NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-sparc/58352: ld: /usr/lib/libubsan.so: undefined reference to `__sync_val_compare_and_swap_8'



The following reply was made to PR port-sparc/58352; it has been noted by GNATS.

From: Rin Okuyama <rokuyama.rk%gmail.com@localhost>
To: matthew green <mrg%NetBSD.org@localhost>, Martin Husemann <martin%duskware.de@localhost>
Cc: gnats-bugs%netbsd.org@localhost, port-sparc-maintainer%netbsd.org@localhost,
 gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost, campbell+netbsd%mumble.net@localhost
Subject: Re: port-sparc/58352: ld: /usr/lib/libubsan.so: undefined reference
 to `__sync_val_compare_and_swap_8'
Date: Sun, 30 Jun 2024 15:28:31 +0900

 After some investigation, I've found that sanitizer already
 has its own 64-bit atomic ops for platforms without them.
 
 With the attached patch:
 - libasan works on i386
 - libubsan works on i386, powerpc, and vax (with WIP patches)
 
 Yes, this adds some performance penalty for these platforms,
 however, it is better than having extra diff to upstream, IMO.
 
 Comments?
 
 Thanks,
 rin
 ----
 diff --git a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
 index ccf18f0786d..79f6ad71096 100644
 --- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
 +++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h
 @@ -94,11 +94,17 @@ inline bool atomic_compare_exchange_weak(volatile T *a,
   }  // namespace __sanitizer
   
   // This include provides explicit template instantiations for atomic_uint64_t
 -// on MIPS32, which does not directly support 8 byte atomics. It has to
 +// on platforms, which do not directly support 8 byte atomics. It has to
   // proceed the template definitions above.
   #if defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
   #  include "sanitizer_atomic_clang_mips.h"
   #endif
 +#if SANITIZER_NETBSD
 +#  include <machine/types.h>
 +#  ifndef __HAVE_ATOMIC64_OPS
 +#    include "sanitizer_atomic_clang_mips.h"
 +#  endif
 +#endif
   
   #undef ATOMIC_ORDER
   
 diff --git a/external/gpl3/gcc/lib/Makefile.sanitizer b/external/gpl3/gcc/lib/Makefile.sanitizer
 index e574f902c22..00e9f149405 100644
 --- a/external/gpl3/gcc/lib/Makefile.sanitizer
 +++ b/external/gpl3/gcc/lib/Makefile.sanitizer
 @@ -123,13 +123,3 @@ COPTS.sanitizer_symbolizer_report.cc += -O1
   COPTS.ubsan_diag.cc += -O1
   COPTS.ubsan_init.cc += -O1
   .endif
 -
 -# XXX GCC 12 sanitizers has higher minimal requirements upon some CPUs.
 -# - 32-bit SPARC needs v8 to supply eg __sync_add_and_fetch_4
 -# - i386 needs i586 for __sync_val_compare_and_swap_8.
 -.if ${MACHINE_ARCH} == "sparc"
 -COPTS+= -mcpu=v8
 -.endif
 -.if ${MACHINE_ARCH} == "i386"
 -COPTS+= -march=i586
 -.endif
 


Home | Main Index | Thread Index | Old Index