Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions pkgs/development/tools/mold/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ stdenv
, fetchFromGitHub
, lib
, coreutils
, autoPatchelfHook
, cmake
, llvmPackages_latest
Expand Down Expand Up @@ -30,6 +31,39 @@ stdenv.mkDerivation rec {
LTO = 1;
makeFlags = [ "PREFIX=${placeholder "out"}" ];

# The next three variables are substituted into the script scaffold below.
# add-flags.sh; add-hardening.sh; ld-wrapper.sh; utils.bash
suffixSalt = lib.replaceStrings ["-" "."] ["_" "_"] stdenv.targetPlatform.config;
# utils.bash
wrapperName = "MOLD_WRAPPER";
# ld-wrapper.sh; utils.bash
coreutils_bin = lib.getBin coreutils;

postInstall = let
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) (stdenv.targetPlatform.config + "-");
in ''
mkdir -p $out/nix-support

mv $out/bin/mold $out/bin/.mold

export prog=$out/bin/.mold
Comment on lines +47 to +49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use wrapProgram or makeWrapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand how those tools would help solve the problem in a better way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this would help here.

substituteAll \
${../../../build-support/bintools-wrapper/ld-wrapper.sh} \
"$out/bin/${targetPrefix}mold"
chmod +x "$out/bin/${targetPrefix}mold"
ln -s $out/bin/${targetPrefix}mold $out/bin/${targetPrefix}ld

substituteAll \
${../../../build-support/bintools-wrapper/add-flags.sh} \
$out/nix-support/add-flags.sh
substituteAll \
${../../../build-support/bintools-wrapper/add-hardening.sh} \
$out/nix-support/add-hardening.sh
substituteAll \
${../../../build-support/wrapper-common/utils.bash} \
$out/nix-support/utils.bash
'';

passthru = {
updateScript = nix-update-script {
attrPath = pname;
Expand Down