17 pythonEnv = python3.withPackages (ps: [ ps.psutil ]);
18 circt-llvm = callPackage ./circt-llvm.nix { };
20 stdenv.mkDerivation rec {
23 src = fetchFromGitHub {
26 rev = "firtool-${version}";
27 hash = "sha256-zX+mzbfucrXdFN4+j+nAptn3HVLPKVUd55cQRHrpIJg=";
28 fetchSubmodules = true;
31 requiredSystemFeatures = [ "big-parallel" ];
40 buildInputs = [ circt-llvm ];
43 "-DBUILD_SHARED_LIBS=ON"
44 "-DMLIR_DIR=${circt-llvm.dev}/lib/cmake/mlir"
46 # LLVM_EXTERNAL_LIT is executed by python3, the wrapped bash script will not work
47 "-DLLVM_EXTERNAL_LIT=${lit}/bin/.lit-wrapped"
48 "-DCIRCT_LLHD_SIM_ENABLED=OFF"
51 # cannot use lib.optionalString as it creates an empty string, disabling all tests
55 # There are some tests depending on `clang-tools` to work. They are activated only when detected
56 # `clang-tidy` in PATH, However, we cannot simply put `clang-tools` in checkInputs to make these
59 # 1. The absolute paths of binaries used in tests are resolved in configure phase.
60 # 2. When stdenv = clangStdenv, the `clang-tidy` binary appears in PATH via `clang-unwrapped`,
61 # which is always placed before `${clang-tools}/bin` in PATH. `clang-tidy` provided in
62 # `clang-unwrapped` cause tests failing because it is not wrapped to resolve header search paths.
63 # https://github.com/NixOS/nixpkgs/issues/214945 discusses this issue.
65 # As a temporary fix, we disabled these tests when using clang stdenv
66 lib.optionals stdenv.cc.isClang [ "CIRCT :: Target/ExportSystemC/.*\\.mlir" ]
67 # Disable some tests on x86_64-darwin
68 ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-darwin") [
69 # These test seem to pass on hydra (rosetta) but not on x86_64-darwin machines
70 "CIRCT :: Target/ExportSMTLIB/.*\\.mlir"
71 "CIRCT :: circt-bmc/.*\\.mlir"
72 # These tests were having issues on rosetta
73 "CIRCT :: Dialect/.*/Reduction/.*\\.mlir"
74 "CIRCT :: Dialect/SMT/.*\\.mlir"
75 "CIRCT :: circt-as-dis/.*\\.mlir"
76 "CIRCT :: circt-reduce/.*\\.mlir"
77 "CIRCT :: circt-test/basic.mlir"
80 # Temporarily disable for bump: https://github.com/llvm/circt/issues/8000
81 "CIRCT :: Dialect/FIRRTL/SFCTests/ExtractSeqMems/Compose.fir"
82 "CIRCT :: Dialect/FIRRTL/SFCTests/ExtractSeqMems/Simple2.fir"
83 "CIRCT :: Dialect/FIRRTL/extract-instances.mlir"
86 if lit-filters != [ ] then lib.strings.concatStringsSep "|" lit-filters else null;
89 patchShebangs tools/circt-test
93 find ./test -name '*.mlir' -exec sed -i 's|/usr/bin/env|${coreutils}/bin/env|g' {} \;
94 # circt uses git to check its version, but when cloned on nix it can't access git.
95 # So this hard codes the version.
96 substituteInPlace cmake/modules/GenVersionFile.cmake \
97 --replace-fail "unknown git version" "${src.rev}"
98 # Increase timeout on tests because some were failing on hydra.
99 # Using `replace-warn` so it doesn't break when upstream changes the timeout.
100 substituteInPlace integration_test/CMakeLists.txt \
101 --replace-warn 'set(CIRCT_INTEGRATION_TIMEOUT 60)' 'set(CIRCT_INTEGRATION_TIMEOUT 300)'
105 checkTarget = "check-circt check-circt-integration";
107 preCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
108 echo moving libarc-jit-env.dylib to '$lib' before check because archilator links to the output path
110 cp -v ./lib/libarc-jit-env.dylib $lib/lib
119 # Copy circt-llvm's postFixup stage so that it can make all our dylib references
122 # We don't need `postPatch` because circt seems to be automatically inheriting
123 # the config somehow, presumably via. `-DMLIR_DIR`.
124 postFixup = circt-llvm.postFixup;
127 moveToOutput lib "$lib"
131 updateScript = gitUpdater {
132 rev-prefix = "firtool-";
138 description = "Circuit IR compilers and tools";
139 homepage = "https://circt.org/";
140 license = lib.licenses.asl20;
141 maintainers = with lib.maintainers; [
146 platforms = lib.platforms.all;