Skip to content

Cross compiling for mingw doesn't find gcc DLLs #38451

@expipiplus1

Description

@expipiplus1

Issue description

Cross compiling for mingw doesn't find gcc DLLs

Steps to reproduce

Check out nixpkgs 0e7c9b3

Build this derivation:

(import <nixpkgs> {
  crossSystem = {
    config = "x86_64-pc-mingw32";
    libc = "msvcrt";
  };
}).hello

Observe that no DLL links are created.

post-installation fixup
DLLPATH='/nix/store/ifb3aj50q60c2scnh8f882a8r961zn26-hello-2.10-x86_64-pc-mingw32/bin:/nix/store/y5rlyv6nz8134s687d95ysc2gakwx7am-patchelf-0.9/bin:/nix/store/rf7pnq8qk9bkjpl4s2pm5dm2pk4yqhrc-paxctl-0.9/bin:/nix/store/00yzxnmmn02hfcz5zgmlij3wrnn0c92y-x86_64-pc-mingw32-gcc-cross-wrapper-7.3.0-x86_64-pc-mingw32-stage-final/bin:/nix/store/iwhhg7qpvlsgznn8ywyd0g9698sl385l-gcc-7.3.0-x86_64-pc-mingw32-stage-final/bin:/nix/store/cb3slv3szhp46xkrczqw7mscy5mnk64l-coreutils-8.29/bin:/nix/store/6bfyi9qdigj0mvprancyvg5y4l3rcm6s-x86_64-pc-mingw32-x86_64-pc-mingw32-binutils-wrapper-2.28.1/bin:/nix/store/jyl00pcg40mzfvrk29dzzc4z8mgi4mkh-x86_64-pc-mingw32-binutils-2.28.1/bin:/nix/store/cb3slv3szhp46xkrczqw7mscy5mnk64l-coreutils-8.29/bin:/nix/store/cb3slv3szhp46xkrczqw7mscy5mnk64l-coreutils-8.29/bin:/nix/store/364b5gkvgrm87bh1scxm5h8shp975n0r-findutils-4.6.0/bin:/nix/store/cg3yhpr5hfr00y0aah23pgxiijpzl6nz-diffutils-3.6/bin:/nix/store/navldm477k3ar6cy0zlw9rk43i459g69-gnused-4.4/bin:/nix/store/s63b2myh6rxfl4aqwi9yxd6rq66djk33-gnugrep-3.1/bin:/nix/store/j79xs2j519bmvq0gihz8ff4nw5aj3vlh-gawk-4.2.0/bin:/nix/store/2p00w952ljb1172nsf3jm7nsjgsw5qpw-gnutar-1.30/bin:/nix/store/d7895h1an2pgcd6a3vx3yb5fbg786lci-gzip-1.9/bin:/nix/store/qqv6r9vkpb44rw5d8wyfpx64rgqzlvdm-bzip2-1.0.6.0.1-bin/bin:/nix/store/lhp5rw0dagi5mgqwr9i3x41240ba4ypz-gnumake-4.2.1/bin:/nix/store/zqh3l3lyw32q1ayb15bnvg9f24j5v2p0-bash-4.4-p12/bin:/nix/store/gd1mp76qr4zpbw3lccivhvi30b025x51-patch-2.7.6/bin:/nix/store/aakgkcvw6j54zg38zrn1w00sgxx0zj8b-xz-5.2.3-bin/bin'
Created 0 DLL link(s) in /nix/store/ifb3aj50q60c2scnh8f882a8r961zn26-hello-2.10-x86_64-pc-mingw32/bin

Observe that the generated hello.exe doesn't run on windows as libssp-0.dll is missing.

libssp-0.dll is present in the x86_64-pc-mingw32/lib/ directory of gcc-7.3.0-x86_64-pc-mingw32-stage-final, however only the bin directories are searched (see pkgs/build-support/setup-hooks/win-dll-link.sh``:19)

This could be fixed by either changing win-dll-link to search in these directories, or by linking these DLLs into the bin/ directory of the cross compiler.

Annoyingly this will cause the closure of any cross compiled derivations to include GCC. Splitting the cross compiler and its libraries into separate derivations may solve this (I think this happens for native packages)

CC @Ericson2314

Metadata

Metadata

Assignees

Labels

2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: cross-compilationBuilding packages on a different platform than they will be used on6.topic: windowsRunning, or buiding, packages on Windows

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions