first commit
This commit is contained in:
commit
891b708e9c
6 changed files with 211 additions and 0 deletions
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# per-system-optim
|
||||
|
||||
Centralized repository for all things relating to my per-system-optim implementation.
|
64
default.nix
Normal file
64
default.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
nixpkgs ? <nixpkgs>,
|
||||
nixpkgs-unpatched ? null,
|
||||
system ? builtins.currentSystem,
|
||||
}: let
|
||||
nixpkgs-unpatched' =
|
||||
if nixpkgs-unpatched == null
|
||||
then nixpkgs
|
||||
else nixpkgs-unpatched;
|
||||
localSystems = rec {
|
||||
x86_64-linux.system = "x86_64-linux";
|
||||
aarch64-linux.system = "aarch64-linux";
|
||||
default.system = system;
|
||||
skylake =
|
||||
x86_64-linux
|
||||
// {
|
||||
gcc.arch = "skylake";
|
||||
gcc.tune = "skylake";
|
||||
};
|
||||
skylake-avx512 = skylake; # Currently none of my builders support avx512. Revisit when upgraded to znver4
|
||||
neoverse-n1 =
|
||||
aarch64-linux
|
||||
// {
|
||||
gcc.arch = "armv8.2-a";
|
||||
gcc.tune = "neoverse-n1";
|
||||
};
|
||||
znver1 =
|
||||
x86_64-linux
|
||||
// {
|
||||
gcc.arch = "znver1";
|
||||
gcc.tune = "znver1";
|
||||
};
|
||||
znver2 =
|
||||
x86_64-linux
|
||||
// {
|
||||
gcc.arch = "znver2";
|
||||
gcc.tune = "znver2";
|
||||
};
|
||||
};
|
||||
pkgs-unpatched = import nixpkgs-unpatched' {
|
||||
inherit system;
|
||||
overlays = [
|
||||
(_: _: {
|
||||
nixpkgs-unpatched = nixpkgs-unpatched';
|
||||
})
|
||||
(import ./overlay.nix)
|
||||
];
|
||||
config.contentAddressedByDefault = true;
|
||||
};
|
||||
pkgsFor = localSystem: args:
|
||||
import nixpkgs (args
|
||||
// {
|
||||
inherit localSystem;
|
||||
overlays = [
|
||||
(_: _: {
|
||||
nixpkgs-unpatched = nixpkgs-unpatched';
|
||||
})
|
||||
(import ./overlay.nix)
|
||||
];
|
||||
});
|
||||
in {
|
||||
inherit (pkgs-unpatched) nixpkgs;
|
||||
inherit pkgsFor;
|
||||
}
|
9
nixpkgs/default.nix
Normal file
9
nixpkgs/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
nixpkgs,
|
||||
applyPatches,
|
||||
}:
|
||||
applyPatches {
|
||||
name = "nixpkgs-patched";
|
||||
src = nixpkgs;
|
||||
patches = [./nixpkgs.patch];
|
||||
}
|
10
nixpkgs/eval.nix
Normal file
10
nixpkgs/eval.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{nixpkgs}: let
|
||||
buildFor = system:
|
||||
import ../. {
|
||||
inherit nixpkgs system;
|
||||
nixpkgs-unpatched = nixpkgs;
|
||||
};
|
||||
in {
|
||||
x86_64-linux = (buildFor "x86_64-linux").nixpkgs;
|
||||
aarch64-linux = (buildFor "aarch64-linux").nixpkgs;
|
||||
}
|
119
nixpkgs/nixpkgs.patch
Normal file
119
nixpkgs/nixpkgs.patch
Normal file
|
@ -0,0 +1,119 @@
|
|||
diff --git a/lib/systems/architectures.nix b/lib/systems/architectures.nix
|
||||
index 94127fa9..5253e4bb 100644
|
||||
--- a/lib/systems/architectures.nix
|
||||
+++ b/lib/systems/architectures.nix
|
||||
@@ -32,9 +32,24 @@ rec {
|
||||
armv5te = [ ];
|
||||
armv6 = [ ];
|
||||
armv7-a = [ ];
|
||||
- armv8-a = [ ];
|
||||
+ armv8-a = [ "fp" "simd" ];
|
||||
+ "armv8.1-a" = [ "crc" "lse" "rdma" ] ++ features.armv8-a;
|
||||
+ "armv8.2-a" = features."armv8.1-a";
|
||||
+ "armv8.3-a" = [ "pauth" ] ++ features."armv8.2-a";
|
||||
+ "armv8.4-a" = [ "flagm" "fp16fml" "dotprod" ] ++ features."armv8.3-a";
|
||||
+ "armv8.5-a" = [ "sb" "sbss" "predres" ] ++ features."armv8.4-a";
|
||||
+ "armv8.6-a" = [ "bf16" "i8mm" ] ++ features."armv8.5-a";
|
||||
+ "armv8.7-a" = [ "ls64" ] ++ features."armv8.6-a";
|
||||
+ "armv8.8-a" = [ "mops" ] ++ features."armv8.7-a";
|
||||
+ "armv9-a" = [ "sve" "sve2" ] ++ features."armv8.5-a";
|
||||
+ "armv9.1-a" = [ "bf16" "i8mm" ] ++ features."armv9-a";
|
||||
+ "armv9.2-a" = [ "ls64" ] ++ features."armv9.1-a";
|
||||
+ "armv9.3-a" = [ "mops" ] ++ features."armv9.2-a";
|
||||
mips32 = [ ];
|
||||
loongson2f = [ ];
|
||||
+ riscv64-g = [ "multiply" "atomic" "float" "double" "csr" "ifencei" ];
|
||||
+ riscv64-gc = [ "compressed" ] ++ features.riscv64-g;
|
||||
+ riscv64-gcv = [ "vector" ] ++ features.riscv64-gc;
|
||||
};
|
||||
|
||||
# a superior CPU has all the features of an inferior and is able to build and test code for it
|
||||
@@ -85,8 +100,23 @@ rec {
|
||||
armv6 = [ ];
|
||||
armv7-a = [ ];
|
||||
armv8-a = [ ];
|
||||
+ "armv8.1-a" = [ "armv8-a" ] ++ inferiors.armv8-a;
|
||||
+ "armv8.2-a" = [ "armv8.1-a" ] ++ inferiors."armv8.1-a";
|
||||
+ "armv8.3-a" = [ "armv8.2-a" ] ++ inferiors."armv8.2-a";
|
||||
+ "armv8.4-a" = [ "armv8.3-a" ] ++ inferiors."armv8.3-a";
|
||||
+ "armv8.5-a" = [ "armv8.4-a" ] ++ inferiors."armv8.4-a";
|
||||
+ "armv8.6-a" = [ "armv8.5-a" ] ++ inferiors."armv8.5-a";
|
||||
+ "armv8.7-a" = [ "armv8.6-a" ] ++ inferiors."armv8.6-a";
|
||||
+ "armv8.8-a" = [ "armv8.7-a" ] ++ inferiors."armv8.7-a";
|
||||
+ "armv9-a" = [ "armv8.5-a" ] ++ inferiors."armv8.5-a";
|
||||
+ "armv9.1-a" = [ "armv9-a" "armv8.6-a" ] ++ inferiors."armv9-a" ++ inferiors."armv8.6-a";
|
||||
+ "armv9.2-a" = [ "armv9.1-a" "armv8.7-a" ] ++ inferiors."armv9.1-a" ++ inferiors."armv8.7-a";
|
||||
+ "armv9.3-a" = [ "armv9.2-a" "armv8.8-a" ] ++ inferiors."armv9.2-a" ++ inferiors."armv8.8-a";
|
||||
mips32 = [ ];
|
||||
loongson2f = [ ];
|
||||
+ riscv64-g = [ ];
|
||||
+ riscv64-gc = [ "riscv64-g" ] ++ inferiors.riscv64-g;
|
||||
+ riscv64-gcv = [ "riscv64-gc" ] ++ inferiors.riscv64-gc;
|
||||
};
|
||||
|
||||
predicates = let
|
||||
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
|
||||
index e0ee3dae41f..49dbbe56594 100644
|
||||
--- a/pkgs/build-support/cc-wrapper/default.nix
|
||||
+++ b/pkgs/build-support/cc-wrapper/default.nix
|
||||
@@ -122,6 +122,10 @@ let
|
||||
znver1 = versionAtLeast ccVersion "6.0";
|
||||
znver2 = versionAtLeast ccVersion "9.0";
|
||||
znver3 = versionAtLeast ccVersion "11.0";
|
||||
+ # ARM
|
||||
+ # TODO: Fill in as needed
|
||||
+ # RISCV
|
||||
+ # TODO: Fill in as needed
|
||||
}.${arch} or true
|
||||
else if isClang then
|
||||
{ # Intel
|
||||
@@ -132,6 +136,10 @@ let
|
||||
# AMD
|
||||
znver1 = versionAtLeast ccVersion "4.0";
|
||||
znver2 = versionAtLeast ccVersion "9.0";
|
||||
+ # AMD
|
||||
+ # TODO: Fill in as needed
|
||||
+ # RISCV
|
||||
+ # TODO: Fill in as needed
|
||||
}.${arch} or true
|
||||
else
|
||||
false;
|
||||
diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix
|
||||
index 4d847e280f4..874b776c1e1 100644
|
||||
--- a/pkgs/top-level/impure.nix
|
||||
+++ b/pkgs/top-level/impure.nix
|
||||
@@ -9,12 +9,15 @@ let
|
||||
# Return ‘x’ if it evaluates, or ‘def’ if it throws an exception.
|
||||
try = x: def: let res = builtins.tryEval x; in if res.success then res.value else def;
|
||||
|
||||
+ configuredLocalSystem = if builtins.pathExists "/etc/nix/local-system.json" then builtins.fromJSON (builtins.readFile "/etc/nix/local-system.json") else { system = builtins.currentSystem; };
|
||||
+ localSystemOverriden = args: args ? system && (args.system != configuredLocalSystem);
|
||||
+ defaultLocalSystem = args: if localSystemOverriden args then { system = args.system; } else configuredLocalSystem;
|
||||
in
|
||||
|
||||
{ # We put legacy `system` into `localSystem`, if `localSystem` was not passed.
|
||||
# If neither is passed, assume we are building packages on the current
|
||||
# (build, in GNU Autotools parlance) platform.
|
||||
- localSystem ? { system = args.system or builtins.currentSystem; }
|
||||
+ localSystem ? null
|
||||
|
||||
# These are needed only because nix's `--arg` command-line logic doesn't work
|
||||
# with unnamed parameters allowed by ...
|
||||
@@ -78,6 +81,9 @@ in
|
||||
|
||||
, ...
|
||||
} @ args:
|
||||
+let
|
||||
+ localSystem' = if localSystem == null then defaultLocalSystem args else localSystem;
|
||||
+in
|
||||
|
||||
# If `localSystem` was explicitly passed, legacy `system` should
|
||||
# not be passed, and vice-versa.
|
||||
@@ -85,5 +91,6 @@ assert args ? localSystem -> !(args ? system);
|
||||
assert args ? system -> !(args ? localSystem);
|
||||
|
||||
import ./. (builtins.removeAttrs args [ "system" ] // {
|
||||
- inherit config overlays localSystem;
|
||||
+ inherit config overlays;
|
||||
+ localSystem = localSystem';
|
||||
})
|
6
overlay.nix
Normal file
6
overlay.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
self: super: {
|
||||
# nixpkgs-unpatched contains the original upstream nixpkgs tree
|
||||
nixpkgs = self.callPackage ./nixpkgs {
|
||||
nixpkgs = self.nixpkgs-unpatched or <nixpkgs-unpatched>;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue