1 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2 # Local configure fragment for sysdeps/loongarch/elf.
4 dnl It is always possible to access static and hidden symbols in an
5 dnl position independent way.
6 AC_DEFINE(HIDDEN_VAR_NEEDS_DYNAMIC_RELOC)
8 dnl Test if the toolchain is new enough for static PIE.
9 dnl We need a GAS supporting explicit reloc (older GAS produces stack-based
10 dnl reloc and triggers an internal error in the linker). And, we need GCC to
11 dnl pass the correct linker flags for static PIE. We strictly require GAS >=
12 dnl 2.41 so we don't need to check the assembler capability, but we need to
13 dnl check if GCC is doing the correct thing.
14 AC_CACHE_CHECK([if ${CC-cc} is sufficient to build static PIE on LoongArch],
15 libc_cv_static_pie_on_loongarch, [
16 cat > conftest.S <<\EOF
18 .type _start, @function
27 /* This should produce an R_LARCH_RELATIVE in the static PIE. */
31 libc_cv_static_pie_on_loongarch=no
32 if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostdlib -fPIE -o conftest conftest.S]) \
33 && AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest | grep -q R_LARCH_RELATIVE]) \
34 && ! AC_TRY_COMMAND([LC_ALL=C $READELF -Wl conftest | grep -q INTERP])
36 libc_cv_static_pie_on_loongarch=yes
40 if test "$libc_cv_static_pie_on_loongarch" = yes; then
41 AC_DEFINE(SUPPORT_STATIC_PIE)
44 # Check if gcc supports option -mcmodel=medium.
45 AC_CACHE_CHECK(whether $CC supports option -mcmodel=medium,
46 libc_cv_loongarch_cmodel_medium, [
47 if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS -mcmodel=medium /dev/null 1>&AS_MESSAGE_LOG_FD); then
48 libc_cv_loongarch_cmodel_medium=yes
50 libc_cv_loongarch_cmodel_medium=no
52 LIBC_CONFIG_VAR([have-cmodel-medium], [$libc_cv_loongarch_cmodel_medium])
54 # Check if asm support vector instructions.
55 AC_CACHE_CHECK(for vector support in assembler, libc_cv_loongarch_vec_asm, [dnl
56 cat > conftest.s <<\EOF
59 if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.s -o conftest 1>&AS_MESSAGE_LOG_FD); then
60 libc_cv_loongarch_vec_asm=yes
62 libc_cv_loongarch_vec_asm=no
65 if test $libc_cv_loongarch_vec_asm = no; then
66 AC_MSG_ERROR([binutils version is too old, use 2.41 or newer version])