Skip to content

Commit

Permalink
chore(nix): use mold and lld for linking
Browse files Browse the repository at this point in the history
  • Loading branch information
cfcosta committed Jul 21, 2024
1 parent 88fb310 commit 8686b87
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
;

inherit (prev) mkShell;
inherit (prev.lib) concatStringsSep;

dependencies = listToAttrs (
map (file: {
Expand Down Expand Up @@ -40,18 +41,41 @@ let
}) (attrNames (readDir ./packages))
);

systemFlags = {
"x86_64-darwin" = [ "-C link-arg=-fuse-ld=lld" ];
"aarch64-darwin" = systemFlags."x86_64-darwin";
"x86_64-linux" = [
"-C link-arg=-fuse-ld=mold"
"-C link-arg=-Wl,--separate-debug-file"
];
"aarch64-linux" = systemFlags."x86_64-linux";
};

systemDeps = {
"aarch64-darwin" = with prev; [
darwin.apple_sdk.frameworks.SystemConfiguration
lld
];
"x86_64-darwin" = systemDeps."aarch64-darwin";
"x86_64-linux" = with prev; [ mold ];
"aarch64-linux" = systemDeps."x86_64-linux";
};

devShells.default = mkShell {
name = "mu-shell";

packages = [
rust
(attrValues dependencies)
systemDeps.${final.system}

final.cargo-nextest
final.cargo-watch
];

RISC0_DEV_MODE = 1;
RISC0_RUST_SRC = "${rust}/lib/rustlib/src/rust";
RUSTFLAGS = concatStringsSep " " systemFlags.${final.system};
};
in
{
Expand Down

0 comments on commit 8686b87

Please sign in to comment.