[PATCH 1/5] configure: use TEST_CC to check for --no-error-execstack
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Dec 8 12:30:50 GMT 2025
On 05/12/25 22:54, H.J. Lu wrote:
> On Sat, Dec 6, 2025 at 3:13 AM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> 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.
>> ---
>> aclocal.m4 | 32 ++++++++++++++++++++++++++++++++
>> configure | 3 +++
>> configure.ac | 2 +-
>> 3 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/aclocal.m4 b/aclocal.m4
>> index 5c25a71d8f..b32076d8d0 100644
>> --- a/aclocal.m4
>> +++ b/aclocal.m4
>> @@ -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)
>> diff --git a/configure b/configure
>> index 09ac6ff760..ff7c1d45b8 100755
>> --- a/configure
>> +++ b/configure
>> @@ -7143,6 +7143,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
>> @@ -7167,6 +7169,7 @@ if test $libc_linker_feature = yes; then
>> else
>> libc_cv_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; }
>>
>> diff --git a/configure.ac b/configure.ac
>> index 73176840cc..1cde589da6 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1328,7 +1328,7 @@ if test $libc_cv_as_noexecstack = yes; then
>> fi
>> AC_SUBST(ASFLAGS_config)
>>
>> -LIBC_LINKER_FEATURE([--no-error-execstack], [-Wl,--no-error-execstack],
>> +LIBC_TEST_LINKER_FEATURE([--no-error-execstack], [-Wl,--no-error-execstack],
>> [libc_cv_no_error_execstack=yes], [libc_cv_no_error_execstack=no])
>
> I think libc_cv_no_error_execstack should be renamed to
> libc_cv_test_no_error_execstack.
Ack, I will rename it.
More information about the Libc-alpha
mailing list