From 147d7b567f03f7e327b9bd2fa5bec6077022aeeb Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 6 Apr 2020 01:27:17 +0000 Subject: [PATCH] llvm: add a build knob for enabling assertions For head/, this will remain eternally default-on to maintain the status quo. For stable/ branches, it should be flipped to default-off to maintain the status quo. There's value in being able to flip it one way or the other easily on head or stable branches, whether you want to gain some performance back on head/ (for machines there's little chance you'll actually hit an assertion) or potentially diagnose a problem with the version of llvm on an older branch. Currently, stable branches get the CFLAGS+= -ndebug line uncommented; going forward, they will instead have the default of LLVM_ASSERTIONS flipped. Reviewed by: dim, emaste, re (gjb) MFC after: 1 week MFC note: flip the default of LLVM_ASSERTIONS Differential Revision: https://reviews.freebsd.org/D24264 --- lib/clang/llvm.build.mk | 4 +++- share/mk/src.opts.mk | 1 + tools/build/options/WITHOUT_LLVM_ASSERTIONS | 2 ++ tools/build/options/WITH_LLVM_ASSERTIONS | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tools/build/options/WITHOUT_LLVM_ASSERTIONS create mode 100644 tools/build/options/WITH_LLVM_ASSERTIONS diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk index 239c74ceedf..f0e8081e8fc 100644 --- a/lib/clang/llvm.build.mk +++ b/lib/clang/llvm.build.mk @@ -22,7 +22,9 @@ CFLAGS+= -D__STDC_CONSTANT_MACROS CFLAGS+= -D__STDC_FORMAT_MACROS CFLAGS+= -D__STDC_LIMIT_MACROS CFLAGS+= -DHAVE_VCS_VERSION_INC -#CFLAGS+= -DNDEBUG +.if ${MK_LLVM_ASSERTIONS} == "no" +CFLAGS+= -DNDEBUG +.endif TARGET_ARCH?= ${MACHINE_ARCH} BUILD_ARCH?= ${MACHINE_ARCH} diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 08cc821df0e..0e569287547 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -132,6 +132,7 @@ __DEFAULT_YES_OPTIONS = \ LLD \ LLD_BOOTSTRAP \ LLD_IS_LD \ + LLVM_ASSERTIONS \ LLVM_COV \ LLVM_TARGET_ALL \ LOADER_GELI \ diff --git a/tools/build/options/WITHOUT_LLVM_ASSERTIONS b/tools/build/options/WITHOUT_LLVM_ASSERTIONS new file mode 100644 index 00000000000..73d39e55322 --- /dev/null +++ b/tools/build/options/WITHOUT_LLVM_ASSERTIONS @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to disable debugging assertions in LLVM. diff --git a/tools/build/options/WITH_LLVM_ASSERTIONS b/tools/build/options/WITH_LLVM_ASSERTIONS new file mode 100644 index 00000000000..32cf014b583 --- /dev/null +++ b/tools/build/options/WITH_LLVM_ASSERTIONS @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to enable debugging assertions in LLVM.