nixpkgs/pkgs/development/compilers/circt/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

88 lines
2.6 KiB
Nix
Raw Normal View History

2023-02-05 17:32:18 +00:00
{ stdenv
, lib
, cmake
, coreutils
, python3
, git
, fetchFromGitHub
, ninja
, lit
2023-09-09 05:47:05 +00:00
, gitUpdater
, callPackage
2023-02-05 17:32:18 +00:00
}:
let
pythonEnv = python3.withPackages (ps: [ ps.psutil ]);
circt-llvm = callPackage ./circt-llvm.nix { };
2023-02-05 17:32:18 +00:00
in
stdenv.mkDerivation rec {
pname = "circt";
2024-04-08 09:27:11 +00:00
version = "1.72.0";
2023-02-05 17:32:18 +00:00
src = fetchFromGitHub {
owner = "llvm";
repo = "circt";
rev = "firtool-${version}";
2024-04-08 09:27:11 +00:00
hash = "sha256-Jy+/nwb1CkbNjS0mZ244hG0Rzb/2QRYXrlki4yWZ1lk=";
2023-02-05 17:32:18 +00:00
fetchSubmodules = true;
};
requiredSystemFeatures = [ "big-parallel" ];
nativeBuildInputs = [ cmake ninja git pythonEnv ];
buildInputs = [ circt-llvm ];
2023-02-05 17:32:18 +00:00
cmakeFlags = [
"-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"
2023-02-05 17:32:18 +00:00
"-DCIRCT_LLHD_SIM_ENABLED=OFF"
];
2023-02-06 14:59:48 +00:00
# There are some tests depending on `clang-tools` to work. They are activated only when detected
# `clang-tidy` in PATH, However, we cannot simply put `clang-tools` in checkInputs to make these
# tests work. Because
#
# 1. The absolute paths of binaries used in tests are resolved in configure phase.
# 2. When stdenv = clangStdenv, the `clang-tidy` binary appears in PATH via `clang-unwrapped`,
# which is always placed before `${clang-tools}/bin` in PATH. `clang-tidy` provided in
# `clang-unwrapped` cause tests failing because it is not wrapped to resolve header search paths.
# https://github.com/NixOS/nixpkgs/issues/214945 discusses this issue.
#
# As a temporary fix, we disabled these tests when using clang stdenv
# cannot use lib.optionalString as it creates an empty string, disabling all tests
LIT_FILTER_OUT = if stdenv.cc.isClang then "CIRCT :: Target/ExportSystemC/.*\.mlir" else null;
2023-02-06 14:59:48 +00:00
2023-02-05 17:32:18 +00:00
preConfigure = ''
2023-07-05 10:04:06 +00:00
find ./test -name '*.mlir' -exec sed -i 's|/usr/bin/env|${coreutils}/bin/env|g' {} \;
# circt uses git to check its version, but when cloned on nix it can't access git.
# So this hard codes the version.
substituteInPlace cmake/modules/GenVersionFile.cmake --replace "unknown git version" "${src.rev}"
2023-02-05 17:32:18 +00:00
'';
doCheck = true;
checkTarget = "check-circt check-circt-integration";
outputs = [ "out" "lib" "dev" ];
postInstall = ''
moveToOutput lib "$lib"
'';
passthru = {
updateScript = gitUpdater {
rev-prefix = "firtool-";
};
llvm = circt-llvm;
2023-09-09 05:47:05 +00:00
};
2023-02-05 17:32:18 +00:00
meta = {
description = "Circuit IR compilers and tools";
homepage = "https://circt.org/";
license = lib.licenses.asl20;
2023-09-22 17:49:41 +00:00
maintainers = with lib.maintainers; [ sharzy pineapplehunter ];
2023-02-05 17:32:18 +00:00
platforms = lib.platforms.all;
};
}