LoongArch: Simplify the autoconf check for static PIE
[glibc.git] / sysdeps / loongarch / configure
blob30b60d1983ee15497cbc1e2644ccc139bb37ddad
1 # This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
2  # Local configure fragment for sysdeps/loongarch/elf.
4 printf "%s\n" "#define HIDDEN_VAR_NEEDS_DYNAMIC_RELOC 1" >>confdefs.h
7 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if ${CC-cc} is sufficient to build static PIE on LoongArch" >&5
8 printf %s "checking if ${CC-cc} is sufficient to build static PIE on LoongArch... " >&6; }
9 if test ${libc_cv_static_pie_on_loongarch+y}
10 then :
11   printf %s "(cached) " >&6
12 else $as_nop
14   cat > conftest.S <<\EOF
15 .global _start
16 .type _start, @function
17 _start:
18   li.w $a7, 93
19   li.w $a0, 0
20   syscall 0
22 .data
24   .word 0
25   /* This should produce an R_LARCH_RELATIVE in the static PIE.  */
26   .dword _start
27 EOF
29   libc_cv_static_pie_on_loongarch=no
30   if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest conftest.S'
31   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
32   (eval $ac_try) 2>&5
33   ac_status=$?
34   printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
35   test $ac_status = 0; }; } \
36      && { ac_try='LC_ALL=C $READELF -Wr conftest | grep -q R_LARCH_RELATIVE'
37   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
38   (eval $ac_try) 2>&5
39   ac_status=$?
40   printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
41   test $ac_status = 0; }; } \
42      && ! { ac_try='LC_ALL=C $READELF -Wl conftest | grep -q INTERP'
43   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
44   (eval $ac_try) 2>&5
45   ac_status=$?
46   printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
47   test $ac_status = 0; }; }
48   then
49     libc_cv_static_pie_on_loongarch=yes
50   fi
51   rm -rf conftest*
53 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_static_pie_on_loongarch" >&5
54 printf "%s\n" "$libc_cv_static_pie_on_loongarch" >&6; }
56 if test "$libc_cv_static_pie_on_loongarch" = yes; then
57   printf "%s\n" "#define SUPPORT_STATIC_PIE 1" >>confdefs.h
61   # Check if gcc supports option -mcmodel=medium.
62 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports option -mcmodel=medium" >&5
63 printf %s "checking whether $CC supports option -mcmodel=medium... " >&6; }
64 if test ${libc_cv_loongarch_cmodel_medium+y}
65 then :
66   printf %s "(cached) " >&6
67 else $as_nop
69   if { ac_try='${CC-cc} -c $CFLAGS -mcmodel=medium /dev/null 1>&5'
70   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
71   (eval $ac_try) 2>&5
72   ac_status=$?
73   printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
74   test $ac_status = 0; }; }; then
75     libc_cv_loongarch_cmodel_medium=yes
76   else
77     libc_cv_loongarch_cmodel_medium=no
78   fi
80 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_loongarch_cmodel_medium" >&5
81 printf "%s\n" "$libc_cv_loongarch_cmodel_medium" >&6; }
82 config_vars="$config_vars
83 have-cmodel-medium = $libc_cv_loongarch_cmodel_medium"
85 # Check if asm support vector instructions.
86 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for vector support in assembler" >&5
87 printf %s "checking for vector support in assembler... " >&6; }
88 if test ${libc_cv_loongarch_vec_asm+y}
89 then :
90   printf %s "(cached) " >&6
91 else $as_nop
92   cat > conftest.s <<\EOF
93         vld  $vr0, $sp, 0
94 EOF
95 if { ac_try='${CC-cc} -c $CFLAGS conftest.s -o conftest 1>&5'
96   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
97   (eval $ac_try) 2>&5
98   ac_status=$?
99   printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
100   test $ac_status = 0; }; }; then
101   libc_cv_loongarch_vec_asm=yes
102 else
103   libc_cv_loongarch_vec_asm=no
105 rm -f conftest*
107 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_loongarch_vec_asm" >&5
108 printf "%s\n" "$libc_cv_loongarch_vec_asm" >&6; }
109 if test $libc_cv_loongarch_vec_asm = no; then
110   as_fn_error $? "binutils version is too old, use 2.41 or newer version" "$LINENO" 5