Skip to content

Commit

Permalink
Use lld via .cargo/config.toml and not env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Dec 23, 2024
1 parent 3668ee0 commit d32bfcf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ if command -v nix &> /dev/null && [ -z ${DISABLE_NIX+x} ]
then
use nix
fi

if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v lld &> /dev/null && [ ! -f .cargo/config.toml ]; then
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[target.$(uname -m)-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
EOF
fi
6 changes: 4 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ pkgs.mkShell {
useLld = "-C link-arg=-fuse-ld=lld";
in
pkgs.lib.optionalString pkgs.stdenv.isLinux ''
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${useLld}"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${useLld}"
if [ ! -f .cargo/config.toml ]; then
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${useLld}"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${useLld}"
fi
'';
}

0 comments on commit d32bfcf

Please sign in to comment.