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 |