aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-08-02 08:48:21 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-08-02 13:33:24 +0000
commit7bc797e3f3807660cf98e5b1bd63545cafe820f8 (patch)
treea18a5a861b88b98e04104d5a563dbb4c4807e77a /lib
parent5f6c8ce2452da2da233e37bf4c2b6fccde8594b1 (diff)
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile2
-rw-r--r--lib/csu/Makefile.inc3
-rw-r--r--lib/libclang_rt/Makefile.inc2
-rw-r--r--lib/libgcc_eh/Makefile.inc8
-rw-r--r--lib/libgcc_s/Makefile3
5 files changed, 18 insertions, 0 deletions
diff --git a/lib/Makefile b/lib/Makefile
index a06e77dee022..674368a19ffd 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -180,6 +180,8 @@ SUBDIR.${MK_STATS}+= libstats
${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386" || \
${MACHINE_CPUARCH} == "powerpc")
_libclang_rt= libclang_rt
+.elif ${MK_ASAN} != "no" || ${MK_UBSAN} != "no"
+.error "Requested build with sanitizers but cannot build runtime libraries!"
.endif
.if ${MK_CXX} != "no"
diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc
index 5681ef65117a..b089e1a947b1 100644
--- a/lib/csu/Makefile.inc
+++ b/lib/csu/Makefile.inc
@@ -3,6 +3,9 @@
SSP_CFLAGS=
NO_WMISSING_VARIABLE_DECLARATIONS=
+# Can't instrument these files since that breaks non-sanitized programs.
+MK_ASAN:= no
+MK_UBSAN:= no
.include <src.opts.mk>
diff --git a/lib/libclang_rt/Makefile.inc b/lib/libclang_rt/Makefile.inc
index 946d3f4c77a7..19b8868b60e3 100644
--- a/lib/libclang_rt/Makefile.inc
+++ b/lib/libclang_rt/Makefile.inc
@@ -12,6 +12,8 @@ SHLIBDIR= ${LIBDIR}
NO_PIC=
MK_PROFILE= no
+MK_ASAN:= no
+MK_UBSAN:= no
WARNS?= 0
diff --git a/lib/libgcc_eh/Makefile.inc b/lib/libgcc_eh/Makefile.inc
index 4fe1eff406e1..9e386992e78c 100644
--- a/lib/libgcc_eh/Makefile.inc
+++ b/lib/libgcc_eh/Makefile.inc
@@ -20,9 +20,17 @@ SRCS_EXC+= libunwind.cpp
SRCS+= ${SRCS_EXC}
.for file in ${SRCS_EXC:M*.c}
CFLAGS.${file}+= -fno-exceptions -funwind-tables
+.if ${MK_ASAN} != "no"
+# False-positives during stack unwinding
+CFLAGS.${file}+= -fno-sanitize=address
+.endif
.endfor
.for file in ${SRCS_EXC:M*.cpp}
CXXFLAGS.${file}+= -fno-exceptions -funwind-tables
+.if ${MK_ASAN} != "no"
+# False-positives during stack unwinding
+CXXFLAGS.${file}+= -fno-sanitize=address
+.endif
.endfor
CFLAGS+= -I${UNWINDINCDIR}
diff --git a/lib/libgcc_s/Makefile b/lib/libgcc_s/Makefile
index 84477ee00818..aa097d7255de 100644
--- a/lib/libgcc_s/Makefile
+++ b/lib/libgcc_s/Makefile
@@ -4,6 +4,9 @@ PACKAGE= clibs
SHLIB_NAME= libgcc_s.so.1
SHLIBDIR?= /lib
+# Enabling UBSan triggers "undefined reference to vtable for __cxxabiv1::__function_type_info"
+MK_UBSAN:= no
+
.include <bsd.opts.mk>
MK_SSP= no