|
11 | 11 | let |
12 | 12 | pkgs = import nixpkgs { inherit system; }; |
13 | 13 | 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; |
17 | 20 |
|
18 | 21 | buildInputs = with pkgs; [ |
19 | 22 | python3 |
20 | 23 | ninja |
21 | 24 | cmake |
22 | | - llvmPackages_latest.llvm |
23 | | - verilator |
24 | 25 | ]; |
25 | 26 |
|
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 | | - |
31 | 27 | 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" |
46 | 44 | ]; |
47 | 45 | }; |
48 | 46 |
|
| 47 | + devShell = (defaultPackage.overrideAttrs (oldAttrs: { |
| 48 | + name = "llvm-env"; |
| 49 | + buildInputs = oldAttrs.buildInputs ++ (with pkgs; [ verilator ]); |
| 50 | + })); |
| 51 | + |
49 | 52 | }); |
50 | 53 | } |
51 | 54 |
|
0 commit comments