stdenv: disable hardening for embedded (kernel=none) targets#378825
stdenv: disable hardening for embedded (kernel=none) targets#378825midnightveil wants to merge 2 commits intoNixOS:masterfrom
Conversation
|
@midnightveil Thank you! I do this all the time for embedded targets, this is a net positive in usability of Nix for niche target environments |
Yep, I know :)
|
A very partial fix for [NixOS#18995]. This should make the relatively common case of embedded targets Just Work™, since these systems rarely are setup in the standard way. I've often seen __stack__chk failures when building for embedded systems, enabling this should make these architectures usable without needing to do crimes in nix shells / build environments. [NixOS#18995]: NixOS#18995
213bdce to
b3929bb
Compare
A very partial fix for [NixOS#18995]. This should make the relatively common case of embedded targets Just Work™, since these systems rarely are setup in the standard way, and don't like having stack protectors. This should make these architectures usable as a cross-compiler without needing crimes in build environments or nix shells. [NixOS#18995]: NixOS#18995
b3929bb to
68c3282
Compare
|
OK, so, closing this, because of nixpkgs/pkgs/build-support/cc-wrapper/default.nix Lines 682 to 683 in bc411b4 We already disable the hardening flags if we're compiling for nixpkgs/lib/systems/default.nix Line 112 in a097cc5 This is probably why there were only 44 changes (mostly in some uboot compiles), and the second commit didn't add any more. This is also the case if you specify a target triple instead of using the recommended Though (as, I was probably confused in the past), What this didn't solve, is nix-shell:~/code/github/nixpkgs]$ NIX_DEBUG=1 clang -target riscv64-none-elf
HARDENING: disabled flags: pacret pie stackclashprotection fortify3 shadowstack trivialautovarinit
HARDENING: Is active (not completely disabled with "all" flag)
HARDENING: enabling pic
HARDENING: enabling format
HARDENING: enabling zerocallusedregs
HARDENING: enabling stackprotector
HARDENING: enabling fortify
HARDENING: enabling strictoverflow
extra flags before to /nix/store/f74fi945gdb4yg8vcj0xlhn9ckrdcwmi-clang-18.1.8/bin/clang:Compare with e.g., [nix-shell:~/code/github/nixpkgs]$ NIX_DEBUG=1 riscv64-none-elf-gcc
HARDENING: disabled flags: pacret pie pic stackclashprotection fortify3 shadowstack format zerocallusedregs stackprotector fortify strictoverflow trivialautovarinitNow, what's (somewhat) hilarious, is that we can actually get this intended behaviour, by requesting So in essence, a fix for the "hardening issue" (not the random extra compile arguments that point the compilers at random sysroots for gcc even if its clang, etc), is to fix clang so that these are applied dynamically based on the Looks like Wanja's lovely "just merge the directories from unwrapped clang into clang" is probably still the way to go for clang compilers, but for the gcc ones we shouldn't need |
A very partial fix for #18995. This should make the relatively common case of embedded targets Just Work™, since these systems rarely are setup in the standard way.
I've often seen __stack__chk failures when building for embedded systems, enabling this should make these architectures usable without needing to do crimes in nix shells / build environments.
DRAFT, because I need to make sure this works as expected, i.e. I can build things without adding
hardeningDisableto nix-shells for embedded work.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.
cc @wucke13 since this might be of shared interest