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'



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