toolchain.eclass: fix tc-enables-* with -ggdb3
authorLuke Dashjr <luke-jr+git@utopios.org>
Tue, 8 Aug 2017 16:33:09 +0000 (16:33 +0000)
committerSergei Trofimovich <slyfox@gentoo.org>
Thu, 10 Aug 2017 21:55:43 +0000 (22:55 +0100)
-ggdb3 builds debug information for macros into binaries. For this reason,
the C preprocessor includes all #defines as-is in the output. The check
in tc-enables-* expects only a fixed output of "true", which fails in this
scenario.

To fix this, `grep` is used to look specifically for "true" in the output
from the preprocessor.

Closes: https://github.com/gentoo/gentoo/pull/5359
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Matthias Maier <tamiko@gentoo.org>
eclass/toolchain-funcs.eclass

index 777fce905f3e5cf99d1c47205a9cc095a51add47..aeb6f7c702991f1022603087eed1e84b0fef9d08 100644 (file)
@@ -798,7 +798,7 @@ gcc-specs-stack-check() {
 # Return truth if the current compiler generates position-independent code (PIC)
 # which can be linked into executables.
 tc-enables-pie() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null
+       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
                #if defined(__PIE__)
                true
                #endif
@@ -816,7 +816,7 @@ tc-enables-pie() {
 #  -fstack-protector-strong
 #  -fstack-protector-all
 tc-enables-ssp() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null
+       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
                #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)
                true
                #endif
@@ -833,7 +833,7 @@ tc-enables-ssp() {
 #  -fstack-protector-strong
 #  -fstack-protector-all
 tc-enables-ssp-strong() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null
+       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
                #if defined(__SSP_STRONG__) || defined(__SSP_ALL__)
                true
                #endif
@@ -849,7 +849,7 @@ tc-enables-ssp-strong() {
 # on level corresponding to any of the following options:
 #  -fstack-protector-all
 tc-enables-ssp-all() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null
+       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null | grep '^true$'
                #if defined(__SSP_ALL__)
                true
                #endif