zig: disable libcxx hardening flags#463199
Open
DDoSolitary wants to merge 1 commit intoNixOS:masterfrom
Open
Conversation
Member
I get this when building with your PR for |
Contributor
Author
|
@RossComputerGuy The error is irrelevant to this PR. It occurs on current nixpkgs master without this PR, and is caused by incompatibility between Zig and CMake: ziglang/zig-bootstrap#206 You can work around it as shown in my repro command: |
RossComputerGuy
requested changes
Nov 19, 2025
The libcxxhardeningfast and libcxxhardeingextensive hardening flags introduced by NixOS#442945 add _LIBCPP_HARDENING_MODE definitions to compiler invocations, but zig already sets it automatically. This causes macro re-definition warnings (or errors if -Werror is enabled) when compiling C++ projects with zigStdenv.
52e6428 to
a55e7e1
Compare
GabrielDougherty
approved these changes
Dec 7, 2025
Member
GabrielDougherty
left a comment
There was a problem hiding this comment.
nixpkgs-review result
Generated using nixpkgs-review.
Command: nixpkgs-review pr 463199
Commit: a55e7e1073f0275e5e6b7b58cc28a696790ccc9d
aarch64-darwin
✅ 2 packages built:
- nixpkgs-manual
- zigStdenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The libcxxhardeningfast and libcxxhardeingextensive hardening flags introduced by #442945 add _LIBCPP_HARDENING_MODE definitions to compiler invocations, but zig already sets it automatically. This causes macro redefinition warnings (or errors if -Werror is enabled) when compiling C++ projects with zigStdenv.
https://github.com/ziglang/zig/blob/4ea472808437c932f6240c0df5e4d5912d282052/src/libs/libcxx.zig#L542-L544
Repro:
nix build -L --impure --expr 'with builtins.getFlake "git+file:///home/ddosolitary/nixpkgs"; with legacyPackages.x86_64-linux; (hello-cpp.override { stdenv = zigStdenv; }).overrideAttrs { cmakeFlags = [ "-DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=OFF" ]; env.CXXFLAGS = "-Werror"; }'Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.