Skip to content

Commit 3e5a758

Browse files
unlsycnAvimitin
authored andcommitted
[nix] switch to xsfmm llvm
Signed-off-by: unlsycn <[email protected]>
1 parent db50158 commit 3e5a758

File tree

4 files changed

+64
-27
lines changed

4 files changed

+64
-27
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "3.9.2"
1+
version = "3.9.4"
22

33
maxColumn = 120
44
align.preset = most

flake.lock

Lines changed: 31 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-parts.url = "github:hercules-ci/flake-parts";
7+
nixpkgs-for-llvm.url = "github:NixOS/nixpkgs/nixos-unstable-small";
78
mill-ivy-fetcher.url = "github:Avimitin/mill-ivy-fetcher";
89
circt-follow.url = "github:sequencer/zaozi";
910
treefmt-nix.url = "github:numtide/treefmt-nix";
@@ -13,6 +14,7 @@
1314
inputs@{
1415
self,
1516
nixpkgs,
17+
nixpkgs-for-llvm,
1618
mill-ivy-fetcher,
1719
circt-follow,
1820
...
@@ -51,6 +53,10 @@
5153
mill-ivy-fetcher.overlays.default
5254
# Follow CIRCT from sequencer/zaozi overlay
5355
circt-follow.overlays.default
56+
# pin riscv32 packages to avoid consistent breakage
57+
(final: prev: {
58+
rv32_nixpkgs = nixpkgs-for-llvm.legacyPackages."${system}".pkgsCross.riscv32-embedded;
59+
})
5460
overlay
5561
];
5662
};

nix/overlay.nix

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
final: prev:
22

33
let
4-
llvmForRVV_attrName = "llvmPackages_19";
5-
rv32_pkgs = final.pkgsCross.riscv32-embedded;
6-
rv32_buildPkgs = rv32_pkgs.buildPackages;
4+
llvmForRVV_attrName = "llvmPackages_git";
5+
rv32_pkgs = final.rv32_nixpkgs;
6+
rv32_buildPkgs = final.rv32_nixpkgs.buildPackages;
77
in
88
rec {
9-
inherit rv32_pkgs rv32_buildPkgs; # for easier inspection
10-
119
getEnv' =
1210
key:
1311
let
@@ -92,9 +90,31 @@ rec {
9290
newlib = rv32_pkgs.stdenv.cc.libc.overrideAttrs (oldAttrs: {
9391
CFLAGS_FOR_TARGET = "-march=rv32imacf_zvl128b_zve32f -mabi=ilp32f";
9492
});
93+
94+
llvmPackages = rv32_buildPkgs.${llvmForRVV_attrName};
95+
patchedCC =
96+
let
97+
llvmSrc = prev.fetchFromGitHub {
98+
owner = "topperc";
99+
repo = "llvm-project";
100+
rev = "bb123ff9401b517d877de4ed6fd9ea61edf49dbb";
101+
hash = "sha256-6ca5FhSsG5Qik7wi6Vn3OmUmKR/hULSDniu4JLo+5jM=";
102+
};
103+
vscalePatch = prev.fetchpatch {
104+
url = "https://github.com/llvm/llvm-project/pull/140195.patch";
105+
hash = "sha256-fevg7xQ/9RuOvGnT9uBhBAoM0wq+hB0tvidsg2LkxG8=";
106+
stripLen = 1;
107+
};
108+
in
109+
llvmPackages.clang-unwrapped.override {
110+
monorepoSrc = llvmSrc;
111+
libllvm = (llvmPackages.libllvm.override { monorepoSrc = llvmSrc; }).overrideAttrs (old: {
112+
patches = old.patches ++ [ vscalePatch ];
113+
});
114+
};
95115
in
96116
rv32_buildPkgs.wrapCCWith rec {
97-
cc = rv32_buildPkgs.${llvmForRVV_attrName}.clang-unwrapped;
117+
cc = patchedCC;
98118
libc = newlib;
99119
bintools = rv32_pkgs.stdenv.cc.bintools.override {
100120
inherit libc; # we must keep consistency of bintools libc and compiler libc

0 commit comments

Comments
 (0)