Module Name:    src
Committed By:   christos
Date:           Sat Mar 22 17:05:48 UTC 2025

Modified Files:
        src/external/gpl3/gcc/dist/gcc/config: netbsd.h
        src/external/gpl3/gcc/lib/libasan: Makefile
        src/external/gpl3/gcc/lib/liblsan: Makefile
        src/external/gpl3/gcc/lib/libtsan: Makefile
Added Files:
        src/external/gpl3/gcc/lib: preinit.mk

Log Message:
PR/59189: RVP: Like Linux and FreeBSD use .preinit_array to initialize the
sanitizers.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/external/gpl3/gcc/dist/gcc/config/netbsd.h
cvs rdiff -u -r0 -r1.1 src/external/gpl3/gcc/lib/preinit.mk
cvs rdiff -u -r1.37 -r1.38 src/external/gpl3/gcc/lib/libasan/Makefile
cvs rdiff -u -r1.10 -r1.11 src/external/gpl3/gcc/lib/liblsan/Makefile
cvs rdiff -u -r1.17 -r1.18 src/external/gpl3/gcc/lib/libtsan/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/dist/gcc/config/netbsd.h
diff -u src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.40 src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.41
--- src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.40	Sun Jul 30 21:46:31 2023
+++ src/external/gpl3/gcc/dist/gcc/config/netbsd.h	Sat Mar 22 13:05:48 2025
@@ -203,9 +203,29 @@ along with GCC; see the file COPYING3.  
   do {									\
     netbsd_patch_builtins ();						\
   } while(0)
-
+/* Link -lasan early on the command line.  For -static-libasan, don't link
+   it for -shared link, the executable should be compiled with -static-libasan
+   in that case, and for executable link with --{,no-}whole-archive around
+   it to force everything into the executable.  And similarly for -ltsan,
+   -lhwasan, and -llsan.  */
 #if defined(HAVE_LD_STATIC_DYNAMIC)
+#undef LIBASAN_EARLY_SPEC
+#define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
+  "%{static-libasan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
+#undef LIBHWASAN_EARLY_SPEC
+#define LIBHWASAN_EARLY_SPEC "%{static-libhwasan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-libhwasan:-lhwasan}"
 #undef LIBTSAN_EARLY_SPEC
-#define LIBTSAN_EARLY_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}"	\
-  " -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "} -lpthread"
+#define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
+  "%{static-libtsan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
+#undef LIBLSAN_EARLY_SPEC
+#define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
+  "%{static-liblsan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
 #endif

Index: src/external/gpl3/gcc/lib/libasan/Makefile
diff -u src/external/gpl3/gcc/lib/libasan/Makefile:1.37 src/external/gpl3/gcc/lib/libasan/Makefile:1.38
--- src/external/gpl3/gcc/lib/libasan/Makefile:1.37	Sun Sep 29 20:32:12 2024
+++ src/external/gpl3/gcc/lib/libasan/Makefile	Sat Mar 22 13:05:48 2025
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.37 2024/09/30 00:32:12 kalvisd Exp $
+# $NetBSD: Makefile,v 1.38 2025/03/22 17:05:48 christos Exp $
 
 UNSUPPORTED_COMPILER.clang=	# defined
 NOSANITIZER=	# defined
@@ -61,4 +61,6 @@ COPTS.asan_interceptors.cpp += -fno-jump
 COPTS.asan_interceptors.cpp += -mlong-jump-table-offsets -Os
 .endif
 
+.include "../preinit.mk"
+
 .include <bsd.lib.mk>

Index: src/external/gpl3/gcc/lib/liblsan/Makefile
diff -u src/external/gpl3/gcc/lib/liblsan/Makefile:1.10 src/external/gpl3/gcc/lib/liblsan/Makefile:1.11
--- src/external/gpl3/gcc/lib/liblsan/Makefile:1.10	Sun Sep 29 20:32:12 2024
+++ src/external/gpl3/gcc/lib/liblsan/Makefile	Sat Mar 22 13:05:48 2025
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2024/09/30 00:32:12 kalvisd Exp $
+# $NetBSD: Makefile,v 1.11 2025/03/22 17:05:48 christos Exp $
 
 .include <bsd.own.mk>
 
@@ -28,4 +28,6 @@ LIBDPLIBS+= pthread ${NETBSDSRCDIR}/lib/
 
 CWARNFLAGS.clang+=	-Wno-error=unused-private-field
 
+.include "../preinit.mk"
+
 .include <bsd.lib.mk>

Index: src/external/gpl3/gcc/lib/libtsan/Makefile
diff -u src/external/gpl3/gcc/lib/libtsan/Makefile:1.17 src/external/gpl3/gcc/lib/libtsan/Makefile:1.18
--- src/external/gpl3/gcc/lib/libtsan/Makefile:1.17	Wed Aug  2 21:36:55 2023
+++ src/external/gpl3/gcc/lib/libtsan/Makefile	Sat Mar 22 13:05:48 2025
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2023/08/03 01:36:55 mrg Exp $
+# $NetBSD: Makefile,v 1.18 2025/03/22 17:05:48 christos Exp $
 
 UNSUPPORTED_COMPILER.clang=     # defined
 NOSANITIZER=    # defined
@@ -67,4 +67,6 @@ LIBDPLIBS+= pthread ${NETBSDSRCDIR}/lib/
 CPPFLAGS+=-DCAN_SANITIZE_UB=0
 COPTS.tsan_interceptors.cpp += -Wno-unused-function
 
+.include "../preinit.mk"
+
 .include <bsd.lib.mk>

Added files:

Index: src/external/gpl3/gcc/lib/preinit.mk
diff -u /dev/null src/external/gpl3/gcc/lib/preinit.mk:1.1
--- /dev/null	Sat Mar 22 13:05:48 2025
+++ src/external/gpl3/gcc/lib/preinit.mk	Sat Mar 22 13:05:48 2025
@@ -0,0 +1,12 @@
+# $NetBSD: preinit.mk,v 1.1 2025/03/22 17:05:48 christos Exp $
+
+FILE=lib${LIB}_preinit.o
+FILES+=${FILE}
+FILESDIR=/usr/lib
+CLEANFILES+=${FILE} ${LIB}_preinit.o
+
+${FILE}: ${LIB}_preinit.o
+	${_MKTARGET_CREATE}
+	cp ${.ALLSRC} ${.TARGET}
+
+.include <bsd.files.mk>

Reply via email to