Module Name:    src
Committed By:   martin
Date:           Sun Sep  1 10:44:24 UTC 2019

Modified Files:
        src [netbsd-9]: Makefile
        src/common/lib/libc/gmon [netbsd-9]: mcount.c
        src/distrib/sets/lists/base [netbsd-9]: mi
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64 [netbsd-9]:
            Makefile
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64 
[netbsd-9]:
            Makefile
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64 [netbsd-9]:
            Makefile
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64 
[netbsd-9]:
            Makefile
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64 [netbsd-9]:
            Makefile
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64 
[netbsd-9]:
            Makefile
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64 
[netbsd-9]:
            Makefile
        src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64 
[netbsd-9]:
            Makefile
        
src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64 
[netbsd-9]:
            Makefile
        src/external/bsd/fetch/lib [netbsd-9]: Makefile
        src/external/gpl2/lvm2 [netbsd-9]: lvm2tools.mk
        src/lib/libc/gen [netbsd-9]: sysctlgetmibinfo.c
        src/share/mk [netbsd-9]: Makefile bsd.lib.mk bsd.prog.mk
        src/tests/lib/libc/net [netbsd-9]: Makefile
Added Files:
        src/share/mk [netbsd-9]: bsd.sanitizer.mk

Log Message:
Pull up following revision(s) (requested by kamil in ticket #126):

        
external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile: 
revision 1.3
        external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile: 
revision 1.3
        external/gpl2/lvm2/lvm2tools.mk: revision 1.5
        common/lib/libc/gmon/mcount.c: revision 1.14
        Makefile: revision 1.331
        share/mk/Makefile: revision 1.51
        external/bsd/fetch/lib/Makefile: revision 1.12
        external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile: 
revision 1.3
        tests/lib/libc/net/Makefile: revision 1.12
        
external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile:
 revision 1.3
        external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile: 
revision 1.3
        distrib/sets/lists/base/mi: revision 1.1213
        share/mk/bsd.lib.mk: revision 1.380
        
external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile: 
revision 1.3
        external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile: 
revision 1.3
        share/mk/bsd.sanitizer.mk: revision 1.1
        share/mk/bsd.prog.mk: revision 1.323
        external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile: 
revision 1.3
        external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile: 
revision 1.3
        lib/libc/gen/sysctlgetmibinfo.c: revision 1.14

Enhance the support of LLVM sanitizers

Define _REENTRANT for MKSANITIZER build. This is needed for at least stdio
code. This caused new build issued with duplicated symbols in few places
and rump kernel code picking different code paths borrowed from libc.

Handle all this in one go.

Add bsd.sanitizer.mk to share common code used by programs and libraries.

Switch from realall to beforeinstall target in .syms files. This is more
reliable in MKSANITIZER.


To generate a diff of this commit:
cvs rdiff -u -r1.327.2.1 -r1.327.2.2 src/Makefile
cvs rdiff -u -r1.13 -r1.13.18.1 src/common/lib/libc/gmon/mcount.c
cvs rdiff -u -r1.1209.2.1 -r1.1209.2.2 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    
src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 \
    
src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile
cvs rdiff -u -r1.11 -r1.11.6.1 src/external/bsd/fetch/lib/Makefile
cvs rdiff -u -r1.4 -r1.4.46.1 src/external/gpl2/lvm2/lvm2tools.mk
cvs rdiff -u -r1.13 -r1.13.16.1 src/lib/libc/gen/sysctlgetmibinfo.c
cvs rdiff -u -r1.50 -r1.50.4.1 src/share/mk/Makefile
cvs rdiff -u -r1.379 -r1.379.2.1 src/share/mk/bsd.lib.mk
cvs rdiff -u -r1.319.2.2 -r1.319.2.3 src/share/mk/bsd.prog.mk
cvs rdiff -u -r0 -r1.1.2.2 src/share/mk/bsd.sanitizer.mk
cvs rdiff -u -r1.11 -r1.11.2.1 src/tests/lib/libc/net/Makefile

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

Modified files:

Index: src/Makefile
diff -u src/Makefile:1.327.2.1 src/Makefile:1.327.2.2
--- src/Makefile:1.327.2.1	Sun Sep  1 10:36:26 2019
+++ src/Makefile	Sun Sep  1 10:44:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.327.2.1 2019/09/01 10:36:26 martin Exp $
+#	$NetBSD: Makefile,v 1.327.2.2 2019/09/01 10:44:22 martin Exp $
 
 #
 # This is the top-level makefile for building NetBSD. For an outline of
@@ -481,7 +481,7 @@ do-compat-lib: .PHONY .MAKE
 	${MAKEDIRTARGET} compat build_install BOOTSTRAP_SUBDIRS="../../../lib"
 
 do-sanitizer: .PHONY .MAKE
-	${MAKEDIRTARGET} external/bsd/compiler_rt all
+	${MAKEDIRTARGET} external/bsd/compiler_rt build_install
 
 do-sanitizer-tools: .PHONY .MAKE
 .if !exists(${TOOLDIR}/lib/clang) && ${HAVE_LLVM:Uno} == "yes"

Index: src/common/lib/libc/gmon/mcount.c
diff -u src/common/lib/libc/gmon/mcount.c:1.13 src/common/lib/libc/gmon/mcount.c:1.13.18.1
--- src/common/lib/libc/gmon/mcount.c:1.13	Sun Feb 28 02:56:39 2016
+++ src/common/lib/libc/gmon/mcount.c	Sun Sep  1 10:44:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcount.c,v 1.13 2016/02/28 02:56:39 christos Exp $	*/
+/*	$NetBSD: mcount.c,v 1.13.18.1 2019/09/01 10:44:22 martin Exp $	*/
 
 /*
  * Copyright (c) 2003, 2004 Wasabi Systems, Inc.
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "@(#)mcount.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: mcount.c,v 1.13 2016/02/28 02:56:39 christos Exp $");
+__RCSID("$NetBSD: mcount.c,v 1.13.18.1 2019/09/01 10:44:22 martin Exp $");
 #endif
 #endif
 
@@ -88,7 +88,7 @@ __RCSID("$NetBSD: mcount.c,v 1.13 2016/0
 #include "reentrant.h"
 #endif
 
-#ifdef _REENTRANT
+#if defined(_REENTRANT) && !defined(_RUMPKERNEL)
 extern thread_key_t _gmonkey;
 extern struct gmonparam _gmondummy;
 struct gmonparam *_m_gmon_alloc(void);
@@ -143,7 +143,7 @@ _MCOUNT_DECL(u_long frompc, u_long selfp
 	int s;
 #endif
 
-#if defined(_REENTRANT) && !defined(_KERNEL)
+#if defined(_REENTRANT) && !defined(_KERNEL) && !defined(_RUMPKERNEL)
 	if (__isthreaded) {
 		/* prevent re-entry via thr_getspecific */
 		if (_gmonparam.state != GMON_PROF_ON)

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1209.2.1 src/distrib/sets/lists/base/mi:1.1209.2.2
--- src/distrib/sets/lists/base/mi:1.1209.2.1	Fri Aug 16 19:10:42 2019
+++ src/distrib/sets/lists/base/mi	Sun Sep  1 10:44:23 2019
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1209.2.1 2019/08/16 19:10:42 martin Exp $
+# $NetBSD: mi,v 1.1209.2.2 2019/09/01 10:44:23 martin Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -4837,6 +4837,7 @@
 ./usr/share/mk/bsd.port.subdir.mk		base-obsolete		obsolete
 ./usr/share/mk/bsd.prog.mk			base-mk-share		share
 ./usr/share/mk/bsd.rpc.mk			base-mk-share		share
+./usr/share/mk/bsd.sanitizer.mk			base-mk-share		share
 ./usr/share/mk/bsd.shlib.mk			base-mk-share		share
 ./usr/share/mk/bsd.subdir.mk			base-mk-share		share
 ./usr/share/mk/bsd.sys.mk			base-mk-share		share

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:27 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan-m64/Makefile	Sun Sep  1 10:44:24 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:27 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:24 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -56,7 +56,7 @@ COPTS+=		-fPIC
 
 SYMS=		libclang_rt.asan-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:26 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/asan_cxx-m64/Makefile	Sun Sep  1 10:44:23 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:26 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:23 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -39,7 +39,7 @@ COPTS+=		-fPIC
 
 SYMS=	libclang_rt.asan_cxx-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:26 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan-m64/Makefile	Sun Sep  1 10:44:23 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:26 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:23 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -51,7 +51,7 @@ COPTS+=		-fPIC
 
 SYMS=		libclang_rt.msan-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:25 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/msan_cxx-m64/Makefile	Sun Sep  1 10:44:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:25 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:22 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -40,7 +40,7 @@ COPTS+=		-fPIC
 
 SYMS=		libclang_rt.msan_cxx-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:27 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan-m64/Makefile	Sun Sep  1 10:44:24 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:27 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:24 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -51,7 +51,7 @@ CPPFLAGS+=	-I${TOPDIR}/lib
 
 SYMS=		libclang_rt.tsan-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:27 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/tsan_cxx-m64/Makefile	Sun Sep  1 10:44:24 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:27 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:24 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -39,7 +39,7 @@ CPPFLAGS+=	-I${TOPDIR}/lib
 
 SYMS=		libclang_rt.tsan_cxx-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:25 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_minimal-m64/Makefile	Sun Sep  1 10:44:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:25 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:22 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -35,7 +35,7 @@ CPPFLAGS+=	-I${TOPDIR}/lib
 
 SYMS=		libclang_rt.ubsan_minimal-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:26 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone-m64/Makefile	Sun Sep  1 10:44:23 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:26 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:23 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -49,7 +49,7 @@ CPPFLAGS+=	-I${TOPDIR}/lib
 
 SYMS=		libclang_rt.ubsan_standalone-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile
diff -u src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile:1.1.2.3 src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile:1.1.2.4
--- src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile:1.1.2.3	Sun Sep  1 10:36:26 2019
+++ src/external/bsd/compiler_rt/lib/clang/lib/netbsd/ubsan_standalone_cxx-m64/Makefile	Sun Sep  1 10:44:23 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1.2.3 2019/09/01 10:36:26 martin Exp $
+#	$NetBSD: Makefile,v 1.1.2.4 2019/09/01 10:44:23 martin Exp $
 
 NOSANITIZER=    # defined
 
@@ -35,7 +35,7 @@ CPPFLAGS+=	-I${TOPDIR}/lib
 
 SYMS=		libclang_rt.ubsan_standalone_cxx-x86_64.a.syms
 
-realall: ${SYMS}
+beforeinstall: ${SYMS}
 
 CLEANFILES+=	${SYMS}
 FILES=		${SYMS}

Index: src/external/bsd/fetch/lib/Makefile
diff -u src/external/bsd/fetch/lib/Makefile:1.11 src/external/bsd/fetch/lib/Makefile:1.11.6.1
--- src/external/bsd/fetch/lib/Makefile:1.11	Sun Feb  4 03:19:52 2018
+++ src/external/bsd/fetch/lib/Makefile	Sun Sep  1 10:44:23 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 2018/02/04 03:19:52 christos Exp $
+# $NetBSD: Makefile,v 1.11.6.1 2019/09/01 10:44:23 martin Exp $
 
 LIB=		fetch
 SRCS=		fetch.c common.c ftp.c http.c file.c
@@ -32,4 +32,8 @@ httperr.h: ${LIBFETCHDIR}/http.errors ${
 	${HOST_SH} ${LIBFETCHDIR}/errlist.sh http_errlist HTTP \
 	    ${LIBFETCHDIR}/http.errors > ${.TARGET}
 
+.if ${MKSANITIZER:Uno} == "yes"
+CFLAGS+=	-Wno-macro-redefined # _REENTRANT redefined
+.endif
+
 .include <bsd.lib.mk>

Index: src/external/gpl2/lvm2/lvm2tools.mk
diff -u src/external/gpl2/lvm2/lvm2tools.mk:1.4 src/external/gpl2/lvm2/lvm2tools.mk:1.4.46.1
--- src/external/gpl2/lvm2/lvm2tools.mk:1.4	Fri Mar  4 22:48:29 2011
+++ src/external/gpl2/lvm2/lvm2tools.mk	Sun Sep  1 10:44:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: lvm2tools.mk,v 1.4 2011/03/04 22:48:29 matt Exp $
+#	$NetBSD: lvm2tools.mk,v 1.4.46.1 2019/09/01 10:44:22 martin Exp $
 
 .include <bsd.own.mk>
 
@@ -24,3 +24,7 @@ CPPFLAGS+=-DDM_DEVICE_UID=0 -DDM_DEVICE_
 #.endif
 #
 #LVM2.liblvm=	${LVM2OBJDIR.liblvm}/liblvm.a
+
+.if ${MKSANITIZER:Uno} == "yes"
+CFLAGS+=	-Wno-macro-redefined # _REENTRANT redefined in lib.h
+.endif

Index: src/lib/libc/gen/sysctlgetmibinfo.c
diff -u src/lib/libc/gen/sysctlgetmibinfo.c:1.13 src/lib/libc/gen/sysctlgetmibinfo.c:1.13.16.1
--- src/lib/libc/gen/sysctlgetmibinfo.c:1.13	Fri Sep 30 06:22:21 2016
+++ src/lib/libc/gen/sysctlgetmibinfo.c	Sun Sep  1 10:44:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctlgetmibinfo.c,v 1.13 2016/09/30 06:22:21 dholland Exp $ */
+/*	$NetBSD: sysctlgetmibinfo.c,v 1.13.16.1 2019/09/01 10:44:24 martin Exp $ */
 
 /*-
  * Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.13 2016/09/30 06:22:21 dholland Exp $");
+__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.13.16.1 2019/09/01 10:44:24 martin Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -386,16 +386,16 @@ __learn_tree(int *name, u_int namelen, s
  * the mib while parsing, and you should try again.  in the case of an
  * invalid node name, cname will be set to contain the offending name.
  */
-#ifdef _REENTRANT
+#if defined(_REENTRANT) && !defined(RUMP_ACTION)
 static mutex_t sysctl_mutex = MUTEX_INITIALIZER;
 static int sysctlgetmibinfo_unlocked(const char *, int *, u_int *, char *,
 				     size_t *, struct sysctlnode **, int);
-#endif /* __REENTRANT */
+#endif /* __REENTRANT && !RUMP_ACTION */
 
 int
 sysctlgetmibinfo(const char *gname, int *iname, u_int *namelenp,
 		 char *cname, size_t *csz, struct sysctlnode **rnode, int v)
-#ifdef _REENTRANT
+#if defined(_REENTRANT) && !defined(RUMP_ACTION)
 {
 	int rc;
 
@@ -411,7 +411,7 @@ static int
 sysctlgetmibinfo_unlocked(const char *gname, int *iname, u_int *namelenp,
 			  char *cname, size_t *csz, struct sysctlnode **rnode,
 			  int v)
-#endif /* _REENTRANT */
+#endif /* _REENTRANT && !RUMP_ACTION */
 {
 	struct sysctlnode *pnode, *node;
 	int name[CTL_MAXNAME], n, haven;

Index: src/share/mk/Makefile
diff -u src/share/mk/Makefile:1.50 src/share/mk/Makefile:1.50.4.1
--- src/share/mk/Makefile:1.50	Mon May 28 13:21:50 2018
+++ src/share/mk/Makefile	Sun Sep  1 10:44:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.50 2018/05/28 13:21:50 christos Exp $
+#	$NetBSD: Makefile,v 1.50.4.1 2019/09/01 10:44:22 martin Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/8/93
 
 NOOBJ=	# defined
@@ -12,7 +12,8 @@ FILES=	bsd.README bsd.buildinstall.mk bs
 	bsd.info.mk bsd.init.mk bsd.ioconf.mk bsd.kernobj.mk bsd.kinc.mk \
 	bsd.klinks.mk bsd.kmodule.mk bsd.lib.mk bsd.links.mk bsd.lua.mk \
 	bsd.man.mk bsd.nls.mk \
-	bsd.obj.mk bsd.own.mk bsd.prog.mk bsd.rpc.mk bsd.shlib.mk \
+	bsd.obj.mk bsd.own.mk bsd.prog.mk bsd.rpc.mk \
+	bsd.sanitizer.mk bsd.shlib.mk \
 	bsd.subdir.mk bsd.sys.mk bsd.syscall.mk bsd.test.mk bsd.x11.mk sys.mk
 
 FILESDIR=/usr/share/mk

Index: src/share/mk/bsd.lib.mk
diff -u src/share/mk/bsd.lib.mk:1.379 src/share/mk/bsd.lib.mk:1.379.2.1
--- src/share/mk/bsd.lib.mk:1.379	Mon Jan 21 21:11:54 2019
+++ src/share/mk/bsd.lib.mk	Sun Sep  1 10:44:22 2019
@@ -1,16 +1,10 @@
-#	$NetBSD: bsd.lib.mk,v 1.379 2019/01/21 21:11:54 christos Exp $
+#	$NetBSD: bsd.lib.mk,v 1.379.2.1 2019/09/01 10:44:22 martin Exp $
 #	@(#)bsd.lib.mk	8.3 (Berkeley) 4/22/94
 
 .include <bsd.init.mk>
 .include <bsd.shlib.mk>
 .include <bsd.gcc.mk>
-
-# Rename the local function definitions to not conflict with libc/rt/pthread/m.
-.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_SYMBOL)
-.	for _symbol in ${SANITIZER_RENAME_SYMBOL}
-CPPFLAGS+=	-D${_symbol}=__mksanitizer_${_symbol}
-.	endfor
-.endif
+.include <bsd.sanitizer.mk>
 
 # Pull in <bsd.sys.mk> here so we can override its .c.o rule
 .include <bsd.sys.mk>

Index: src/share/mk/bsd.prog.mk
diff -u src/share/mk/bsd.prog.mk:1.319.2.2 src/share/mk/bsd.prog.mk:1.319.2.3
--- src/share/mk/bsd.prog.mk:1.319.2.2	Mon Aug 19 15:53:40 2019
+++ src/share/mk/bsd.prog.mk	Sun Sep  1 10:44:22 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.prog.mk,v 1.319.2.2 2019/08/19 15:53:40 martin Exp $
+#	$NetBSD: bsd.prog.mk,v 1.319.2.3 2019/09/01 10:44:22 martin Exp $
 #	@(#)bsd.prog.mk	8.2 (Berkeley) 4/2/94
 
 .ifndef HOSTPROG
@@ -6,6 +6,7 @@
 .include <bsd.init.mk>
 .include <bsd.shlib.mk>
 .include <bsd.gcc.mk>
+.include <bsd.sanitizer.mk>
 
 ##### Sanitizer specific flags.
 
@@ -13,23 +14,6 @@ CFLAGS+=	${SANITIZERFLAGS} ${LIBCSANITIZ
 CXXFLAGS+=	${SANITIZERFLAGS} ${LIBCSANITIZERFLAGS}
 LDFLAGS+=	${SANITIZERFLAGS}
 
-# Rename the local function definitions to not conflict with libc/rt/pthread/m.
-.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_SYMBOL)
-.	for _symbol in ${SANITIZER_RENAME_SYMBOL}
-CPPFLAGS+=	-D${_symbol}=__mksanitizer_${_symbol}
-.	endfor
-.endif
-
-.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_CLASSES)
-.	for _class in ${SANITIZER_RENAME_CLASSES}
-.		for _file in ${SANITIZER_RENAME_FILES.${_class}}
-.			for _symbol in ${SANITIZER_RENAME_SYMBOL.${_class}}
-COPTS.${_file}+=	-D${_symbol}=__mksanitizer_${_symbol}
-.			endfor
-.		endfor
-.	endfor
-.endif
-
 #
 # Definitions and targets shared among all programs built by a single
 # Makefile.

Index: src/tests/lib/libc/net/Makefile
diff -u src/tests/lib/libc/net/Makefile:1.11 src/tests/lib/libc/net/Makefile:1.11.2.1
--- src/tests/lib/libc/net/Makefile:1.11	Mon Aug  6 04:50:11 2018
+++ src/tests/lib/libc/net/Makefile	Sun Sep  1 10:44:23 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 2018/08/06 04:50:11 msaitoh Exp $
+# $NetBSD: Makefile,v 1.11.2.1 2019/09/01 10:44:23 martin Exp $
 
 .include <bsd.own.mk>
 
@@ -41,4 +41,8 @@ LDADD.h_nsd_recurse+=	-lpthread
 
 CLEANFILES+=	aton_ether_subr.c
 
+.if ${MKSANITIZER:Uno} == "yes"
+COPTS.h_nsd_recurse.c+=	-Wno-macro-redefined # _REENTRANT redefined
+.endif
+
 .include <bsd.test.mk>

Added files:

Index: src/share/mk/bsd.sanitizer.mk
diff -u /dev/null src/share/mk/bsd.sanitizer.mk:1.1.2.2
--- /dev/null	Sun Sep  1 10:44:24 2019
+++ src/share/mk/bsd.sanitizer.mk	Sun Sep  1 10:44:22 2019
@@ -0,0 +1,27 @@
+#	$NetBSD: bsd.sanitizer.mk,v 1.1.2.2 2019/09/01 10:44:22 martin Exp $
+
+.if !defined(_BSD_SANITIZER_MK_)
+_BSD_SANITIZER_MK_=1
+
+.if ${MKSANITIZER:Uno} == "yes"
+CPPFLAGS+=	-D_REENTRANT
+.endif
+
+# Rename the local function definitions to not conflict with libc/rt/pthread/m.
+.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_SYMBOL)
+.	for _symbol in ${SANITIZER_RENAME_SYMBOL}
+CPPFLAGS+=	-D${_symbol}=__mksanitizer_${_symbol}
+.	endfor
+.endif
+
+.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_CLASSES)
+.	for _class in ${SANITIZER_RENAME_CLASSES}
+.		for _file in ${SANITIZER_RENAME_FILES.${_class}}
+.			for _symbol in ${SANITIZER_RENAME_SYMBOL.${_class}}
+COPTS.${_file}+=	-D${_symbol}=__mksanitizer_${_symbol}
+.			endfor
+.		endfor
+.	endfor
+.endif
+
+.endif  # !defined(_BSD_SANITIZER_MK_)

Reply via email to