diff options
author | Andreas Rammhold <andreas@rammhold.de> | 2020-03-28 20:45:46 +0100 |
---|---|---|
committer | Andreas Rammhold <andreas@rammhold.de> | 2020-03-28 21:13:16 +0100 |
commit | c8de31baa6d820c9275d4708c296c4af370cf63b (patch) | |
tree | 8cac04ca9c021e039ee7f4022151f21f3c8db3af /pkgs/build-support/rust/build-rust-crate | |
parent | 7c451c3b6bc3b9fef2c8fa76d3faebda1607b21c (diff) | |
download | nixpkgs-c8de31baa6d820c9275d4708c296c4af370cf63b.tar nixpkgs-c8de31baa6d820c9275d4708c296c4af370cf63b.tar.gz nixpkgs-c8de31baa6d820c9275d4708c296c4af370cf63b.tar.bz2 nixpkgs-c8de31baa6d820c9275d4708c296c4af370cf63b.tar.lz nixpkgs-c8de31baa6d820c9275d4708c296c4af370cf63b.tar.xz nixpkgs-c8de31baa6d820c9275d4708c296c4af370cf63b.tar.zst nixpkgs-c8de31baa6d820c9275d4708c296c4af370cf63b.zip |
buildRustCrateTests: Fix link order test on darwin
As it turns out Darwin does most of the things differently then "normal" systems. They are using a different shared library extension and require an obscure commandline parameter that has to be added to every build system out there. That issue seems to be with clang on Darwin as on Linux that flag isn't required to build the very same tests (when using clang). After adjusting these two details the tests are running fine on the darwin box that I was able to obtain.
Diffstat (limited to 'pkgs/build-support/rust/build-rust-crate')
-rw-r--r-- | pkgs/build-support/rust/build-rust-crate/test/default.nix | 25 |
1 files changed, 20 insertions, 5 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 2251a1b40f2..598b5daed1b 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,13 @@ -{ lib, buildRustCrate, runCommand, runCommandCC, writeTextFile, symlinkJoin, callPackage, releaseTools }: +{ lib +, stdenv +, buildRustCrate +, runCommand +, runCommandCC +, writeTextFile +, symlinkJoin +, callPackage +, releaseTools +}: let mkCrate = args: let p = { @@ -284,12 +293,18 @@ let ]; }; buildInputs = let - compile = name: text: runCommandCC name {} '' - mkdir -p $out/lib - $CC -shared -o $out/lib/${name}.so ${writeTextFile { + compile = name: text: let + src = writeTextFile { name = "${name}-src.c"; inherit text; - }} + }; + in runCommandCC name {} '' + mkdir -p $out/lib + # Note: On darwin (which defaults to clang) we have to add + # `-undefined dynamic_lookup` as otherwise the compilation fails. + cc -shared \ + ${lib.optionalString stdenv.isDarwin "-undefined dynamic_lookup"} \ + -o $out/lib/${name}${stdenv.hostPlatform.extensions.sharedLibrary} ${src} ''; b = compile "libb" '' #include <stdio.h> |