]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
configure: use TEST_CC to check for --no-error-execstack
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 9 Dec 2025 14:58:32 +0000 (11:58 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 11 Dec 2025 11:27:16 +0000 (08:27 -0300)
The ld.lld does not support the --no-error-execstack option, and it is
required only to suppress the linker warning while building tests. A new
configure macro, LIBC_TEST_LINKER_FEATURE, is added to check for linker
features using TEST_CC instead of CC.

Checked on x86_64-linux-gnu and aarch64-linux-gnu with gcc and
TEST_CC set to clang-18 and clan-21.

Reviewed-by: Sam James <sam@gentoo.org>
aclocal.m4
configure
configure.ac

index 5c25a71d8fdb6b3a6feabf820e1f33cc99d28242..b32076d8d05f307bfedd74fd7c349830b6fae7a8 100644 (file)
@@ -268,6 +268,38 @@ else
 fi
 AC_MSG_RESULT($libc_linker_feature)])
 
+dnl Check linker option support.
+dnl LIBC_TEST_LINKER_FEATURE([ld_option], [cc_option], [action-if-true], [action-if-false])
+AC_DEFUN([LIBC_TEST_LINKER_FEATURE],
+[AC_MSG_CHECKING([for linker that supports $1])
+libc_linker_feature=no
+cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+saved_CC="$CC"
+CC="$TEST_CC"
+if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+                 $2 -nostdlib -nostartfiles
+                 -fPIC -shared -o conftest.so conftest.c
+                 1>&AS_MESSAGE_LOG_FD])
+then
+  if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp $2 -nostdlib \
+      -nostartfiles -fPIC -shared -o conftest.so conftest.c 2>&1 \
+      | grep "warning: $1 ignored" > /dev/null 2>&1; then
+    true
+  else
+    libc_linker_feature=yes
+  fi
+fi
+rm -f conftest*
+if test $libc_linker_feature = yes; then
+  $3
+else
+  $4
+fi
+CC="$saved_CC"
+AC_MSG_RESULT($libc_linker_feature)])
+
 dnl Add a makefile variable, with value set from a shell string
 dnl (expanded by the shell inside double quotes), to config.make.
 dnl LIBC_CONFIG_VAR(make-variable, shell-value)
index 9e79accc434821ed4e35158a407e4241b3776be2..f93530f7bacca7e1f986e1184f0daa105de4d5e9 100755 (executable)
--- a/configure
+++ b/configure
@@ -659,7 +659,7 @@ libc_cv_has_glob_dat
 libc_cv_fpie
 libc_cv_test_static_pie
 libc_cv_z_execstack
-libc_cv_no_error_execstack
+libc_cv_test_no_error_execstack
 ASFLAGS_config
 libc_cv_cc_with_libunwind
 libc_cv_insert
@@ -7142,6 +7142,8 @@ libc_linker_feature=no
 cat > conftest.c <<EOF
 int _start (void) { return 42; }
 EOF
+saved_CC="$CC"
+CC="$TEST_CC"
 if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
                  -Wl,--no-error-execstack -nostdlib -nostartfiles
                  -fPIC -shared -o conftest.so conftest.c
@@ -7162,10 +7164,11 @@ then
 fi
 rm -f conftest*
 if test $libc_linker_feature = yes; then
-  libc_cv_no_error_execstack=yes
+  libc_cv_test_no_error_execstack=yes
 else
-  libc_cv_no_error_execstack=no
+  libc_cv_test_no_error_execstack=no
 fi
+CC="$saved_CC"
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
 printf "%s\n" "$libc_linker_feature" >&6; }
 
index 784e9e15a0f0463e8aea3a7bdaeace3c4fa9c307..cf6ddd1d33576446922824def2f84407e094ed29 100644 (file)
@@ -1328,9 +1328,9 @@ if test $libc_cv_as_noexecstack = yes; then
 fi
 AC_SUBST(ASFLAGS_config)
 
-LIBC_LINKER_FEATURE([--no-error-execstack], [-Wl,--no-error-execstack],
-                   [libc_cv_no_error_execstack=yes], [libc_cv_no_error_execstack=no])
-AC_SUBST(libc_cv_no_error_execstack)
+LIBC_TEST_LINKER_FEATURE([--no-error-execstack], [-Wl,--no-error-execstack],
+                   [libc_cv_test_no_error_execstack=yes], [libc_cv_test_no_error_execstack=no])
+AC_SUBST(libc_cv_test_no_error_execstack)
 
 LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
                    [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])