32 lines
954 B
Nix
32 lines
954 B
Nix
|
pkgs: baseStdenv: let
|
||
|
inherit (pkgs) lib;
|
||
|
inherit (lib)
|
||
|
concatStrings
|
||
|
optionals
|
||
|
optionalAttrs
|
||
|
mapAttrsToList
|
||
|
extendEnv;
|
||
|
inherit (stdenv) targetPlatform;
|
||
|
|
||
|
stdenv = pkgs.overrideCC baseStdenv pkgs.llvmPackages.clangUseLLVM;
|
||
|
in pkgs.addAttrsToDerivation (extendEnv {
|
||
|
NIX_RUSTFLAGS = let
|
||
|
target-cpu = targetPlatform.rust.rustcTargetCPU
|
||
|
or (if targetPlatform.isx86 then "x86-64-v3" else null);
|
||
|
|
||
|
target-features = targetPlatform.rust.rustcTargetFeatures
|
||
|
or (optionalAttrs targetPlatform.isAarch {
|
||
|
"v8.2a" = true;
|
||
|
fp16 = true;
|
||
|
rcpc = true;
|
||
|
dotprod = true;
|
||
|
}) |> mapAttrsToList (n: v: (if v then "+" else "-") + n) |> concatStrings;
|
||
|
in [
|
||
|
"-C" "codegen-units=1"
|
||
|
"-C" "opt-level=2"
|
||
|
"-C" "linker-plugin-lto"
|
||
|
"-C" "prefer-dynamic"
|
||
|
"-C" "target-features=${target-features}"
|
||
|
] ++ optionals (target-cpu != null) [ "-C target-cpu=${target-cpu}" ];
|
||
|
}) stdenv
|