From 113f762c550973cf0e00c7c56a2f95641ea2541e Mon Sep 17 00:00:00 2001 From: xinyangli Date: Tue, 12 Mar 2024 19:10:16 +0800 Subject: [PATCH] circt: init at 1.43.0 --- default.nix | 3 +- flake.lock | 8 ++--- pkgs/circt/default.nix | 70 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 pkgs/circt/default.nix diff --git a/default.nix b/default.nix index 4789c05..1005c1c 100644 --- a/default.nix +++ b/default.nix @@ -15,7 +15,8 @@ with pkgs; lib = import ./lib { inherit pkgs; }; # functions modules = import ./modules; # NixOS modules overlays = import ./overlays; # nixpkgs overlays - + + circt143 = callPackage ./pkgs/circt { version = "v143"; }; nvboard = callPackage ./pkgs/nvboard { }; ieda = callPackage ./pkgs/ieda { }; abstract-machine = callPackage ./pkgs/abstract-machine { }; diff --git a/flake.lock b/flake.lock index 0e3d3ae..63e6cbe 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1704161960, - "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "lastModified": 1704722960, + "narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/pkgs/circt/default.nix b/pkgs/circt/default.nix new file mode 100644 index 0000000..e2cb9b2 --- /dev/null +++ b/pkgs/circt/default.nix @@ -0,0 +1,70 @@ +{ stdenv +, lib +, cmake +, ninja +, git +, version +, python3 ? python312 +}: +let + pythonEnv = python3.withPackages (ps: [ ps.psutil ]); + versionHash = { + v143 = "sha256-RkjigboswLkLgLkgOGahQLIygCkC3Q9rbVw3LqIzREY="; + }; +in +stdenv.mkDerivation rec { + pname = "circt"; + version = version; + src = fetchFromGitHub { + owner = "llvm"; + repo = "circt"; + rev = "firtool-${version}"; + sha256 = versionHash.version; + fetchSubmodules = true; + }; + + requiredSystemFeatures = [ "big-parallel" ]; + + nativeBuildInputs = [ + cmake + ninja + git + pythonEnv + ]; + + 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=.." + "-DCIRCT_LLHD_SIM_ENABLED=OFF" + ]; + + LIT_FILTER_OUT = if stdenv.cc.isClang then "CIRCT :: Target/ExportSystemC/.*\.mlir" else null; + + preConfigure = '' + find ./test -name '*.mlir' -exec sed -i 's|/usr/bin/env|${coreutils}/bin/env|g' {} \; + ''; + + 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"; + + meta = { + description = "Circuit IR compilers and tools"; + homepage = "https://circt.org/"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ sharzy ]; + platforms = lib.platforms.all; + }; +};