nixpkgs/pkgs/development/rocm-modules/6/llvm/stage-3/mlir.nix
Martin Schwaighofer e380b53037 rocmPackages.llvm: compress outputs of clang-offload-bundler
This patches the clang-offload-bundler tool to add a compression option
from a more recent version of clang.
This compression option reduces the size of ROCm's fat binaries.
Those binaries contain .hip_fatbin sections with GPU-specific code,
for each target.
Compression is automatically turned on for all produced outputs
via a wrapper, because it's difficult to identify all the places
where the -compression argument would be needed.

Once upsteam introduces handeling for this argument,
we should drop the wrapper again.
This transistion will create inconsistsency, but I do not think that
it will impact any actual users and it's what's practical to implement.
2024-04-07 17:09:56 +02:00

62 lines
1.5 KiB
Nix

{ stdenv
, callPackage
, rocmUpdateScript
, clr
, vulkan-headers
, vulkan-loader
, glslang
, shaderc
, lit
, fetchpatch
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildDocs = false; # No decent way to hack this to work
buildMan = false; # No man pages to build
targetName = "mlir";
targetDir = targetName;
# Fix `DebugTranslation.cpp:139:10: error: no matching function for call to 'get'`
extraPatches = [
(fetchpatch {
url = "https://github.com/ROCm/llvm-project/commit/f1d1e10ec7e1061bf0b90abbc1e298d9438a5e74.patch";
hash = "sha256-3c91A9InMKxm+JcnWxoUeOU68y5I6w1AAXx6T9UByqI=";
})
];
extraNativeBuildInputs = [ clr ];
extraBuildInputs = [
vulkan-headers
vulkan-loader
glslang
shaderc
];
extraCMakeFlags = [
"-DMLIR_INCLUDE_DOCS=ON"
"-DMLIR_INCLUDE_TESTS=ON"
"-DMLIR_ENABLE_ROCM_RUNNER=ON"
"-DMLIR_ENABLE_SPIRV_CPU_RUNNER=ON"
"-DMLIR_ENABLE_VULKAN_RUNNER=ON"
"-DROCM_TEST_CHIPSET=gfx000" # CPU runner
];
extraPostPatch = ''
# `add_library cannot create target "llvm_gtest" because an imported target with the same name already exists`
substituteInPlace CMakeLists.txt \
--replace "EXISTS \''${UNITTEST_DIR}/googletest/include/gtest/gtest.h" "FALSE"
# Mainly `No such file or directory`
cat ${./1001-mlir-failing-tests.list} | xargs -d \\n rm
'';
extraPostInstall = ''
mkdir -p $out/bin
mv bin/mlir-tblgen $out/bin
'';
checkTargets = [ "check-${targetName}" ];
requiredSystemFeatures = [ "big-parallel" ];
}