Open flosse opened 6 years ago
@flosse use latest.rustChannels.<channel>.rust
, example
rust = (pkgs.latest.rustChannels.nightly.rust.override {
targets = [ "x86_64-unknown-linux-musl" ];
});
i didn't test this, but it should give you a hint, how to read rust-overlay.nix. please reopen the issue if above solution doesn't solve your problem.
attribute 'latest' missing, at /etc/nixos/configuration.nix:15:11
it seems that the overlay was not applied?
Ok now I can build it. Instead of
nixpkgs.config.overlays = [rustOverlay];
it has to be
nixpkgs.overlays = [rustOverlay];
But running a cargo build --target x86_64-unknown-linux-musl --release
leads to
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4.build_script_build0-afd01dc4b713e70b70e94e985240ed21.rs.rcgu.o" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4.build_script_build1-afd01dc4b713e70b70e94e985240ed21.rs.rcgu.o" "-o" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/mk/dev/ofdb/target/release/deps" "-L" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6851e07ca29e9abd.rlib" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-f4756b0c7819d088.rlib" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-4a4e6b90de4aee3b.rlib" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-796b548f911787cf.rlib" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-291834af13e3e380.rlib" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-53071de1a48897ba.rlib" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-49b314758875a8f4.rlib" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-d81c0e46e313811f.rlib" "-Wl,--end-group" "/nix/store/gk99p635qd0371l3nhcgdn5b6nvg92im-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-e8932e20141db79e.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"
= note: /nix/store/2kcrj1ksd2a14bm5sky182fv2xwfhfap-glibc-2.26-131/lib/Scrt1.o: In function `_start':
/build/glibc-2.26/csu/../sysdeps/x86_64/start.S:101: undefined reference to `__libc_csu_fini'
/build/glibc-2.26/csu/../sysdeps/x86_64/start.S:102: undefined reference to `__libc_csu_init'
collect2: Fehler: ld gab 1 als Ende-Status zurück
@flosse Can you compile the default hello world program that comes with cargo new
for binaries?
Can you compile the default hello world program
yes, that is working :)
I try to compile openfairdb which depends also on sqlite
, openssl
etc.
So I tried this:
$ nix-shell -p pkgconfig -p sqlite -p openssl -p musl -p musl.dev -p cmake -p zlib
$ cargo clean
$ cargo build --target x86_64-unknown-linux-musl --release
Compiling cfg-if v0.1.3
Compiling nodrop v0.1.12
Compiling memoffset v0.2.1
Compiling scopeguard v0.3.3
Compiling lazy_static v1.0.0
Compiling rayon-core v1.4.0
Compiling libc v0.2.41
Compiling unicode-xid v0.1.0
Compiling cc v1.0.15
Compiling pkg-config v0.3.11
Compiling matches v0.1.6
Compiling version_check v0.1.3
Compiling antidote v1.0.0
Compiling gcc v0.3.54
Compiling yansi v0.4.0
Compiling unicode-normalization v0.1.7
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4.build_script_build0-afd01dc4b713e70b70e94e985240ed21.rs.rcgu.o" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4.build_script_build1-afd01dc4b713e70b70e94e985240ed21.rs.rcgu.o" "-o" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4" "/home/mk/dev/ofdb/target/release/build/rayon-core-b7d2da7cc4c3b3f4/build_script_build-b7d2da7cc4c3b3f4.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/mk/dev/ofdb/target/release/deps" "-L" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-6851e07ca29e9abd.rlib" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-f4756b0c7819d088.rlib" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-4a4e6b90de4aee3b.rlib" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-796b548f911787cf.rlib" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-291834af13e3e380.rlib" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-53071de1a48897ba.rlib" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-49b314758875a8f4.rlib" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-d81c0e46e313811f.rlib" "-Wl,--end-group" "/nix/store/3al6kyhrcz32qyrc7b5cxja513dk2xw7-rust-1.28.0-nightly-2018-05-21-cb20f68d0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-e8932e20141db79e.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"
= note: /nix/store/2kcrj1ksd2a14bm5sky182fv2xwfhfap-glibc-2.26-131/lib/Scrt1.o: In function `_start':
/build/glibc-2.26/csu/../sysdeps/x86_64/start.S:101: undefined reference to `__libc_csu_fini'
/build/glibc-2.26/csu/../sysdeps/x86_64/start.S:102: undefined reference to `__libc_csu_init'
collect2: Fehler: ld gab 1 als Ende-Status zurück
error: aborting due to previous error
error: Could not compile `rayon-core`.
warning: build failed, waiting for other jobs to finish...
I noticed that same issue with rayon-core
v1.4.0 earlier when trying to compile one of my crates for the musl
target but it went away after cargo update
. Now it builds fine using the same nightly
version.
cargo update
increases the problem, now there is an additional error: Could not compile 'serde'
I tried several things but still without success :( Running a virtual machine with Ubuntu is my current workaround but it's quite annoying :-\
Here are the detailed steps to reproduce:
$ nixos-version
18.03.132500.2f6440eb09b (Impala)
$ git clone https://github.com/flosse/openfairdb
$ cd openfairdb/
$ nix-shell --pure overlay-dev-env.nix
$ rustc -V
rustc 1.28.0-nightly (5bf68db6e 2018-05-28)
$ cargo clean
$ cargo update
$ cargo build --target x86_64-unknown-linux-musl --release
I used the following overlay-dev-env-nix
(its not in the repo):
let
moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
pkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
channel = pkgs.rustChannelOf {
date = "2018-05-29";
channel = "nightly";
};
rust = (channel.rust.override {
targets = [ "x86_64-unknown-linux-musl" ];
});
in
with pkgs;
stdenv.mkDerivation {
name = "rust-ofdb-dev-env";
buildInputs = [
rust
musl
musl.dev
sqlite
sqlite.dev
cmake
pkgconfig
];
SQLITE3_DIR = "${sqlite.dev}";
SQLITE3_LIB_DIR = "${sqlite.out}/lib";
SQLITE3_INCLUDE_LIB_DIR = "${sqlite.out}/include";
}
You can do this now by using rustChannelOfTargets "nightly" null ["target1", "target2"]
.
Could someone explain how to use this overlay to compile WASM from Rust in NixOS in simple steps?
I've installed $HOME/.config/nixpkgs/overlays/rust-overlay.nix
and can compile WASM with these steps, but it fails at the final step:
$ nix-shell -p rustChannels.stable.cargo rustChannels.stable.rustc
$ RUSTFLAGS="" cargo build --target wasm32-unknown-unknown
Compiling wasm-bindgen v0.2.29
error[E0463]: can't find crate for `core`
|
= note: the `wasm32-unknown-unknown` target may not be installed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `wasm-bindgen`.
To learn more, run the command again with --verbose.
I'm getting a similar error while attempting to compile with musl target:
default.nix
let
moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
stableRust = nixpkgs.latest.rustChannels.stable.rust.override {
targets = [ "x86_64-unknown-linux-gnu" "x86_64-unknown-linux-musl" ];
};
stableCargo = nixpkgs.latest.rustChannels.stable.cargo;
buildRustPackage = nixpkgs.callPackage (import <nixpkgs/pkgs/build-support/rust>) {
rust = {
rustc = stableRust;
cargo = stableCargo;
};
};
derivation = { stdenv, rustPlatform, buildRustPackage, llvmPackages_39, rust-bindgen, ... }:
buildRustPackage rec {
name = "foo-package";
version = "0.1.0";
src = ./.;
libclang = llvmPackages_39.libclang.lib;
clang = llvmPackages_39.clang;
buildInputs = [ libclang rust-bindgen ];
propagatedBuildInputs = [ clang ];
configurePhase = ''
export LIBCLANG_PATH=${libclang}/lib
'';
cargoSha256 = "0cwc4m5wfaf5nn4gz4pvfhbc816xv0v9w6vy8y190xjllyv3rr70";
meta = with stdenv.lib; {
description = "foo-package";
license = licenses.mpl20;
maintainers = with maintainers; [ tdbgamer ];
};
shellHook = ''
export LIBCLANG_PATH=${libclang}/lib
'';
};
in
nixpkgs.callPackage derivation {
inherit buildRustPackage;
rust = stableRust;
cargo = stableCargo;
}
The output:
[nix-shell:~/src/tim]$ cargo build --target x86_64-unknown-linux-musl
Compiling foo-package v0.1.0 (/home/tbess/src/foo-package)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--eh-frame-hdr" "-Wl,-(" "-m64" "-nostdlib" "/nix/store/1y4rdlkn82wfq6dkv7p69hadkdi1vzr4-rust-1.31.1-2018-12-18-b6c32da9b/lib/rustlib/x86_64-unknown-linux-musl/lib/crt1.o" "/nix/store/1y4rdlkn82wfq6dkv7p69hadkdi1vzr4-rust-1.31.1-2018-12-18-b6c32da9b/lib/rustlib/x86_64-unknown-linux-musl/lib/crti.o" "-L" "/nix/store/1y4rdlkn82wfq6dkv7p69hadkdi1vzr4-rust-1.31.1-2018-12-18-b6c32da9b/lib/rustlib/x86_64-unknown-linux-musl/lib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.12fsgcdf5xnmqkmg.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.16cxbycxyoseol3n.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.17n9962hv8f36dr3.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.19v3fse28da3kzax.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1barhd6k8e1ekbg8.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1kclo7ptsbyqmptz.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1mo0q9xmz3ittoek.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1oy92u96wnw1zqw1.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1oyy5xaawnmt5wqt.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1ra2jozjzv044jnc.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1uczn18qwvt17bx4.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1wrwsm1e15ya710e.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.1yjoqtvmejbzhiw7.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.22uw94c4j3qeedc4.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2ai8mmfxxxs2mxh0.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2au0wmi42w0jyewt.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2burg7nfoan8nu5p.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2f0xxo0sj526amlv.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2j6xi02iqt83qfxe.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2jgavptu1g6jrkrj.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2mybfss6xlmg209v.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2nqwxcss3d9vjnew.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.2o61572kousxu6ui.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.31c8wtd1mgdcaqzk.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.32h9dkkj180f8f04.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.36ly8mfo0845cv6g.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.36qt447uhkgcmi3c.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3fr3t0a3rizbotlg.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3hbho43i0f9k6a1k.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3l52gnyvzc8q3hax.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3qdm4bc4fxax1dzp.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3riyxcg9nqxll6f6.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3sohq9okd63oafay.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3u0zc528w1x42z67.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3ucqwvl3upg5d1zu.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.3ueuywdfxh9r6osa.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.40ewg5mgj2j259la.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.43fvqd8e2uf0sqpy.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.447ejqevpjf9gvhb.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.46rojnp6tz7h2n1z.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.47kvpcbn61h7z818.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4duvp5fd3l1n09mo.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4ikj01vhiw1ckjzd.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4pmenrjd8g8vtoih.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4s6xjt2s9o00f8lr.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4skvopzxc9npabmh.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4szf0chyn0hwibv5.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4tdan3gyrz6l49fy.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4xbxv90ppb1sqej.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.4yyh5v0xqajm9jzj.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.599w4c256nmmdeqy.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.5a52q2ddz4jx3io0.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.5uxz5e6m1vzixyv.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.c4tj62v7rubuc0l.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.hwze9ugjjwp3aur.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.i78kgbjqesa7mu8.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.m8rakj3jvvrm5mg.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.mvc303cc4w0vmfs.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.nifqwo78ty2qt91.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.nj48mt83xcghl9b.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.nttribdfa05ctec.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.on4hb11ht1dept1.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.san4cd1grj1mkx4.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.v8s1hbsfc6q3sc8.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.vtin6fqun8oifly.rcgu.o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.xqks8qly8wtocgj.rcgu.o" "-o" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/foo-package-d4d338f9ab7a5c17.5cvh25e6auxoftmj.rcgu.o" "-Wl,--gc-sections" "-no-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps" "-L" "/home/tbess/src/foo-package/target/debug/deps" "-L" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/build/backtrace-sys-3cfb8d5dc5f4fc41/out" "-L" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/build/libpg_query-sys-e9c43763c9e77cf3/out/libpg_query" "-L" "/nix/store/1y4rdlkn82wfq6dkv7p69hadkdi1vzr4-rust-1.31.1-2018-12-18-b6c32da9b/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc_jemalloc-daf4b30ba0aa7eb6.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libfoo-package-3d761339ee90b05c.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libserde_json-4546dd31b955ff4a.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libryu-62ce123ff15b88b6.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libitoa-d6795f6dccb0ec90.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libserde-942a6c0db87389e2.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libquicli-8f8aa84aae8758c5.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libexitfailure-499c961a2b117d5d.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librayon-4c74f844c31bde2f.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libeither-b7c39e308dae8c08.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librayon_core-8256d4a2d8497a0d.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libnum_cpus-26cd56987111a237.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libcrossbeam_deque-eca307c019ba08a7.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libcrossbeam_epoch-16db1a80a93fbb31.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libcrossbeam_utils-6ba00254217a34e4.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libclap_verbosity_flag-6cc4615ca3bd3a3b.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libenv_logger-c24528491b15651a.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libhumantime-587a3f64c2d018e0.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libquick_error-9d5363c460557c7f.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libtermcolor-ceb6ac954018e82b.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libglobwalk-f06041c907eafc39.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libignore-34236e5a4031f69f.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libwalkdir-b5edbe628d6fa2ed.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libsame_file-d214b48828062f82.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libglobset-04ad7fc0bce8d1a5.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libregex-db829d7c84c9eed8.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libutf8_ranges-ef1e8bc03d6aedb3.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libregex_syntax-f4b35d99bc11840b.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libucd_util-59498ee8cc928093.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libthread_local-25ebbe0584c724e8.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblog-fe15b35da0dc3ebe.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libfnv-4e3e0a48235ae458.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libaho_corasick-359e6824d4ed197e.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libmemchr-3e681b76ef82279c.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libcrossbeam_channel-6d9d72edd7122227.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libparking_lot-fd2288be21ba1e51.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libparking_lot_core-9c1d917c5f1cba05.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libsmallvec-23f888168bc3df14.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libunreachable-8e1c8d9015c7f6da.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libvoid-c89b4d8d5f4ffed8.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librand-4c6d2c9ce2e36e6c.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librand_xorshift-881ad314012cf69f.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librand_pcg-8d23a7d2b0b9a978.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librand_hc-4c8babb0f6dd198c.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librand_chacha-22e72ee053923e56.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librand_isaac-3d74c7d155763354.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librand_core-af5ff114bcd7d580.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblock_api-576636fbab7e221b.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libowning_ref-775a54564be7e984.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libstable_deref_trait-5102c8c48ee46160.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libcrossbeam_epoch-589f554f9cdf3c12.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblazy_static-29999fb99158c51a.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libscopeguard-409fa5a85f80f8b5.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libmemoffset-19f7eadc94009acf.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libcrossbeam_utils-aa6926b844a17e3e.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libarrayvec-9d7dabfaef20a9a2.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libnodrop-3c2b4ea8ea959f63.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libremove_dir_all-015c0beef79257d3.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libfailure-5dc4462b7ce18d62.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libbacktrace-52fea4d90fc5d265.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libbacktrace_sys-35463d497c4f16b5.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/librustc_demangle-6567dcb12bb30866.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libcfg_if-e5c77d455d1e3462.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libstructopt-293b53327ba55b19.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libclap-8f52d924155175e3.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libvec_map-ebe208df55ced208.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libtextwrap-a539cd0d6364041d.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libunicode_width-b88dff9a42af1818.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libstrsim-3419a621d7e5ee7c.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libbitflags-65cfda72a6f0e70c.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libatty-b6aadc17e7b96816.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibc-111bc4d118e0e3c8.rlib" "/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/libansi_term-3b002c6f9e08e2ee.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-cd33df8f773a8d34.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-b4f2368c97086610.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-4c51ac82f70822c1.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc_system-34fc26c16207806e.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-d0b3565c39ede68e.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-ac8a19e2dea4f5a1.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-bc99d396b91fe14a.rlib" "/nix/store/5f1diyzdp535w3b8jpjp9db6qwmvc7ll-rust-std/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-5f64e7823d30511e.rlib" "-static" "-Wl,-Bdynamic" "/nix/store/1y4rdlkn82wfq6dkv7p69hadkdi1vzr4-rust-1.31.1-2018-12-18-b6c32da9b/lib/rustlib/x86_64-unknown-linux-musl/lib/crtn.o" "-Wl,-)"
= note: /home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_backend_utils_mmgr_mcxt.o): In function `fprintf':
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:97: undefined reference to `__fprintf_chk'
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:97: undefined reference to `__fprintf_chk'
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:97: undefined reference to `__fprintf_chk'
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_backend_utils_error_elog.o): In function `snprintf':
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:64: undefined reference to `__snprintf_chk'
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_backend_utils_error_elog.o): In function `vfprintf':
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:127: undefined reference to `__vfprintf_chk'
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_backend_utils_error_elog.o): In function `pg_re_throw':
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/build/libpg_query-sys-e9c43763c9e77cf3/out/libpg_query/src/postgres/src_backend_utils_error_elog.c:1382: undefined reference to `__longjmp_chk'
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_backend_utils_mmgr_aset.o): In function `fprintf':
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:97: undefined reference to `__fprintf_chk'
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_backend_utils_mb_wchar.o): In function `sprintf':
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:33: undefined reference to `__sprintf_chk'
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:33: undefined reference to `__sprintf_chk'
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_common_psprintf.o): In function `vsnprintf':
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/stdio2.h:77: undefined reference to `__vsnprintf_chk'
/home/tbess/src/foo-package/target/x86_64-unknown-linux-musl/debug/deps/liblibpg_query-a75ce5d94d5659c5.rlib(src_backend_parser_scansup.o): In function `memcpy':
/nix/store/f3l058q0zvnzr7nvl0jj789pyvljqadw-glibc-2.27-dev/include/bits/string_fortified.h:34: undefined reference to `__memcpy_chk'
collect2: error: ld returned 1 exit status
error: aborting due to previous error
error: Could not compile `foo-package`.
To learn more, run the command again with --verbose.
I got cross compilation to work in a nix-shell using the following configuration:
default.nix:
{ pkgsPath ? <nixpkgs>, crossSystem ? null }:
let
mozOverlay = import (
builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz
);
pkgs = import pkgsPath {
overlays = [ mozOverlay ];
inherit crossSystem;
};
targets = [ pkgs.stdenv.targetPlatform.config ];
my_openssl = pkgs.openssl_1_1 or pkgs.openssl_1_1_0;
in
with pkgs;
stdenv.mkDerivation {
name = "castle";
# build time dependencies targeting the build platform
depsBuildBuild = [
buildPackages.stdenv.cc
];
HOST_CC = "cc";
# build time dependencies targeting the host platform
nativeBuildInputs = [
(buildPackages.buildPackages.latest.rustChannels.nightly.rust.override { inherit targets; })
buildPackages.buildPackages.rustfmt
];
shellHook = ''
export RUSTFLAGS="-C linker=$CC"
'';
CARGO_BUILD_TARGET = targets;
# run time dependencies
OPENSSL_DIR = my_openssl.dev;
OPENSSL_LIB_DIR = "${my_openssl.out}/lib";
}
aarch64.nix:
import ./default.nix {
crossSystem = (import <nixpkgs> {}).lib.systems.examples.aarch64-multiplatform;
}
For normal compilation execute:
nix-shell
cargo build
For cross-compilation to aarch64 execute:
nix-shell aarch64.nix
cargo build
This does not work for me :(
nix-shell musl64.nix
cargo build
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo)
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: __rawmemchr: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_Resume: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: __register_atfork: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_GetIPInfo: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: __res_init: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_GetDataRelBase: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_GetRegionStart: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_SetGR: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_FindEnclosingFunction: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_GetTextRelBase: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_DeleteException: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_RaiseException: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_Backtrace: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating /nix/store/0k2y2dsafmcwpl7gss07a9kn3bga37bb-rust-1.34.0-nightly-2019-02-26-02c4c2892-x86_64-unknown-linux-musl/bin/cargo: _Unwind_SetIP: symbol not found
This does not work for me :(
Weird, compiling to musl64 works for me (using crossSystem = (import <nixpkgs> {}).lib.systems.examples.musl64;
). What do your .nix
files look like?
@haslersn It compiles but for me it doesn't make a static binary (with openssl depends).
ldd target/x86_64-unknown-linux-musl/release/mqtt-webhook
linux-vdso.so.1 (0x00007ffdff5cc000)
libssl.so.1.1 => /nix/store/3x85azr8a9i2vl096ix0yqb6k7pqmcnh-openssl-1.1.1b-x86_64-unknown-linux-musl/lib/libssl.so.1.1 (0x00007ff62dad9000)
libcrypto.so.1.1 => /nix/store/3x85azr8a9i2vl096ix0yqb6k7pqmcnh-openssl-1.1.1b-x86_64-unknown-linux-musl/lib/libcrypto.so.1.1 (0x00007ff62d852000)
libc.so => /nix/store/3vp3w8wf66357w04lwq7pcr40vlrwqfg-musl-1.1.21-x86_64-unknown-linux-musl/lib/libc.so (0x00007ff62d7a5000)
I tried OPENSSL_STATIC=1; but I have this error with cargo build --target x86_64-unknown-linux-musl --release
:
error: could not find native static library
ssl, perhaps an -L flag is missing?
Thank you again for your feedback.
It works with this example
with import <nixpkgs> {};
let
rust = (rustChannels.nightly.rust.override {
targets = [
"x86_64-unknown-linux-musl"
];
});
in pkgs.mkShell {
name = "env-mqtt-webhook";
buildInputs = [
rust
];
PKG_CONFIG_ALLOW_CROSS=true;
PKG_CONFIG_ALL_STATIC=true;
LIBZ_SYS_STATIC=1;
OPENSSL_STATIC=1;
OPENSSL_DIR = pkgsStatic.openssl.dev;
OPENSSL_LIB_DIR = "${pkgsStatic.openssl.out}/lib";
}
cargo build --target x86_64-unknown-linux-musl --release
@apeyroux can you build a static rust package using buildRustPackage
with the rust
and cargo
taken from this overlay?
In my
/etc/nixos/configuration.nix
I triedBut I get this error:
attribute 'latest' missing, at /etc/nixos/configuration.nix:14:11
Where is my fault?