diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index 473a91f9ce07..ea150c2fe85d 100644 --- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -186,7 +186,10 @@ in '' set +e EXTRA_BUILD=$(sed -n "s/^cargo:rustc-flags=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u) EXTRA_FEATURES=$(sed -n "s/^cargo:rustc-cfg=\(.*\)/--cfg \1/p" target/build/${crateName}.opt | tr '\n' ' ') - EXTRA_LINK=$(sed -n "s/^cargo:rustc-link-lib=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_ARGS=$(sed -n "s/^cargo:rustc-link-arg=\(.*\)/-C link-arg=\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_ARGS_BINS=$(sed -n "s/^cargo:rustc-link-arg-bins=\(.*\)/-C link-arg=\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_ARGS_LIB=$(sed -n "s/^cargo:rustc-link-arg-lib=\(.*\)/-C link-arg=\1/p" target/build/${crateName}.opt | tr '\n' ' ') + EXTRA_LINK_LIBS=$(sed -n "s/^cargo:rustc-link-lib=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ') EXTRA_LINK_SEARCH=$(sed -n "s/^cargo:rustc-link-search=\(.*\)/\1/p" target/build/${crateName}.opt | tr '\n' ' ' | sort -u) # We want to read part of every line that has cargo:rustc-env= prefix and diff --git a/pkgs/build-support/rust/build-rust-crate/lib.sh b/pkgs/build-support/rust/build-rust-crate/lib.sh index 39f7d53f6f75..7f98701b5409 100644 --- a/pkgs/build-support/rust/build-rust-crate/lib.sh +++ b/pkgs/build-support/rust/build-rust-crate/lib.sh @@ -17,6 +17,8 @@ build_lib() { -L dependency=target/deps \ --cap-lints allow \ $LINK \ + $EXTRA_LINK_ARGS \ + $EXTRA_LINK_ARGS_LIB \ $LIB_RUSTC_OPTS \ $BUILD_OUT_DIR \ $EXTRA_BUILD \ @@ -47,6 +49,8 @@ build_bin() { --out-dir target/bin \ -L dependency=target/deps \ $LINK \ + $EXTRA_LINK_ARGS \ + $EXTRA_LINK_ARGS_BINS \ $EXTRA_LIB \ --cap-lints allow \ $BUILD_OUT_DIR \ @@ -94,7 +98,7 @@ setup_link_paths() { done fi done - echo "$EXTRA_LINK" | while read i; do + echo "$EXTRA_LINK_LIBS" | while read i; do if [[ ! -z "$i" ]]; then for library in $i; do echo "-l $library" >> target/link