From d8da506981905752f84165f622fdf0ee26011744 Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Thu, 8 Feb 2018 17:15:01 +0100 Subject: 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.) --- configure | 17 ++++++++++++----- 1 file 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 -- cgit