aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 09:03:49 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 09:24:58 +0100
commit96a36833084f66b79ba778e719862b8219557773 (patch)
tree14e66e570e656c1ea988c805524c81e37dcbfc46 /src
parentc6064390e86b11dbec23af7525a2fa9a70666f23 (diff)
Ban building Nix with NDEBUG
When reviewing old PRs, I found that #9997 adds some code to ensure one particular assert is always present. But, removing asserts isn't something we do in our own release builds either in the flake here or in nixpkgs, and is plainly a bad idea that increases support burden, especially if other distros make bad choices of build flags in their Nix packaging. For context, the assert macro in the C standard is defined to do nothing if NDEBUG is set. There is no way in our build system to set -DNDEBUG without manually adding it to CFLAGS, so this is simply a configuration we do not use. Let's ban it at compile time. I put this preprocessor directive in src/libutil.cc because it is not obvious where else to put it, and it seems like the most logical file since you are not getting a usable nix without it. Upstream-PR: https://github.com/NixOS/nix/pull/10126 Original-Change-Id: I513cceaac1371decb3d96231e6ef9181c910c218 Change-Id: I531a51f6348a746e8e41d88203b08f614898356c
Diffstat (limited to 'src')
-rw-r--r--src/libutil/util.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 3b4c181e5..baff6624c 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -45,6 +45,10 @@
extern char * * environ __attribute__((weak));
+#ifdef NDEBUG
+#error "Nix may not be built with assertions disabled (i.e. with -DNDEBUG)."
+#endif
+
namespace nix {
void initLibUtil() {