diff options
author | Symphorien Gibol <symphorien+git@xlumurb.eu> | 2020-03-28 12:00:00 +0000 |
---|---|---|
committer | Symphorien Gibol <symphorien+git@xlumurb.eu> | 2020-03-28 12:00:00 +0000 |
commit | 2f7fb1c49732105c8937b66b7d92402c04546073 (patch) | |
tree | ca4fa2223eb5fb3c482f7e805263a092ab47500a /pkgs/build-support/rust/build-rust-crate | |
parent | d8b853799d6658582a6039be8febfbd925d967aa (diff) | |
download | nixlib-2f7fb1c49732105c8937b66b7d92402c04546073.tar nixlib-2f7fb1c49732105c8937b66b7d92402c04546073.tar.gz nixlib-2f7fb1c49732105c8937b66b7d92402c04546073.tar.bz2 nixlib-2f7fb1c49732105c8937b66b7d92402c04546073.tar.lz nixlib-2f7fb1c49732105c8937b66b7d92402c04546073.tar.xz nixlib-2f7fb1c49732105c8937b66b7d92402c04546073.tar.zst nixlib-2f7fb1c49732105c8937b66b7d92402c04546073.zip |
buildRustCrateTests: add regression test for link order
Diffstat (limited to 'pkgs/build-support/rust/build-rust-crate')
-rw-r--r-- | pkgs/build-support/rust/build-rust-crate/test/default.nix | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/pkgs/build-support/rust/build-rust-crate/test/default.nix b/pkgs/build-support/rust/build-rust-crate/test/default.nix index f24583c41fcb..2251a1b40f2e 100644 --- a/pkgs/build-support/rust/build-rust-crate/test/default.nix +++ b/pkgs/build-support/rust/build-rust-crate/test/default.nix @@ -1,4 +1,4 @@ -{ lib, buildRustCrate, runCommand, writeTextFile, symlinkJoin, callPackage, releaseTools }: +{ lib, buildRustCrate, runCommand, runCommandCC, writeTextFile, symlinkJoin, callPackage, releaseTools }: let mkCrate = args: let p = { @@ -258,6 +258,58 @@ let ]; }; }; + # Regression test for https://github.com/NixOS/nixpkgs/pull/83379 + # link flag order should be preserved + linkOrder = { + src = symlinkJoin { + name = "buildrs-out-dir-overlay"; + paths = [ + (mkFile "build.rs" '' + fn main() { + // in the other order, linkage will fail + println!("cargo:rustc-link-lib=b"); + println!("cargo:rustc-link-lib=a"); + } + '') + (mkFile "src/main.rs" '' + extern "C" { + fn hello_world(); + } + fn main() { + unsafe { + hello_world(); + } + } + '') + ]; + }; + buildInputs = let + compile = name: text: runCommandCC name {} '' + mkdir -p $out/lib + $CC -shared -o $out/lib/${name}.so ${writeTextFile { + name = "${name}-src.c"; + inherit text; + }} + ''; + b = compile "libb" '' + #include <stdio.h> + + void hello(); + + void hello_world() { + hello(); + printf(" world!\n"); + } + ''; + a = compile "liba" '' + #include <stdio.h> + + void hello() { + printf("hello"); + } + ''; + in [ a b ]; + }; rustCargoTomlInSubDir = { # The "workspace_member" can be set to the sub directory with the crate to build. # By default ".", meaning the top level directory is assumed. |