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.
This commit is contained in:
parent
7c451c3b6b
commit
c8de31baa6
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user