adapters: Add useWildLinker
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
|
gccStdenv,
|
||||||
|
clangStdenv,
|
||||||
|
buildPackages,
|
||||||
|
runCommandCC,
|
||||||
makeBinaryWrapper,
|
makeBinaryWrapper,
|
||||||
gcc,
|
gcc,
|
||||||
wild,
|
wild,
|
||||||
@@ -8,6 +12,8 @@
|
|||||||
clang,
|
clang,
|
||||||
lld,
|
lld,
|
||||||
clang-tools,
|
clang-tools,
|
||||||
|
useWildLinker,
|
||||||
|
hello,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
# These wrappers are REQUIRED for the Wild test suite to pass
|
# These wrappers are REQUIRED for the Wild test suite to pass
|
||||||
@@ -51,6 +57,38 @@ let
|
|||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Test helper that takes in a binary and checks that it runs
|
||||||
|
# and was built with Wild
|
||||||
|
helloTest =
|
||||||
|
name: helloWild:
|
||||||
|
let
|
||||||
|
command = "$READELF -p .comment ${lib.getExe helloWild}";
|
||||||
|
emulator = stdenv.hostPlatform.emulator buildPackages;
|
||||||
|
in
|
||||||
|
runCommandCC "wild-${name}-test" { passthru = { inherit helloWild; }; } ''
|
||||||
|
echo "Testing running the 'hello' binary which should be linked with 'wild'" >&2
|
||||||
|
${emulator} ${lib.getExe helloWild}
|
||||||
|
|
||||||
|
echo "Checking for wild in the '.comment' section" >&2
|
||||||
|
if output=$(${command} 2>&1); then
|
||||||
|
if grep -Fw -- "Wild" - <<< "$output"; then
|
||||||
|
touch $out
|
||||||
|
else
|
||||||
|
echo "No mention of 'wild' detected in the '.comment' section" >&2
|
||||||
|
echo "The command was:" >&2
|
||||||
|
echo "${command}" >&2
|
||||||
|
echo "The output was:" >&2
|
||||||
|
echo "$output" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -n "${command}" >&2
|
||||||
|
echo " returned a non-zero exit code." >&2
|
||||||
|
echo "$output" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
testWild = wild.overrideAttrs {
|
testWild = wild.overrideAttrs {
|
||||||
@@ -96,4 +134,18 @@ in
|
|||||||
|
|
||||||
installPhase = "touch $out";
|
installPhase = "touch $out";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Test that the adapter works with a gcc stdenv
|
||||||
|
adapterGcc = helloTest "adapter-gcc" (
|
||||||
|
hello.override (_: {
|
||||||
|
stdenv = useWildLinker gccStdenv;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
# Test the adapter works with a clang stdenv
|
||||||
|
adapter-llvm = helloTest "adapter-llvm" (
|
||||||
|
hello.override (_: {
|
||||||
|
stdenv = useWildLinker clangStdenv;
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,6 +335,22 @@ rec {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useWildLinker =
|
||||||
|
stdenv:
|
||||||
|
if !stdenv.targetPlatform.isLinux then
|
||||||
|
throw "Wild only supports building Linux ELF files from Linux hosts."
|
||||||
|
else
|
||||||
|
stdenv.override (prev: {
|
||||||
|
allowedRequisites = null;
|
||||||
|
cc = prev.cc.override {
|
||||||
|
bintools = prev.cc.bintools.override {
|
||||||
|
extraBuildCommands = ''
|
||||||
|
ln -fs ${pkgs.buildPackages.wild-wrapped}/bin/* "$out/bin"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Modify a stdenv so that it builds binaries optimized specifically
|
Modify a stdenv so that it builds binaries optimized specifically
|
||||||
for the machine they are built on.
|
for the machine they are built on.
|
||||||
|
|||||||
Reference in New Issue
Block a user