Gentoo Archives: gentoo-dev

From: Matthias Maier <tamiko@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 1/5] toolchain-funcs.eclass: Add functions for detection of PIE / SSP in way compatible with GCC >=6.
Date: Thu, 15 Jun 2017 08:09:47
Message-Id: 874lvhhdu0.fsf@kestrel.kyomu.43-1.org
In Reply to: Re: [gentoo-dev] [PATCH 1/5] toolchain-funcs.eclass: Add functions for detection of PIE / SSP in way compatible with GCC >=6. by "Michał Górny"
1 >> +# @FUNCTION: tc-enables-pie
2 >> +# @RETURN: Truth if the current compiler generates position-independent code (PIC) which can be linked into executables
3 >> +# @DESCRIPTION:
4 >> +# Return truth if the current compiler generates position-independent code (PIC)
5 >> +# which can be linked into executables.
6 >> +tc-enables-pie() {
7 >> + $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null
8 >> + #if defined(__PIE__)
9 >> + true
10 >> + #else
11 >> + false
12 >> + #endif
13 >> + EOF
14 >> + )
15 >
16 > Looks quite horrible. Why can't you just compare the output against
17 > a value instead of randomly executing it?
18
19 Because we have to execute the compiler anyway and this is the quickest
20 way of getting the answer we need. Further, piping an unfiltered output
21 (e.g. -E -dM -x c) through grep is by no means prettier.
22
23 Best,
24 Matthias

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies