-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
stdenv/adapters.nix: add isStatic when static stdenv adapter is used #97047
Conversation
My intent would just be to fix it so it does. I still fail to see why we need to architect this differently than we do with all the other variations. Also isn't |
That's true on Linux, but on macOS you can reuse the same compiler / linker / libc for partially static compilation. Ideally we could reuse the native toolchain for static compilation on Linux, but Glibc doesn't support full static linking. If Static compilation really is different from cross compilation, since native static compilation is a perfectly reasonable thing to do. We do end up reusing some infrastructure here, like Perhaps we should add a "not fully static" Glibc package set to make this more clear. So |
Generally the meaning of I converted some |
@matthewbauer but if we reused GCC by building libraries separately like we do with LLVM, we would reduce the GCC even with |
@matthewbauer I had to repeat the nix derivation in for static builds in https://github.com/NixOS/nix/blob/92438c70d2291a02577e02b9462f53c23817aebd/flake.nix#L442-L477 because the overlay would try to override the new nix derivation I was putting in. I take this as evidence that having an overlay is the wrong approach. Note that switching |
please avoid merges, rebase instead. |
7b821f6
to
aa8e35b
Compare
@Ericson2314 Can you take a look at this again? I've updated the description with a more clear reason of why it's needed. Importantly, stdenv.hostPlatform.isStatic is false on pkgsStatic in darwin (https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/stage.nix#L214-L232). This means that static is broken after the stdenv.hostPlatform.isStatic refactors. This should fix the regression with the least amount of pain. |
I still don't like putting it in |
aa8e35b
to
cd8e48f
Compare
This results in:
because of nixpkgs/pkgs/top-level/all-packages.nix Line 9672 in 5452d8d
|
@matthewbauer What if we made |
useLLVM doesn't have any effect because we already have https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/cross/default.nix#L66-L67. The thing that pulls in xcode is a usage of binutils in bash at nixpkgs/pkgs/shells/bash/4.4.nix Line 82 in 652b2d6
|
This corrects an issue from NixOS#96223, where darwin/macOS static compilation is broken. The issue is that stdenv.hostPlatform.isStatic is only set on Linux: https://github.com/NixOS/nixpkgs/blob/916815204eac9e4a41f263dd9855e51380135674/pkgs/top-level/stage.nix#L221 and not macOS or other platforms. This means that we can’t static compile on platforms platforms that can’t cross-compile to themselves. To fix this, move isStatic from stdenv.hostPlatform to stdenv. This avoids the need to have stdenv.hostPlatform != stdenv.buildPlatform.
Darwin breaks when you pass in -static. Note, this shouldn’t be set on non-static executable situations, but we don’t have an isStaticExecutables yet.
bc18ed3
to
d67375d
Compare
Any objections to merging this & then trying to solve the stdenv.hostPlatform != stdenv.buildPlatform issue later? |
Ehh we still have the precedent of --- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -8673,7 +8673,7 @@ in
}));
crossLibcStdenv = overrideCC stdenv
- (if stdenv.hostPlatform.useLLVM or false
+ (if with stdenv.hostPlatform; isDarwin || useLLVM or false
then buildPackages.llvmPackages_8.lldClangNoLibc
else buildPackages.gccCrossStageStatic);
( |
Started in #110914. |
I marked this as stale due to inactivity. → More info |
42b5817 added isStatic to darwin too. |
This corrects an issue from
#96223, where darwin/macOS static
compilation is broken. The issue is that stdenv.hostPlatform.isStatic
is only set on Linux:
nixpkgs/pkgs/top-level/stage.nix
Line 221 in 9168152
and not macOS or other platforms. This means that we can’t static
compile on platforms platforms that can’t cross-compile to themselves.
To fix this, move isStatic from stdenv.hostPlatform to stdenv. This
avoids the need to have stdenv.hostPlatform != stdenv.buildPlatform.
We still can have something similar to isStatic in
stdenv.hostPlatform, but instead of being a configurable value, it is
now called ‘hasDynamicLoader’. This should be true for everything but
a few specific platforms we support.
This also makes some weird cases less confusing. For instance,
import nixpkgs { crossSystem = { system = builtins.currentSystem; isStatic = true; }
would be expected to provide static stdenv, but it actually doesn't./cc @vcunat @Ericson2314 @KAction