Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: toolchain@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 2/4] toolchain-funcs.eclass: Assume CPP="$(tc-getCC) -E" when unset, #582822
Date: Fri, 24 Jun 2016 20:09:27
Message-Id: 20160624200733.8446-3-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH v4] tc-get-compiler-type() + wrappers by "Michał Górny"
1 Modify the tc-getCPP and tc-getBUILD_CPP functions to use "$(tc-getCC)
2 -E" (i.e. the C compiler's preprocessing call) instead of falling back
3 to 'cpp'. This ensures that in environment with CC (and CXX) overriden
4 the correct compiler is used rather than the one selected by gcc-config,
5 which in turn fixes gcc version queries.
6
7 The alternative would be to always override CPP along with CC & CXX.
8 However, that is uncommon and is known to break some packages.
9
10 Bug: https://bugs.gentoo.org/show_bug.cgi?id=582822
11 ---
12 eclass/toolchain-funcs.eclass | 4 ++--
13 1 file changed, 2 insertions(+), 2 deletions(-)
14
15 diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
16 index 8ecc736..1baab96 100644
17 --- a/eclass/toolchain-funcs.eclass
18 +++ b/eclass/toolchain-funcs.eclass
19 @@ -59,7 +59,7 @@ tc-getCC() { tc-getPROG CC gcc "$@"; }
20 # @FUNCTION: tc-getCPP
21 # @USAGE: [toolchain prefix]
22 # @RETURN: name of the C preprocessor
23 -tc-getCPP() { tc-getPROG CPP cpp "$@"; }
24 +tc-getCPP() { tc-getPROG CPP "${CC:-gcc} -E" "$@"; }
25 # @FUNCTION: tc-getCXX
26 # @USAGE: [toolchain prefix]
27 # @RETURN: name of the C++ compiler
28 @@ -132,7 +132,7 @@ tc-getBUILD_CC() { tc-getBUILD_PROG CC gcc "$@"; }
29 # @FUNCTION: tc-getBUILD_CPP
30 # @USAGE: [toolchain prefix]
31 # @RETURN: name of the C preprocessor for building binaries to run on the build machine
32 -tc-getBUILD_CPP() { tc-getBUILD_PROG CPP cpp "$@"; }
33 +tc-getBUILD_CPP() { tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"; }
34 # @FUNCTION: tc-getBUILD_CXX
35 # @USAGE: [toolchain prefix]
36 # @RETURN: name of the C++ compiler for building binaries to run on the build machine
37 --
38 2.9.0