Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@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:11:34
Message-Id: 1497514281.1807.2.camel@gentoo.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 Matthias Maier
1 On czw, 2017-06-15 at 03:09 -0500, Matthias Maier wrote:
2 > > > +# @FUNCTION: tc-enables-pie
3 > > > +# @RETURN: Truth if the current compiler generates position-independent code (PIC) which can be linked into executables
4 > > > +# @DESCRIPTION:
5 > > > +# Return truth if the current compiler generates position-independent code (PIC)
6 > > > +# which can be linked into executables.
7 > > > +tc-enables-pie() {
8 > > > + $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null
9 > > > + #if defined(__PIE__)
10 > > > + true
11 > > > + #else
12 > > > + false
13 > > > + #endif
14 > > > + EOF
15 > > > + )
16 > >
17 > > Looks quite horrible. Why can't you just compare the output against
18 > > a value instead of randomly executing it?
19 >
20 > Because we have to execute the compiler anyway and this is the quickest
21 > way of getting the answer we need. Further, piping an unfiltered output
22 > (e.g. -E -dM -x c) through grep is by no means prettier.
23 >
24
25 That's not what I mean. What I mean is that you are executing
26 the filtered output, i.e. calling whatever gets spilt on stdout as shell
27 script.
28
29 --
30 Best regards,
31 Michał Górny

Attachments

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

Replies