diff options
Diffstat (limited to 'pkgs/development/compilers/circt')
-rw-r--r-- | pkgs/development/compilers/circt/circt-llvm.nix | 94 | ||||
-rw-r--r-- | pkgs/development/compilers/circt/default.nix | 95 |
2 files changed, 0 insertions, 189 deletions
diff --git a/pkgs/development/compilers/circt/circt-llvm.nix b/pkgs/development/compilers/circt/circt-llvm.nix deleted file mode 100644 index 0043702fd847..000000000000 --- a/pkgs/development/compilers/circt/circt-llvm.nix +++ /dev/null @@ -1,94 +0,0 @@ -{ lib -, stdenv -, cmake -, ninja -, circt -, llvm -, python3 -}: stdenv.mkDerivation { - pname = circt.pname + "-llvm"; - inherit (circt) version src; - - requiredSystemFeatures = [ "big-parallel" ]; - - nativeBuildInputs = [ cmake ninja python3 ]; - - preConfigure = '' - cd llvm/llvm - ''; - - cmakeFlags = [ - "-DBUILD_SHARED_LIBS=ON" - "-DLLVM_ENABLE_BINDINGS=OFF" - "-DLLVM_ENABLE_OCAMLDOC=OFF" - "-DLLVM_BUILD_EXAMPLES=OFF" - "-DLLVM_OPTIMIZED_TABLEGEN=ON" - "-DLLVM_ENABLE_PROJECTS=mlir" - "-DLLVM_TARGETS_TO_BUILD=Native" - - # This option is needed to install llvm-config - "-DLLVM_INSTALL_UTILS=ON" - ]; - - outputs = [ "out" "lib" "dev" ]; - - # Get rid of ${extra_libdir} (which ends up containing a path to circt-llvm.dev - # in circt) so that we only have to remove the one fixed rpath. - postPatch = lib.optionalString stdenv.isDarwin '' - substituteInPlace llvm/llvm/cmake/modules/AddLLVM.cmake \ - --replace-fail 'set(_install_rpath "@loader_path/../lib''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' \ - 'set(_install_rpath "@loader_path/../lib''${LLVM_LIBDIR_SUFFIX}")' - ''; - - postInstall = '' - # move llvm-config to $dev to resolve a circular dependency - moveToOutput "bin/llvm-config*" "$dev" - - # move all lib files to $lib except lib/cmake - moveToOutput "lib" "$lib" - moveToOutput "lib/cmake" "$dev" - - # patch configuration files so each path points to the new $lib or $dev paths - substituteInPlace "$dev/lib/cmake/llvm/LLVMConfig.cmake" \ - --replace 'set(LLVM_BINARY_DIR "''${LLVM_INSTALL_PREFIX}")' 'set(LLVM_BINARY_DIR "'"$lib"'")' - substituteInPlace \ - "$dev/lib/cmake/llvm/LLVMExports-release.cmake" \ - "$dev/lib/cmake/mlir/MLIRTargets-release.cmake" \ - --replace "\''${_IMPORT_PREFIX}/lib/lib" "$lib/lib/lib" \ - --replace "\''${_IMPORT_PREFIX}/lib/objects-Release" "$lib/lib/objects-Release" \ - --replace "$out/bin/llvm-config" "$dev/bin/llvm-config" # patch path for llvm-config - ''; - - # Replace all references to @rpath with absolute paths and remove the rpaths. - # - # This is different from what the regular LLVM package does, which is to make - # everything absolute from the start: however, that doesn't work for us because - # we have `-DBUILD_SHARED_LIBS=ON`, meaning that many more things are - # dynamically rather than statically linked. This includes TableGen, which then - # fails to run halfway through the build because it tries to reference $lib when - # it hasn't been populated yet. - # - # Inspired by fixDarwinDylibNames. - postFixup = lib.optionalString stdenv.isDarwin '' - local flags=(-delete_rpath @loader_path/../lib) - for file in "$lib"/lib/*.dylib; do - flags+=(-change @rpath/"$(basename "$file")" "$file") - done - - for file in "$out"/bin/* "$lib"/lib/*.dylib; do - if [ -L "$file" ]; then continue; fi - echo "$file: fixing dylib references" - # note that -id does nothing on binaries - install_name_tool -id "$file" "''${flags[@]}" "$file" - done - ''; - - # circt only use the mlir part of llvm, occasionally there are some unrelated failure from llvm, - # disable the llvm check, but keep the circt check enabled. - doCheck = false; - checkTarget = "check-mlir"; - - meta = llvm.meta // { - inherit (circt.meta) maintainers; - }; -} diff --git a/pkgs/development/compilers/circt/default.nix b/pkgs/development/compilers/circt/default.nix deleted file mode 100644 index a893166082d5..000000000000 --- a/pkgs/development/compilers/circt/default.nix +++ /dev/null @@ -1,95 +0,0 @@ -{ stdenv -, lib -, cmake -, coreutils -, python3 -, git -, fetchFromGitHub -, ninja -, lit -, z3 -, gitUpdater -, callPackage -}: - -let - pythonEnv = python3.withPackages (ps: [ ps.psutil ]); - circt-llvm = callPackage ./circt-llvm.nix { }; -in -stdenv.mkDerivation rec { - pname = "circt"; - version = "1.76.0"; - src = fetchFromGitHub { - owner = "llvm"; - repo = "circt"; - rev = "firtool-${version}"; - hash = "sha256-L8ELchwUzweS1gzZ8EfnddZu5xMJIVURViwwtPpxylo="; - fetchSubmodules = true; - }; - - requiredSystemFeatures = [ "big-parallel" ]; - - nativeBuildInputs = [ cmake ninja git pythonEnv z3 ]; - buildInputs = [ circt-llvm ]; - - 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" - "-DCIRCT_LLHD_SIM_ENABLED=OFF" - ]; - - # 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; - - preConfigure = '' - 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}" - ''; - - doCheck = true; - checkTarget = "check-circt check-circt-integration"; - - outputs = [ "out" "lib" "dev" ]; - - # Copy circt-llvm's postFixup stage so that it can make all our dylib references - # absolute as well. - # - # We don't need `postPatch` because circt seems to be automatically inheriting - # the config somehow, presumably via. `-DMLIR_DIR`. - postFixup = circt-llvm.postFixup; - - postInstall = '' - moveToOutput lib "$lib" - ''; - - passthru = { - updateScript = gitUpdater { - rev-prefix = "firtool-"; - }; - llvm = circt-llvm; - }; - - meta = { - description = "Circuit IR compilers and tools"; - homepage = "https://circt.org/"; - license = lib.licenses.asl20; - maintainers = with lib.maintainers; [ sharzy pineapplehunter ]; - platforms = lib.platforms.all; - }; -} |