-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkgsStatic: Pass hostPlatform.gcc attribute #283460
Conversation
pkgs/top-level/stage.nix
Outdated
@@ -272,6 +272,7 @@ let | |||
if stdenv.isLinux | |||
then makeMuslParsedPlatform stdenv.hostPlatform.parsed | |||
else stdenv.hostPlatform.parsed; | |||
gcc = lib.optionalAttrs (stdenv.hostPlatform ? gcc) stdenv.hostPlatform.gcc; | |||
} // lib.optionalAttrs (stdenv.hostPlatform.system == "powerpc64-linux") { | |||
gcc.abi = "elfv2"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
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 = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)mount
andsudo
which run okay now.Add a 👍 reaction to pull requests you find important.