mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
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.
This commit is contained in:
parent
ba9b6b29b7
commit
2625e9fb0a
2 changed files with 4 additions and 2 deletions
|
@ -9,6 +9,10 @@
|
||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#error "Nix may not be built with assertions disabled (i.e. with -DNDEBUG)."
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
void initLibUtil() {
|
void initLibUtil() {
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
TEST(OutputsSpec, no_empty_names) {
|
TEST(OutputsSpec, no_empty_names) {
|
||||||
ASSERT_DEATH(OutputsSpec::Names { std::set<std::string> { } }, "");
|
ASSERT_DEATH(OutputsSpec::Names { std::set<std::string> { } }, "");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TEST_DONT_PARSE(NAME, STR) \
|
#define TEST_DONT_PARSE(NAME, STR) \
|
||||||
TEST(OutputsSpec, bad_ ## NAME) { \
|
TEST(OutputsSpec, bad_ ## NAME) { \
|
||||||
|
|
Loading…
Reference in a new issue