Skip to content
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

Build failure: pkgsCross.mingwW64.pkgsStatic.stdenv #281596

Open
yshui opened this issue Jan 17, 2024 · 4 comments · May be fixed by #303849
Open

Build failure: pkgsCross.mingwW64.pkgsStatic.stdenv #281596

yshui opened this issue Jan 17, 2024 · 4 comments · May be fixed by #303849
Labels
0.kind: build failure 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: static

Comments

@yshui
Copy link
Contributor

yshui commented Jan 17, 2024

Steps To Reproduce

Steps to reproduce the behavior:

  1. build pkgsCross.mingwW64.pkgsStatic.stdenv

Build log

error: builder for '/nix/store/v1ycfkiivjszsl8qagsw2v86r81amwxs-mingw-w64-static-x86_64-w64-windows-gnu-10.0.0-headers.drv' failed with exit code 1;
       last 10 log lines:
       > checking for x86_64-w64-windows-gnu-strip... no
       > checking for strip... no
       > checking for a race-free mkdir -p... /nix/store/khndnv11g1rmzhzymm1s5dw7l2ld45bc-coreutils-9.4/bin/mkdir -p
       > checking for gawk... gawk
       > checking whether make sets $(MAKE)... yes
       > checking whether make supports nested variables... yes
       > checking whether to enable maintainer-specific portions of Makefiles... no
       > checking build system type... x86_64-unknown-linux-gnu
       > checking host system type... Invalid configuration 'x86_64-w64-windows-gnu': Kernel 'windows' not known to work with OS 'gnu'.
       > configure: error: /nix/store/9vafkkic27k7m4934fpawl6yip3a6k4h-bash-5.2-p21/bin/bash ./build-aux/config.sub x86_64-w64-windows-gnu failed

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.10-zen1, NixOS, 24.05 (Uakari), 24.05.20240115.c3e128f`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"nixos"`
 - channels(user): `"nixgl, nixpkgs"`
 - nixpkgs: `/nix/store/11zbgb8j7wnnccbbjcq0q556h28g7p4r-source`

Add a 👍 reaction to issues you find important.

@yshui
Copy link
Contributor Author

yshui commented Jan 17, 2024

pkgsCross.mingwW64.pkgsStatic.stdenv.targetPlatform.config is "x86_64-w64-windows-gnu" for some reason, unlike pkgsCross.mingwW64.stdenv.targetPlatform.config which is "x86_64-w64-mingw32" as expected.

@wegank
Copy link
Member

wegank commented Jan 18, 2024

pkgsStatic = nixpkgsFun ({
overlays = [ (self': super': {
pkgsStatic = super';
})] ++ overlays;
crossSystem = {
isStatic = true;
parsed =
if stdenv.isLinux
then makeMuslParsedPlatform stdenv.hostPlatform.parsed
else stdenv.hostPlatform.parsed;
} // lib.optionalAttrs (stdenv.hostPlatform.system == "powerpc64-linux") {
gcc.abi = "elfv2";
};
});

The Windows case doesn't seem to be covered here, since for MinGW-w64, config doesn't use the result from lib.systems.parse.tripleFromSystem pkgsCross.mingwW64.stdenv.hostPlatform.parsed, which is "x86_64-w64-windows-gnu". Instead, we have

# 64 bit mingw-w64
mingwW64 = {
# That's the triplet they use in the mingw-w64 docs.
config = "x86_64-w64-mingw32";
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
};

So I guess stdenv.hostPlatform.{config,libc} should be passed to crossSystem conditionally.

@wolfgangwalther wolfgangwalther linked a pull request Apr 13, 2024 that will close this issue
13 tasks
@Frontear
Copy link
Member

Bump, this issue is quite unfortunate when attempting to build static apps through nix.

wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this issue Sep 25, 2024
This makes combinations work, where pkgsStatic is used on another
package set, for example:

- Keeps pkgsCross.mingwW64.pkgsStatic.stdenv.hostPlatform.config at
"x86_64-w64-mingw32"
- Keeps pkgsLLVM.pkgsStatic.stdenv.hostPlatform.useLLVM at "true"

Makes pkgsCross.mingwW64.pkgsStatic.stdenv build. Not sure whether it
actually builds static executables already, though.

Resolves NixOS#281596
@aforemny
Copy link
Contributor

aforemny commented Oct 14, 2024

I was able to build a static windows (mingwW64) executable with 34cefd7. I think this closes the issue? Thanks @wolfgangwalther! ❤️

edit: It seems #303849 is not merged yet. So I'm just leaving this information here.

@FliegendeWurst FliegendeWurst added 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: static labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: static
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants