From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ACA603858D3C; Wed, 22 Nov 2023 13:37:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACA603858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700660221; bh=d7dRJ26sDQNCMfe5ihmXeUAVlqqv4SVb1sQNZ1AcNbE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RMZWKDgg/BBNrOhi91yRnbao+d8qpTIwch3sQI27mz5u9O0FsDIyB0okO/r3Y3836 t4tn/Fewxpr9O6vLjY/ajF9GzLUJ9cL1zvtmMe6Vdwpev2BhMFdvyDAfGcCRVrlqC2 c1h46TaYNI/cz6Fu2fMNjsnnX0DXfJ8ZmDcrVoF8= 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:37:01 +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 #11 from ro at CeBiTec dot Uni-Bielefeld.DE --- > --- Comment #10 from Jakub Jelinek --- > (In reply to ro@CeBiTec.Uni-Bielefeld.DE from comment #9) [...] >> I've now come up with an alternative. It's a bit ugly, but it gets the >> work done: >>=20 >> 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) >>=20=20 >> +// FIXME: Explain. >> +# if defined(__sparc__) >> +# define ASM_MEM_DEF(FUNC) \ >> + __asm__(".global " #FUNC "\n" \ >> + ".type " #FUNC ",function\n" \ > > Not @function ? No, this should be #function: that's the only variant sparc as understands, and gas does for compatibility. >> + ".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"); >>=20 >> 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. > > If it works, nice. Can you file it on github.com/llvm/llvm-project as an= issue > and see if upstream is willing to accept it? I think they'll want some Can do, either as an issue or directly as a pull request. I'll run it through a full llvm build, too, first. > indentation changes (if defined(__sparc__) is below the _WIN32 #if, so th= ey > probably want it > indented more and the define even more. And dunno if defined(__sparc__) = or > SANITIZER_SPARC should be used. I know: LLVM has clang/tools/clang-format/clang-format-diff.py to handle this. I usually run my patches through that first, unlike it messes up the existing formatting as was the case for pull request #72973. The patches also needs an explanatory comment; this was just a proof of concept. It might be even better to restrict the hack to __sparc__ && __sun__ && __svr4__ to avoid interfering with Linux/sparc64.=