From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1147) id ED5283858C2C; Thu, 1 Feb 2024 12:13:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED5283858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706789612; bh=ENsLtMjqBPSzsVjnJp3CJCsfBV3gyn7H8MCySyA86/U=; h=From:To:Subject:Date:From; b=fsjROCHdmi26qYW0uQGpld5V5YP+hWphHW6Y/GgVU1/AR3p8O4v6b8Y0DCkLa4++N vV7WDxOE8JLdkAk29SvKo3vQwsYu/FHzqV7/Lh/GrVIJpMk++icBxCxsuplIAKnTmW ddcyvD6/Fzr7/DEjeJdXJgxt3FSqkXveJFqwy6Ho= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Rainer Orth To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8694] Link shared libasan with -z now on Solaris X-Act-Checkin: gcc X-Git-Author: Rainer Orth X-Git-Refname: refs/heads/master X-Git-Oldrev: 5b9b395b8561efe797842b5f1c435d538d0a5de4 X-Git-Newrev: 099d53e5b5404532e8910d1430f3942c4f07976c Message-Id: <20240201121332.ED5283858C2C@sourceware.org> Date: Thu, 1 Feb 2024 12:13:32 +0000 (GMT) List-Id: https://gcc.gnu.org/g:099d53e5b5404532e8910d1430f3942c4f07976c commit r14-8694-g099d53e5b5404532e8910d1430f3942c4f07976c Author: Rainer Orth Date: Thu Feb 1 13:13:06 2024 +0100 Link shared libasan with -z now on Solaris g++.dg/asan/default-options-1.C FAILs on Solaris/SPARC and x86: FAIL: g++.dg/asan/default-options-1.C -O0 execution test FAIL: g++.dg/asan/default-options-1.C -O1 execution test FAIL: g++.dg/asan/default-options-1.C -O2 execution test FAIL: g++.dg/asan/default-options-1.C -O2 -flto execution test FAIL: g++.dg/asan/default-options-1.C -O2 -flto -flto-partition=none execution test FAIL: g++.dg/asan/default-options-1.C -O3 -g execution test FAIL: g++.dg/asan/default-options-1.C -Os execution test The failure is always the same: AddressSanitizer: CHECK failed: asan_rtl.cpp:397 "((!AsanInitIsRunning() && "ASan init calls itself!")) != (0)" (0x0, 0x0) (tid=1) This happens because libasan makes unportable assumptions about initialization order that don't hold on Solaris. The problem has already been fixed in clang by [Driver] Link shared asan runtime lib with -z now on Solaris/x86 https://reviews.llvm.org/D156325 where it was way more prevalent. This patch applies the same fix to gcc. Tested on i386-pc-solaris2.11 (ld and gld) and sparc-sun-solaris2.11. 2024-01-30 Rainer Orth gcc: * config/sol2.h (LIBASAN_EARLY_SPEC): Add -z now unless -static-libasan. Add missing whitespace. Diff: --- gcc/config/sol2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index 5b1d3371b4d6..85c1f9daf6a9 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -255,7 +255,7 @@ along with GCC; see the file COPYING3. If not see " %{!shared:libasan_preinit%O%s} \ %{static-libasan:%{!shared: -Bstatic "\ LD_WHOLE_ARCHIVE_OPTION " -lasan " LD_NO_WHOLE_ARCHIVE_OPTION \ - "-Bdynamic}}%{!static-libasan:-lasan}" + " -Bdynamic}}%{!static-libasan:-z now -lasan}" /* Error out on -fsanitize=thread|leak. */ #define LIBTSAN_EARLY_SPEC "\