toolchain-funcs.eclass: fix tc-cpp-is-true() to work with clang
authorMattias Nissler <mnissler@chromium.org>
Mon, 4 Nov 2019 10:11:20 +0000 (10:11 +0000)
committerSergei Trofimovich <slyfox@gentoo.org>
Wed, 6 Nov 2019 22:44:33 +0000 (22:44 +0000)
Clang's preprocessor likes to output a leading newline, which makes
the comparison always fail. GCC generates additional output with certain
flags (e.g. -ggdb3) as well. Hence, switch the test to trigger a
preprocessor error when the condition is not true and examine the exit
code.

Bug: https://bugs.gentoo.org/698912

Signed-off-by: Mattias Nissler <mnissler@chromium.org>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
eclass/toolchain-funcs.eclass

index e358d484417ab0ddad812ce54feb9141618cc2e8..1bc6cbbc1088d9ff0fbdbe6c9339abb01383b61c 100644 (file)
@@ -207,14 +207,13 @@ tc-cpp-is-true() {
        local CONDITION=${1}
        shift
 
-       local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
-                       #if ${CONDITION}
-                       true
-                       #endif
-               EOF
-       )
-
-       [[ ${RESULT} == true ]]
+       $(tc-getTARGET_CPP) "${@}" -P - <<-EOF >/dev/null 2>&1
+               #if ${CONDITION}
+               true
+               #else
+               #error false
+               #endif
+       EOF
 }
 
 # @FUNCTION: tc-detect-is-softfloat