!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

581 Members
129 Servers

Load older messages


SenderMessageTime
10 Jun 2026
@eureka-cpu:matrix.orgeureka-cpu *

is there a guide for how to cross compile to windows? I have some rust code I'm trying to cross compile from x86_64-linux to mingw-ucrt-x86_64-llvm, but hit a snag on needing pthreads. I added it but then I get the supported platform error since it doesn't include any platforms. What's the intended way of using it? Forgive my sloppy code, but here's what I currently have:

          test-cargo-reaper-build-cross-windows =
            let
              inherit (pkgs.lib.systems.examples.mingw-ucrt-x86_64-llvm.rust) rustcTarget;
              crossPkgs = pkgs.pkgsCross.mingw-ucrt-x86_64-llvm;
              mingwCC = crossPkgs.stdenv.cc;
              crossCC = "${mingwCC}/bin/${mingwCC.targetPrefix}cc";
              crossCXX = "${mingwCC}/bin/${mingwCC.targetPrefix}c++";

              rustWithWindowsTarget = fenix.packages.${system}.combine [
                rustToolchain
                (fenix.packages.${system}.targets.${rustcTarget}.toolchainOf {
                  channel = "1.87.0";
                  sha256 = "sha256-KUm16pHj+cRedf8vxs/Hd2YWxpOrWZ7UOrwhILdSJBU=";
                }).rust-std
              ];
              craneLibCross =
                let
                  craneLib = (crane.mkLib pkgs).overrideToolchain rustWithWindowsTarget;
                in
                craneLib // (cargoReaper.crane { inherit craneLib; });

              crossArgs = {
                src = testFileset ./tests/plugin_manifests/package_manifest;
                strictDeps = true;

                nativeBuildInputs = [
                  mingwCC
                  pkgs.llvmPackages.bintools
                  pkgs.windows.pthreads
                ];

                CARGO_BUILD_TARGET = rustcTarget;
                CARGO_TARGET_X86_64_PC_WINDOWS_GNULLVM_LINKER =
                  "${mingwCC}/bin/${mingwCC.targetPrefix}cc";
                "CC_${rustcTarget}" = crossCC;
                "CXX_${rustcTarget}" = crossCXX;
              };
              cargoArtifactsCross = craneLibCross.buildDepsOnly crossArgs;
            in
            craneLibCross.buildReaperExtension (crossArgs // {
              cargoArtifacts = cargoArtifactsCross;
              package = "package_manifest";
              plugin = "reaper_package_ext";
              target = rustcTarget;
              doInstallCheck = true;
              installCheckPhase = ''
                test -f $out/lib/reaper_package_ext.dll
              '';
            });
18:49:17
@eureka-cpu:matrix.orgeureka-cpu

Ah so the pthreads problem was with libc, it hasn't even gotten to my build yet:

Cannot build '/nix/store/2qixrw546lxpxqkwyglhzhhnf2m7kv2b-compiler-rt-libc-x86_64-w64-mingw32-21.1.8.drv'
19:58:03
@eureka-cpu:matrix.orgeureka-cpuIs mingw just broken atm?19:58:57
@eureka-cpu:matrix.orgeureka-cpu * Is mingw-ucrt-x86_64-llvm just broken atm? 19:59:55
@symphorien:xlumurb.eusymphoriencross compiling is best effort as a general rule20:20:13
@symphorien:xlumurb.eusymphorienmeaning that if nobody cares about a specific triple enough to compile stuff regularly with it and to contribute fixes, it will most probably be broken20:21:42
11 Jun 2026
@eureka-cpu:matrix.orgeureka-cpu I was able to make it work with mingwW64 and some extra environment variables. mingw-ucrt-x86_64-llvm is indeed borked at the moment. 02:54:09
@rosssmyth:matrix.org@rosssmyth:matrix.org Yeah the ucrt code paths are not as well tested. Crane also has weird cross behavior itself, and rustPlatform is more reliable for Rust cross. If you cannot got it to cross with rustPlatform, you can open an issue on Nixpkgs with some logs and an MVP, and post in #windows:nixos.org. One of us may look into it. 15:21:59
@eureka-cpu:matrix.orgeureka-cpuThe crane cross story has gotten more reliable not too long ago15:47:46
@eureka-cpu:matrix.orgeureka-cpuI'll give that a try though if I get an ABI mismatch. Was trying to compile a DLL for an application.15:48:13
23 May 2021
@grahamc:nixos.org@grahamc:nixos.org set the history visibility to "world_readable".12:31:03
@grahamc:nixos.org@grahamc:nixos.org changed the room name to "" from "".12:31:03
@grahamc:nixos.org@grahamc:nixos.org invited @qyliss:fairydust.spaceAlyssa Ross.12:31:18
@qyliss:fairydust.spaceAlyssa Ross joined the room.13:21:04
@symphorien:xlumurb.eusymphorien joined the room.13:29:22
@joe:monoid.aljoe joined the room.13:29:32
@cleverca22:matrix.orgcleverca22 joined the room.13:29:44
@andi:kack.itandi- joined the room.13:36:08
@sternenseemann:systemli.orgsterni joined the room.13:39:12
@server_stats:nordgedanken.devServer Stats Discoverer (traveler bot) joined the room.14:52:21
@milan:petabyte.devMilan (they/them) 🏳️‍⚧️ joined the room.14:52:24
@thefloweringash:matrix.orgthefloweringash joined the room.14:52:43
@milan:petabyte.devMilan (they/them) 🏳️‍⚧️ changed their profile picture.18:30:44
@maljub01:matrix.orgmaljub01 joined the room.20:05:19
@colemickens:matrix.orgcolemickens 🏳️‍🌈 joined the room.21:50:09
24 May 2021
@voyager:t2bot.ioMatrix Traveler (bot) joined the room.03:05:08
@rajivr:matrix.orgrajivr joined the room.03:35:42
@kunrooted:matrix.orgkunrooted joined the room.05:17:10
@aaronjanse:matrix.orgaaronjanse joined the room.07:04:03
@vika:matrix.nice.sampler.fivika (she/her) 🏳️‍⚧️ joined the room.07:13:18

Show newer messages


Back to Room ListRoom Version: 6