build: replace mold with the wild linker

This commit is contained in:
Amaan Qureshi 2026-06-15 21:53:46 -04:00
commit b42e6f4af9
No known key found for this signature in database
GPG key ID: 2171751AD2A2739A
8 changed files with 53 additions and 66 deletions

View file

@ -2,12 +2,20 @@
lib,
rustPlatform,
llvm,
clang,
wild,
}: let
pname = "microfetch";
toml = (lib.importTOML ../Cargo.toml).workspace.package;
inherit (toml) version;
inherit (llvm) stdenv;
# wild + clang are only used on Linux tier-1 arches
hasWild =
stdenv.hostPlatform.isLinux
&& (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isAarch64);
in
rustPlatform.buildRustPackage.override {inherit (llvm) stdenv;} (finalAttrs: {
rustPlatform.buildRustPackage.override {inherit stdenv;} (finalAttrs: {
__structuredAttrs = true;
inherit pname version;
@ -21,12 +29,17 @@ in
(s + /.cargo)
(s + /crates)
(s + /microfetch)
(s + /scripts/ld-wrapper)
(s + /Cargo.lock)
(s + /Cargo.toml)
];
};
nativeBuildInputs = lib.optionals hasWild [wild clang];
env = lib.optionalAttrs hasWild {
RUSTFLAGS = "-Cforce-unwind-tables=no -Clinker=${clang}/bin/clang -Clink-arg=--ld-path=${wild}/bin/wild";
};
cargoLock.lockFile = "${finalAttrs.src}/Cargo.lock";
enableParallelBuilding = true;
buildNoDefaultFeatures = true;

View file

@ -2,7 +2,7 @@
mkShell,
cargo,
rustc,
mold,
wild,
clang,
rust-analyzer,
rustfmt,
@ -16,7 +16,7 @@ mkShell {
nativeBuildInputs = [
cargo
rustc
mold
wild
clang
rust-analyzer