https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112563

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to r...@cebitec.uni-bielefeld.de from comment #9)
> > --- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> > So, shall we go with
> > --- libsanitizer/sanitizer_common/sanitizer_redefine_builtins.h.jj     
> > 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 = __sanitizer_internal_memcpy");
> >  asm("memmove = __sanitizer_internal_memmove");
> > @@ -50,7 +51,7 @@ using vector = 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" \

Not @function ?

> +                ".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 = __sanitizer_internal_memcpy");
>  asm("memmove = __sanitizer_internal_memmove");
>  asm("memset = __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.

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
indentation changes (if defined(__sparc__) is below the _WIN32 #if, so they
probably want it
indented more and the define even more.  And dunno if defined(__sparc__) or
SANITIZER_SPARC should be used.

Reply via email to