Open gcoakes opened 3 years ago
The nixpkgs-mozilla version also gives me an error on my machine
error: builder for '/nix/store/75dhk8ci68y75nhkrnjabq9i40dnl1di-hello-deps-0.1.0.drv' failed with exit code 101;
last 10 log lines:
> = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/nix/store/l6cjpg87id5x7bkcifvzw1vmvrgrdc
fr-rust-1.53.0-nightly-2021-03-23-673d0db5e/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/build/dummy-src/target/release/build/hello-38695f0
04601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.0.rcgu.o" "/build/dummy-src/target/release/build/hello-38695
f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.1.rcgu.o" "/build/dummy-src/target/release/build/hello-386
95f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.2.rcgu.o" "/build/dummy-src/target/release/build/hello-3
8695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.3.rcgu.o" "/build/dummy-src/target/release/build/hello
-38695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.4.rcgu.o" "/build/dummy-src/target/release/build/hel
lo-38695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.5.rcgu.o" "/build/dummy-src/target/release/build/h
ello-38695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.6.rcgu.o" "-o" "/build/dummy-src/target/release/
build/hello-38695f004601b9fe/build_script_build-38695f004601b9fe" "/build/dummy-src/target/release/build/hello-38695f004601b9fe/build_scri
pt_build-38695f004601b9fe.2hbwckp71vjel1wh.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/build/dumm
y-src/target/release/deps" "-L" "/nix/store/l6cjpg87id5x7bkcifvzw1vmvrgrdcfr-rust-1.53.0-nightly-2021-03-23-673d0db5e/lib/rustlib/x86_64-u
nknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linu
x-gnu/lib/libstd-61556e43b375c2c0.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpani
c_unwind-787faa8b02fbd963.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-
dda4c0b69607e93b.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-4b7dae8949ac132
c.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-978e97832b309706.rlib" "/nix/
store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-073b1b693304b876.rlib" "/nix/store/rsylh
1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-c07f996a53ee6558.rlib" "/nix/store/rsylh1ac9xpynzh8galg
hjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-0ae8ed6a282247d0.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprl
am420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-978dd04958b6ebcc.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust
/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-14b94bdd9a47d665.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x
-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-bff7534e4dfcef6c.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rust
lib/x86_64-unknown-linux-gnu/lib/libcfg_if-022f1a0e7cd794ec.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unk
nown-linux-gnu/lib/liblibc-ff456575f1773ef0.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/l
ib/liballoc-3aeb407930ebd519.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std
_workspace_core-6ab1ee6dbc17ad08.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-
166dae07beec0398.rlib" "-Wl,--end-group" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcom
piler_builtins-761b290f47712921.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
> = note: /nix/store/xdii8qvch5h8chyp0z2is2qzky565w68-binutils-2.35.1/bin/ld: /nix/store/qah4dp8h83cqyc5n19a5rw85hlmmmrwh-pthread
s-w32-2.9.1-x86_64-w64-mingw32/lib/libpthread.a: error adding symbols: file format not recognized
> collect2: error: ld returned 1 exit status
Might be related to rust-lang/cargo#8239
The error you are getting (error adding symbols: archive has no index; run ranlib to add one
) seems to be from not having pthreads
in build inputs.
-buildInputs = with pkgs.pkgsCross.mingwW64.windows; [ mingw_w64_pthreads ];
+buildInputs = with pkgs.pkgsCross.mingwW64.windows; [ mingw_w64_pthreads pthreads ];
And by the way, there is a typo in the example you provided:
combine [
minimal.rustc
minimal.cargo
- targets.x86_64-unknown-linux-musl.latest.rust-std
+ targets.x86_64-pc-windows-gnu.latest.rust-std
];
Though I still get this error for both examples.
Sorry about the typos. I attempted to clean up the file before submitting and apparently removed some of the wrong lines. This is what I ended up using: https://github.com/gcoakes/img-sort I'll try again with fenix after I'm done with my work today.
I decided to turn my adventures in mingwW64 cross compilation into a pull request for naersk. Here's two commits showing the same process first with fenix then with nixpkgs-mozilla. The former fails; the later succeeds. fenix nixpkgs-mozilla
Of particular note here, the actual naersk-lib.buildPackage
call does not change between the two versions. Only the method in which the toolchain is obtained.
I found the problem! nix-community/fenix@dfd5ba should fix it. I tested it with the example you provided.
@figsoda , thank you. It seems to have fixed my issue. I updated my pull request to naersk to use fenix instead of nixpkgs-mozilla in the hopes of spreading flakes around a bit more. I unfortunately hit another issue, but I doubt it's related to fenix. It seems like naersk or probably nixpkgs is attempting to link to pthreads even for build scripts. Build scripts are of course meant to be built for the native platform. Either way, this doesn't affect basic "hello world" like projects. Thank you for your help.
The nixpkgs-mozilla version also gives me an error on my machine
error: builder for '/nix/store/75dhk8ci68y75nhkrnjabq9i40dnl1di-hello-deps-0.1.0.drv' failed with exit code 101; last 10 log lines: > = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/nix/store/l6cjpg87id5x7bkcifvzw1vmvrgrdc fr-rust-1.53.0-nightly-2021-03-23-673d0db5e/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/build/dummy-src/target/release/build/hello-38695f0 04601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.0.rcgu.o" "/build/dummy-src/target/release/build/hello-38695 f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.1.rcgu.o" "/build/dummy-src/target/release/build/hello-386 95f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.2.rcgu.o" "/build/dummy-src/target/release/build/hello-3 8695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.3.rcgu.o" "/build/dummy-src/target/release/build/hello -38695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.4.rcgu.o" "/build/dummy-src/target/release/build/hel lo-38695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.5.rcgu.o" "/build/dummy-src/target/release/build/h ello-38695f004601b9fe/build_script_build-38695f004601b9fe.build_script_build.3bz0o6bp-cgu.6.rcgu.o" "-o" "/build/dummy-src/target/release/ build/hello-38695f004601b9fe/build_script_build-38695f004601b9fe" "/build/dummy-src/target/release/build/hello-38695f004601b9fe/build_scri pt_build-38695f004601b9fe.2hbwckp71vjel1wh.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/build/dumm y-src/target/release/deps" "-L" "/nix/store/l6cjpg87id5x7bkcifvzw1vmvrgrdcfr-rust-1.53.0-nightly-2021-03-23-673d0db5e/lib/rustlib/x86_64-u nknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linu x-gnu/lib/libstd-61556e43b375c2c0.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpani c_unwind-787faa8b02fbd963.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide- dda4c0b69607e93b.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-4b7dae8949ac132 c.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-978e97832b309706.rlib" "/nix/ store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-073b1b693304b876.rlib" "/nix/store/rsylh 1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-c07f996a53ee6558.rlib" "/nix/store/rsylh1ac9xpynzh8galg hjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-0ae8ed6a282247d0.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprl am420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-978dd04958b6ebcc.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust /lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-14b94bdd9a47d665.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x -rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-bff7534e4dfcef6c.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rust lib/x86_64-unknown-linux-gnu/lib/libcfg_if-022f1a0e7cd794ec.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unk nown-linux-gnu/lib/liblibc-ff456575f1773ef0.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/l ib/liballoc-3aeb407930ebd519.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std _workspace_core-6ab1ee6dbc17ad08.rlib" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore- 166dae07beec0398.rlib" "-Wl,--end-group" "/nix/store/rsylh1ac9xpynzh8galghjjprlam420x-rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcom piler_builtins-761b290f47712921.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" > = note: /nix/store/xdii8qvch5h8chyp0z2is2qzky565w68-binutils-2.35.1/bin/ld: /nix/store/qah4dp8h83cqyc5n19a5rw85hlmmmrwh-pthread s-w32-2.9.1-x86_64-w64-mingw32/lib/libpthread.a: error adding symbols: file format not recognized > collect2: error: ld returned 1 exit status
Sorry for bringing this up here, but it's the only other reference I can find to this issue. How did you manage to fix this error? The latest fenix/naerks don't seem to have solved it.
I am unable to cross compile for mingw-w64 target using fenix while I am able to with nixpkgs-mozilla. Using the following flake.nix, naersk and fenix would fail to compile a hello world project. If I replace only the toolchain with one created from nixpkgs-mozilla, it compiles properly, so I believe that points towards fenix being the culprit.
fenix:
nixpkgs-mozilla: