Skip to content

Commit 699a5e4

Browse files
authored
fix issues with flake.nix (#10)
1 parent f5b34c4 commit 699a5e4

File tree

2 files changed

+36
-25
lines changed

2 files changed

+36
-25
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TODO
66
## Getting dev shell
77
* Install `nix`:
88
```
9-
$ sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --no-daemon
9+
sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --no-daemon
1010
```
1111
* Enable flakes experimental feature:
1212
```
@@ -19,3 +19,11 @@ nix develop
1919
```
2020
* (Optional) Setup [direnv](https://github.com/direnv/direnv) to enter into nix shell automatically
2121

22+
23+
## Building
24+
25+
Inside nix shell:
26+
```
27+
cmake $cmakeFlags -S llvm -B build
28+
ninja -C build
29+
```

flake.nix

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,44 @@
1111
let
1212
pkgs = import nixpkgs { inherit system; };
1313
gccForLibs = pkgs.stdenv.cc.cc;
14-
in {
15-
devShell = pkgs.mkShell {
16-
name = "llvm-env";
14+
in rec {
15+
16+
defaultPackage = pkgs.stdenv.mkDerivation {
17+
name = "llvm";
18+
19+
dontUnpack = true;
1720

1821
buildInputs = with pkgs; [
1922
python3
2023
ninja
2124
cmake
22-
llvmPackages_latest.llvm
23-
verilator
2425
];
2526

26-
# where to find libgcc
27-
NIX_LDFLAGS="-L${gccForLibs}/lib/gcc/${system}/${gccForLibs.version}";
28-
# teach clang about C startup file locations
29-
CFLAGS="-B${gccForLibs}/lib/gcc/${system}/${gccForLibs.version} -B ${pkgs.stdenv.cc.libc}/lib";
30-
3127
cmakeFlags = [
32-
"-DGCC_INSTALL_PREFIX=${pkgs.gcc}"
33-
"-DC_INCLUDE_DIRS=${pkgs.stdenv.cc.libc.dev}/include"
34-
"-GNinja"
35-
# Debug for debug builds
36-
"-DCMAKE_BUILD_TYPE=Release"
37-
# inst will be our installation prefix
38-
"-DCMAKE_INSTALL_PREFIX=../inst"
39-
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
40-
# change this to enable the projects you need
41-
"-DLLVM_ENABLE_PROJECTS=clang"
42-
# enable libcxx* to come into play at runtimes
43-
"-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi"
44-
# this makes llvm only to produce code for the current platform, this saves CPU time, change it to what you need
45-
"-DLLVM_TARGETS_TO_BUILD=host"
28+
"-DUSE_DEPRECATED_GCC_INSTALL_PREFIX=1"
29+
"-DGCC_INSTALL_PREFIX=${pkgs.gcc}"
30+
"-DC_INCLUDE_DIRS=${pkgs.stdenv.cc.libc.dev}/include"
31+
"-GNinja"
32+
# Debug for debug builds
33+
"-DCMAKE_BUILD_TYPE=Release"
34+
# inst will be our installation prefix
35+
"-DCMAKE_INSTALL_PREFIX=../inst"
36+
"-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON"
37+
# change this to enable the projects you need
38+
"-DLLVM_ENABLE_PROJECTS=clang"
39+
# enable libcxx* to come into play at runtimes
40+
"-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi"
41+
# this makes llvm only to produce code for the current platform, this saves CPU time, change it to what you need
42+
"-DLLVM_TARGETS_TO_BUILD=host"
43+
"-S ${self}/llvm"
4644
];
4745
};
4846

47+
devShell = (defaultPackage.overrideAttrs (oldAttrs: {
48+
name = "llvm-env";
49+
buildInputs = oldAttrs.buildInputs ++ (with pkgs; [ verilator ]);
50+
}));
51+
4952
});
5053
}
5154

0 commit comments

Comments
 (0)