pkgsStatic: Pass hostPlatform.gcc attribute#283460
Conversation
pkgs/top-level/stage.nix
Outdated
There was a problem hiding this comment.
This will not merge correctly on ppc. Also, maybe we should inherit all the values of the platform, and only change isStatic and parsed?
There was a problem hiding this comment.
This will not merge correctly on ppc
Ups, I'll move the // to the gcc attribute instead.
maybe we should inherit all the values of the platform
I don't know the consecuences of that, so I only wanted to do the minimal changes that fix the current problem. I assume for other pkgs* sets some similar fix should be done.
c379a0d to
57e7c8f
Compare
57e7c8f to
02002b1
Compare
|
Can we merge this? NixOS continues to be broken when cross-compiling with specific Otherwise, can you provide workaround so we can switch to upstream nixpkgs? AFAIK, I cannot patch nixpkgs when using it as an input flake, so I cannot take that route either. |
To build the security wrappers[1] the pkgsStatic stdenv is used, so the binaries are static. However, the hostPlatform may have gcc attributes that are *required* to build binaries so they can run on the host platform. In particular, this is the case when using gcc.arch, which ends up injecting -march=... in the gcc wrapper. Those attributes are not contained in hostPlatform.parsed. This change sets the same gcc attributes found in the hostPlatform for the pkgsStatic cross system, so it can build binaries with the same gcc flags. [1]: nixos/modules/security/wrappers/default.nix
02002b1 to
e4ee77f
Compare
To build the security wrappers1 the pkgsStatic stdenv is used, so the binaries are static. However, the hostPlatform may have gcc attributes that are required to build binaries so they can run on the host platform. In particular, this is the case when using gcc.arch, which ends up injecting -march=... in the gcc wrapper. Those attributes are not contained in hostPlatform.parsed.
This change sets the same gcc attributes found in the hostPlatform for the pkgsStatic cross system, so it can build binaries with the same gcc flags.
This problem has ocurred to me while cross compiling a RISC-V NixOS system from an x86 machine to run in QEMU with the compressed instructions disabled (using
-cpu rv64,c=false). What happens when the -march flags are not propagated to the gcc wrapper is that the binaries end up being compiled with compressed instructions which cause a SIGILL like the following:Description of changes
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/)mountandsudowhich run okay now.Add a 👍 reaction to pull requests you find important.