aboutsummaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorMichael Schmidt <github@mschmidt.me>2018-02-08 17:15:01 +0100
committerXavier Leroy <xavierleroy@users.noreply.github.com>2018-02-08 17:15:01 +0100
commitd8da506981905752f84165f622fdf0ee26011744 (patch)
tree05c36693c9684dda1a93372595516f42535cbb00 /configure
parent14aad5e8f330423427e63265dcb9bff45a3f55f3 (diff)
downloadcompcert-d8da506981905752f84165f622fdf0ee26011744.tar.gz
compcert-d8da506981905752f84165f622fdf0ee26011744.zip
Configure check for PIE (#55)
When checking for -no-pie and -nopie, evaluate gcc output for error message like 'unknown argument'. (Relying on the error code is not enough.)
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure17
1 files changed, 12 insertions, 5 deletions
diff --git a/configure b/configure
index 081ac202..58cd51ec 100755
--- a/configure
+++ b/configure
@@ -432,12 +432,17 @@ int main (void)
return 0;
}
EOF
- "$@" -o "$tmpout" "$tmpsrc" >/dev/null 2>/dev/null
+ errout=$("$@" -o "$tmpout" "$tmpsrc" 2>&1 >/dev/null)
retcode=$?
+ errcount=$(echo "${errout}" | grep -ciE "(unknown|unsupported|unrecognized).*(option|argument)")
rm -f "$tmpsrc" "$tmpout"
- return $retcode
+ # Test failed or error is logged to stderr
+ if [ "${retcode}" != "0" ] || [ "${errcount}" != "0" ]; then return 1; fi
+ # OK and no error was logged
+ return 0
}
+
#
# Test Assembler Support for CFI Directives
#
@@ -462,12 +467,14 @@ fi
#
-# Test Availability of Option '-no-pie'
+# Test Availability of Option '-no-pie' or '-nopie'
#
if ($clinker_needs_no_pie) then
- echo "Testing linker support for '-no-pie' option... " | tr -d '\n'
+ echo "Testing linker support for '-no-pie' / '-nopie' option... " | tr -d '\n'
if testcompiler ${cc} -no-pie;
- then echo "yes"; clinker_options="${clinker_options} -no-pie"
+ then echo "yes, '-no-pie'"; clinker_options="${clinker_options} -no-pie"
+ elif testcompiler ${cc} -nopie;
+ then echo "yes, '-nopie'"; clinker_options="${clinker_options} -nopie"
else echo "no"; clinker_needs_no_pie=false
fi
fi