[PATCH] ld: Properly override compiler flags in tests

Sam James sam@gentoo.org
Sat Aug 16 12:25:06 GMT 2025


Sam James <sam@gentoo.org> writes:

> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> Some tests need to be compiled with additional flags.  When binutils is
>> built and compiled with
>>
>> CC="gcc -fsanitize=address,undefined" CXX="g++ -fsanitize=address,undefined"
>>
>> [...]
>
> [...]

We also get doubled-up -fno-sanitize=all flags in e.g. pr21964-2 but I think that's
because of:

# Only run them when libdl is available.
if [check_libdl_available] {
  # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
  # sections.
  # Disable all sanitizers.
  set old_CFLAGS "$CFLAGS_FOR_TARGET_TEST"
  append CFLAGS_FOR_TARGET_TEST " $NOSANITIZE_CFLAGS"
  run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsd*"
  set CFLAGS_FOR_TARGET_TEST "$old_CFLAGS"
}

in ld/testsuite/ld-elf/shared.exp. I think the doubling up is OK
here. It only happens in some places in the file anyway. I just mention
it for completeness.


More information about the Binutils mailing list