Ray-V / tde-slackbuilds

A fork of Thorn Inurcide's SlackBuilds for the Trinity Desktop Environment
17 stars 5 forks source link

crash and burn using clang #28

Closed Ndolam closed 2 years ago

Ndolam commented 2 years ago

Ray, thanks for your efforts here.

I saw the option to use clang, and so for better or worse I tried it. Cland crashed and burned with this:

/tmp/build/tmp-tdeutils/tdeutils-trinity-14.0.12/kmilo/generic/generic_monitor.cpp:78:16: error: non-constant-expression cannot be narrowed from type 'int' to 'uint' (aka 'unsigned int') in initializer list [-Wc++11-narrowing] { "Search", TDEShortcut("XF86Search"), TQT_SLOT(launchSearch()) }, ^~~~~~~~~

There were a ot of similar errors. I guess you could say this is a TDE bug, but in any case when I changed to gcc I was able to build. Obviously gcc is either smarter about that conversion or stupider about checking for invalid conversions. Or maybe there is a third choice.

In any case, I'm wondering whether anyone else was able to compile this on Slackware64 15.0 with clang, or whether you want to remove the option to use clang, or put in a warning, or ...

If you want me to try anything out on my system let me know.

Ray-V commented 2 years ago

This issue seems to be common in the wider world and is generally fixed by a patch specific to the build that failed, so I guess it should be a TDE fix.

However, according to the gcc man page, With -std=c++11, -Wno-narrowing suppresses the diagnostic required by the standard and it can be used as a work-around.

This works for me:

--- Core/tdeutils/tdeutils.SlackBuild
+++ Core/tdeutils/tdeutils.SlackBuild
@@ -46,0 +47,4 @@
+
+## work-around for clang build failure
+[[ $COMPILER_CXX == clang++ ]] && NO_C11=-Wno-c++11-narrowing
+
@@ -49 +53 @@
-    -DCMAKE_CXX_FLAGS="$SLKRCFLAGS" \
+    -DCMAKE_CXX_FLAGS="$SLKRCFLAGS ${NO_C11:-}" \
Ndolam commented 2 years ago

Thanks Ray. I have passed this on to Slavek and maybe the code which so upsets clang will be modified at some point.