From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CE99E3858C78; Wed, 22 Nov 2023 13:22:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE99E3858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700659332; bh=hZqBBM/LBEID9iOXi/Io4RC5JhK+q8k1EyBQOv3GfIY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cVEb09w0vbRyjlkkp5TlcGIzSWQF+rJTQy/A2gfz6l6V4p0TDuTG/JRm4rZdnfgIT WzczbvDzPPuu88cVX8OxdW8vGEz7cyb4GpWQ3r+LSGmgW55FXnBsXwnpMfAMsOLOhv V76I07I1G0gofTSbpB4UrmDJ6LjnJo3n7dWupJRQ= From: "ro at CeBiTec dot Uni-Bielefeld.DE" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/112563] [14 regression] libsanitizer doesn't assemble with Solaris/sparc as Date: Wed, 22 Nov 2023 13:22:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: build X-Bugzilla-Severity: normal X-Bugzilla-Who: ro at CeBiTec dot Uni-Bielefeld.DE X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112563 --- Comment #9 from ro at CeBiTec dot Uni-Bielefeld.DE --- > --- Comment #8 from Jakub Jelinek --- > So, shall we go with > --- libsanitizer/sanitizer_common/sanitizer_redefine_builtins.h.jj=20=20= =20=20=20 > 2023-11-15 12:45:17.359586776 +0100 > +++ libsanitizer/sanitizer_common/sanitizer_redefine_builtins.h 2023-11-21 > 18:29:52.401817763 +0100 > @@ -15,7 +15,8 @@ > # define SANITIZER_REDEFINE_BUILTINS_H > > // The asm hack only works with GCC and Clang. > -# if !defined(_WIN32) > +// It doesn't work when using Solaris as either. > +# if !defined(_WIN32) && !SANITIZER_SOLARIS > > asm("memcpy =3D __sanitizer_internal_memcpy"); > asm("memmove =3D __sanitizer_internal_memmove"); > @@ -50,7 +51,7 @@ using vector =3D Define_SANITIZER_COMMON_N > } // namespace std > > # endif // __cpluplus > -# endif // !_WIN32 > +# endif // !_WIN32 && !SANITIZER_SOLARIS > > # endif // SANITIZER_REDEFINE_BUILTINS_H > #endif // SANITIZER_COMMON_NO_REDEFINE_BUILTINS > > then (either as local patch or try to push it upstream)? That's way to heavy IMO: it punishes the Solaris/x86 as which isn't affected and also Solaris/SPARC with gas. I've now come up with an alternative. It's a bit ugly, but it gets the work done: diff --git a/libsanitizer/sanitizer_common/sanitizer_redefine_builtins.h b/libsanitizer/sanitizer_common/sanitizer_redefine_builtins.h --- a/libsanitizer/sanitizer_common/sanitizer_redefine_builtins.h +++ b/libsanitizer/sanitizer_common/sanitizer_redefine_builtins.h @@ -17,6 +17,17 @@ // The asm hack only works with GCC and Clang. # if !defined(_WIN32) +// FIXME: Explain. +# if defined(__sparc__) +# define ASM_MEM_DEF(FUNC) \ + __asm__(".global " #FUNC "\n" \ + ".type " #FUNC ",function\n" \ + ".weak " #FUNC "\n" \ + #FUNC ":\n"); +ASM_MEM_DEF(__sanitizer_internal_memcpy) +ASM_MEM_DEF(__sanitizer_internal_memmove) +ASM_MEM_DEF(__sanitizer_internal_memset) +# endif asm("memcpy =3D __sanitizer_internal_memcpy"); asm("memmove =3D __sanitizer_internal_memmove"); asm("memset =3D __sanitizer_internal_memset"); I've run libsanitizer builds on sparc without this patch (gas only since as fails) and with it (as and gas). It fixes the as build failure and leaves the same number of calls to mem* functions in libasan.so as an unpatched tree with gas.=