about summary refs log tree commit diff
path: root/pkgs/development/compilers/circt/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/circt/default.nix')
-rw-r--r--pkgs/development/compilers/circt/default.nix38
1 files changed, 20 insertions, 18 deletions
diff --git a/pkgs/development/compilers/circt/default.nix b/pkgs/development/compilers/circt/default.nix
index 4c4f69bc74ff..b7804f708228 100644
--- a/pkgs/development/compilers/circt/default.nix
+++ b/pkgs/development/compilers/circt/default.nix
@@ -6,11 +6,14 @@
 , git
 , fetchFromGitHub
 , ninja
+, lit
 , gitUpdater
+, callPackage
 }:
 
 let
   pythonEnv = python3.withPackages (ps: [ ps.psutil ]);
+  circt-llvm = callPackage ./circt-llvm.nix { };
 in
 stdenv.mkDerivation rec {
   pname = "circt";
@@ -26,16 +29,14 @@ stdenv.mkDerivation rec {
   requiredSystemFeatures = [ "big-parallel" ];
 
   nativeBuildInputs = [ cmake ninja git pythonEnv ];
+  buildInputs = [ circt-llvm ];
 
-  cmakeDir = "../llvm/llvm";
   cmakeFlags = [
-    "-DLLVM_ENABLE_BINDINGS=OFF"
-    "-DLLVM_ENABLE_OCAMLDOC=OFF"
-    "-DLLVM_BUILD_EXAMPLES=OFF"
-    "-DLLVM_OPTIMIZED_TABLEGEN=ON"
-    "-DLLVM_ENABLE_PROJECTS=mlir"
-    "-DLLVM_EXTERNAL_PROJECTS=circt"
-    "-DLLVM_EXTERNAL_CIRCT_SOURCE_DIR=.."
+    "-DBUILD_SHARED_LIBS=ON"
+    "-DMLIR_DIR=${circt-llvm.dev}/lib/cmake/mlir"
+
+    # LLVM_EXTERNAL_LIT is executed by python3, the wrapped bash script will not work
+    "-DLLVM_EXTERNAL_LIT=${lit}/bin/.lit-wrapped"
     "-DCIRCT_LLHD_SIM_ENABLED=OFF"
   ];
 
@@ -60,18 +61,20 @@ stdenv.mkDerivation rec {
     substituteInPlace cmake/modules/GenVersionFile.cmake --replace "unknown git version" "${src.rev}"
   '';
 
-  installPhase = ''
-    runHook preInstall
-    mkdir -p $out/bin
-    mv bin/{{fir,hls}tool,circt-{as,dis,lsp-server,opt,reduce,translate}} $out/bin
-    runHook postInstall
-  '';
-
   doCheck = true;
   checkTarget = "check-circt check-circt-integration";
 
-  passthru.updateScript = gitUpdater {
-    rev-prefix = "firtool-";
+  outputs = [ "out" "lib" "dev" ];
+
+  postInstall = ''
+    moveToOutput lib "$lib"
+  '';
+
+  passthru = {
+    updateScript = gitUpdater {
+      rev-prefix = "firtool-";
+    };
+    llvm = circt-llvm;
   };
 
   meta = {
@@ -82,4 +85,3 @@ stdenv.mkDerivation rec {
     platforms = lib.platforms.all;
   };
 }
-