aboutsummaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorMichael Schmidt <github@mschmidt.me>2017-07-27 12:03:57 +0200
committerMichael Schmidt <github@mschmidt.me>2017-07-27 12:03:57 +0200
commitede6344f3791e406cfd3042ab5a2395d09ff16a1 (patch)
tree26bd2e91e44d33458cdb1575eee2855b91303a60 /configure
parentc310fe9acf361dd6862d894523ff979806ac4536 (diff)
downloadcompcert-ede6344f3791e406cfd3042ab5a2395d09ff16a1.tar.gz
compcert-ede6344f3791e406cfd3042ab5a2395d09ff16a1.zip
generalize test for compiler options
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure37
1 files changed, 22 insertions, 15 deletions
diff --git a/configure b/configure
index d9738f2d..66db7d12 100755
--- a/configure
+++ b/configure
@@ -157,10 +157,10 @@ target=${target#[a-zA-Z0-9]*-}
# Per-target configuration
-clinker_needs_no_pie=true
asm_supports_cfi=""
casm_options=""
casmruntime=""
+clinker_needs_no_pie=true
clinker_options=""
cprepro_options=""
struct_passing=""
@@ -378,6 +378,7 @@ if test "$arch" = "x86" -a "$bitsize" = "64"; then
esac
fi
+
#
# RISC-V Target Configuration
#
@@ -401,12 +402,31 @@ if test "$arch" = "riscV"; then
system="linux"
fi
+
#
# Finalize Target Configuration
#
if test -z "$casmruntime"; then casmruntime="$casm $casm_options"; fi
+# Invoke a C compiler, e.g. to check for availability of command-line options
+testcompiler () {
+ tmpsrc="${TMPDIR:-/tmp}/compcert-configure-$$.c"
+ rm -f "$tmpsrc"
+ tmpout="${TMPDIR:-/tmp}/compcert-configure-$$.out"
+ rm -f "$tmpout"
+ cat >> "$tmpsrc" <<EOF
+int main (void)
+{
+ return 0;
+}
+EOF
+ "$@" -o "$tmpout" "$tmpsrc" >/dev/null 2>/dev/null
+ retcode=$?
+ rm -f "$tmpsrc" "$tmpout"
+ return $retcode
+}
+
#
# Test Assembler Support for CFI Directives
#
@@ -435,23 +455,10 @@ fi
#
if ($clinker_needs_no_pie) then
echo "Testing linker support for '-no-pie' option... " | tr -d '\n'
- fx=/tmp/compcert-configure-$$.elf
- rm -f $fx
- f=/tmp/compcert-configure-$$.c
- rm -f $f
- cat >> $f <<EOF
-int main (void)
-{
- return 0;
-}
-EOF
- $cc -no-pie -o $fx $f >/dev/null 2>&1
- status=$?
- if [ $status -eq 0 ]
+ if testcompiler ${cc} -no-pie;
then echo "yes"; clinker_options="${clinker_options} -no-pie"
else echo "no"; clinker_needs_no_pie=false
fi
- rm -f $f $fx
fi