I noticed that gcc/config/sol2.h uses USE_GNU_LD as a guard in one
place only. This is a cross of USE_GLD and HAVE_GNU_LD which doesn't
exist so the gld variant is never used.
This went unnoticed since the wrong versions of LD_WHOLE_ARCHIVE_OPTION
and LD_NO_WHOLE_ARCHIVE_OPTION are only ever used in LIBASAN_EARLY_SPEC
and only effective when -static-libasan is used. gld would only warn
about the unsupported -z options here.
The issue wasn't noticed before since the only testcase using
-static-libasan isn't run on Solaris, which this patch also corrects.
Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 (both as/ld and gas/gld).
2025-11-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc:
* config/sol2.h: Check USE_GLD instead of USE_GNU_LD.
gcc/testsuite:
* c-c++-common/asan/pr59063-2.c: Enable on Solaris.
in that case, and for executable link with --{,no-}whole-archive around
it to force everything into the executable. */
-#ifndef USE_GNU_LD
+#ifndef USE_GLD
#define LD_WHOLE_ARCHIVE_OPTION "-z allextract"
#define LD_NO_WHOLE_ARCHIVE_OPTION "-z defaultextract"
#else
-/* { dg-do run { target { *-*-linux* *-*-freebsd* } } } */
+/* { dg-do run { target { *-*-linux* *-*-freebsd* *-*-solaris2* } } } */
/* { dg-options "-static-libasan" } */
#include <time.h>