From f6142cd0d1b248581adddbbc1056df00fe12eb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Wed, 28 Feb 2024 08:02:49 +0100 Subject: [PATCH] unset `NIX_HARDENING_ENABLE` in fast build mode `NIX_HARDENING_ENABLE` causes `_FORTIFY_SOURCE` to be defined. This isn't compatible with `-O0`, and the compiler will happily remind us about it at every call, spamming the terminal with warnings and stack traces. We don't really care hardening in that case, so just disable it if we pass `OPTIMIZE=0`. --- Makefile | 1 + flake.nix | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 745e60aa5..c3dc83c77 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,7 @@ ifeq ($(OPTIMIZE), 1) GLOBAL_LDFLAGS += $(CXXLTO) else GLOBAL_CXXFLAGS += -O0 -U_FORTIFY_SOURCE + unexport NIX_HARDENING_ENABLE endif include mk/platform.mk diff --git a/flake.nix b/flake.nix index 58d17bf00..42aaace67 100644 --- a/flake.nix +++ b/flake.nix @@ -396,6 +396,7 @@ # Make bash completion work. XDG_DATA_DIRS+=:$out/share ''; + nativeBuildInputs = attrs.nativeBuildInputs or [] # TODO: Remove the darwin check once # https://github.com/NixOS/nixpkgs/pull/291814 is available