1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-17 19:21:04 +00:00

llvmPackages_rocm -> rocmPackages.llvm

This commit is contained in:
Madoura 2023-10-01 19:36:12 -05:00
parent 41ab671930
commit 12e7fc6923
No known key found for this signature in database
GPG key ID: 1B9BB76A2B71922D
30 changed files with 807 additions and 685 deletions

View file

@ -1,18 +0,0 @@
diff --git a/libomptarget/plugins/amdgpu/impl/impl.cpp b/libomptarget/plugins/amdgpu/impl/impl.cpp
index 80e024789..3a14e0889 100644
--- a/libomptarget/plugins/amdgpu/impl/impl.cpp
+++ b/libomptarget/plugins/amdgpu/impl/impl.cpp
@@ -21,10 +21,11 @@ bool is_locked(void *ptr, hsa_status_t *err_p, void **agentBaseAddress) {
info.size = sizeof(hsa_amd_pointer_info_t);
err = hsa_amd_pointer_info(ptr, &info, nullptr, nullptr, nullptr);
- if (err != HSA_STATUS_SUCCESS)
+ if (err != HSA_STATUS_SUCCESS) {
DP("Error when getting pointer info\n");
- else
+ } else {
is_locked = (info.type == HSA_EXT_POINTER_TYPE_LOCKED);
+ }
if (is_locked && agentBaseAddress != nullptr) {
// When user passes in a basePtr+offset we need to fix the

View file

@ -1,644 +0,0 @@
{ lib
, stdenv
, callPackage
, overrideCC
, wrapCCWith
, wrapBintoolsWith
, runCommand
, lit
, glibc
, spirv-llvm-translator
, xz
, swig
, lua5_3
, gtest
, hip
, rocm-comgr
, vulkan-loader
, vulkan-headers
, glslang
, shaderc
, perl
, rocm-device-libs
, rocm-runtime
, elfutils
, graphviz
, python3Packages
}:
let
# Stage 1
# Base
llvm = callPackage ./llvm.nix {
requiredSystemFeatures = [ "big-parallel" ];
isBroken = stdenv.isAarch64; # https://github.com/RadeonOpenCompute/ROCm/issues/1831#issuecomment-1278205344
};
# Projects
clang-unwrapped = callPackage ./llvm.nix rec {
targetName = "clang";
targetDir = targetName;
extraBuildInputs = [ llvm ];
extraCMakeFlags = [
"-DCLANG_INCLUDE_DOCS=ON"
"-DCLANG_INCLUDE_TESTS=ON"
];
extraPostPatch = ''
# Looks like they forgot to add finding libedit to the standalone build
ln -s ../cmake/Modules/FindLibEdit.cmake cmake/modules
substituteInPlace CMakeLists.txt \
--replace "include(CheckIncludeFile)" "include(CheckIncludeFile)''\nfind_package(LibEdit)"
# `No such file or directory: '/build/source/clang/tools/scan-build/bin/scan-build'`
rm test/Analysis/scan-build/*.test
rm test/Analysis/scan-build/rebuild_index/rebuild_index.test
# `does not depend on a module exporting 'baz.h'`
rm test/Modules/header-attribs.cpp
# We do not have HIP or the ROCm stack available yet
rm test/Driver/hip-options.hip
# ???? `ld: cannot find crti.o: No such file or directory` linker issue?
rm test/Interpreter/dynamic-library.cpp
# `fatal error: 'stdio.h' file not found`
rm test/OpenMP/amdgcn_emit_llvm.c
'';
extraPostInstall = ''
mv bin/clang-tblgen $out/bin
'';
requiredSystemFeatures = [ "big-parallel" ];
};
lld = callPackage ./llvm.nix rec {
buildMan = false; # No man pages to build
targetName = "lld";
targetDir = targetName;
extraBuildInputs = [ llvm ];
checkTargets = [ "check-${targetName}" ];
};
# Runtimes
runtimes = callPackage ./llvm.nix rec {
buildDocs = false;
buildMan = false;
buildTests = false;
targetName = "runtimes";
targetDir = targetName;
targetRuntimes = [
"libunwind"
"libcxxabi"
"libcxx"
"compiler-rt"
];
extraBuildInputs = [ llvm ];
extraCMakeFlags = [
"-DLIBCXX_INCLUDE_BENCHMARKS=OFF"
"-DLIBCXX_CXX_ABI=libcxxabi"
];
extraLicenses = [ lib.licenses.mit ];
};
# Stage 2
# Helpers
rStdenv = overrideCC stdenv (wrapCCWith rec {
inherit bintools;
libcxx = runtimes;
cc = clang-unwrapped;
extraPackages = [
llvm
lld
];
nixSupport.cc-cflags = [
"-resource-dir=$out/resource-root"
"-fuse-ld=lld"
"-rtlib=compiler-rt"
"-unwindlib=libunwind"
"-Wno-unused-command-line-argument"
];
extraBuildCommands = ''
clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
mkdir -p $out/resource-root
ln -s ${cc}/lib/clang/$clang_version/include $out/resource-root
ln -s ${runtimes}/lib $out/resource-root
'';
});
bintools = wrapBintoolsWith { bintools = bintools-unwrapped; };
bintools-unwrapped = runCommand "rocm-llvm-binutils-${llvm.version}" { preferLocalBuild = true; } ''
mkdir -p $out/bin
for prog in ${lld}/bin/*; do
ln -s $prog $out/bin/$(basename $prog)
done
for prog in ${llvm}/bin/*; do
ln -sf $prog $out/bin/$(basename $prog)
done
ln -s ${llvm}/bin/llvm-ar $out/bin/ar
ln -s ${llvm}/bin/llvm-as $out/bin/as
ln -s ${llvm}/bin/llvm-dwp $out/bin/dwp
ln -s ${llvm}/bin/llvm-nm $out/bin/nm
ln -s ${llvm}/bin/llvm-objcopy $out/bin/objcopy
ln -s ${llvm}/bin/llvm-objdump $out/bin/objdump
ln -s ${llvm}/bin/llvm-ranlib $out/bin/ranlib
ln -s ${llvm}/bin/llvm-readelf $out/bin/readelf
ln -s ${llvm}/bin/llvm-size $out/bin/size
ln -s ${llvm}/bin/llvm-strip $out/bin/strip
ln -s ${lld}/bin/lld $out/bin/ld
'';
in rec {
inherit
llvm
clang-unwrapped
lld
bintools
bintools-unwrapped;
# Runtimes
libc = callPackage ./llvm.nix rec {
stdenv = rStdenv;
buildMan = false; # No man pages to build
targetName = "libc";
targetDir = "runtimes";
targetRuntimes = [ targetName ];
extraPostPatch = ''
# `Failed to match ... against ...` `Match value not within tolerance value of MPFR result:`
# We need a better way, but I don't know enough sed magic and patching `CMakeLists.txt` isn't working...
substituteInPlace ../libc/test/src/math/log10_test.cpp \
--replace "i < N" "i < 0" \
--replace "test(mpfr::RoundingMode::Nearest);" "" \
--replace "test(mpfr::RoundingMode::Downward);" "" \
--replace "test(mpfr::RoundingMode::Upward);" "" \
--replace "test(mpfr::RoundingMode::TowardZero);" ""
'';
checkTargets = [ "check-${targetName}" ];
hardeningDisable = [ "fortify" ]; # Prevent `error: "Assumed value of MB_LEN_MAX wrong"`
};
libunwind = callPackage ./llvm.nix rec {
stdenv = rStdenv;
buildMan = false; # No man pages to build
targetName = "libunwind";
targetDir = "runtimes";
targetRuntimes = [ targetName ];
extraCMakeFlags = [
"-DLIBUNWIND_INCLUDE_DOCS=ON"
"-DLIBUNWIND_INCLUDE_TESTS=ON"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
];
extraPostPatch = ''
# `command had no output on stdout or stderr` (Says these unsupported tests)
chmod +w -R ../libunwind/test
rm ../libunwind/test/floatregister.pass.cpp
rm ../libunwind/test/unwind_leaffunction.pass.cpp
rm ../libunwind/test/libunwind_02.pass.cpp
'';
};
libcxxabi = callPackage ./llvm.nix rec {
stdenv = rStdenv;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
targetName = "libcxxabi";
targetDir = "runtimes";
targetRuntimes = [
"libunwind"
targetName
"libcxx"
];
extraCMakeFlags = [
"-DLIBCXXABI_INCLUDE_TESTS=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
"-DLIBCXXABI_USE_COMPILER_RT=ON"
# Workaround having to build combined
"-DLIBUNWIND_INCLUDE_DOCS=OFF"
"-DLIBUNWIND_INCLUDE_TESTS=OFF"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
"-DLIBUNWIND_INSTALL_LIBRARY=OFF"
"-DLIBUNWIND_INSTALL_HEADERS=OFF"
"-DLIBCXX_INCLUDE_DOCS=OFF"
"-DLIBCXX_INCLUDE_TESTS=OFF"
"-DLIBCXX_USE_COMPILER_RT=ON"
"-DLIBCXX_CXX_ABI=libcxxabi"
"-DLIBCXX_INSTALL_LIBRARY=OFF"
"-DLIBCXX_INSTALL_HEADERS=OFF"
];
};
libcxx = callPackage ./llvm.nix rec {
stdenv = rStdenv;
buildMan = false; # No man pages to build
targetName = "libcxx";
targetDir = "runtimes";
targetRuntimes = [
"libunwind"
"libcxxabi"
targetName
];
extraCMakeFlags = [
"-DLIBCXX_INCLUDE_DOCS=ON"
"-DLIBCXX_INCLUDE_TESTS=ON"
"-DLIBCXX_USE_COMPILER_RT=ON"
"-DLIBCXX_CXX_ABI=libcxxabi"
# Workaround having to build combined
"-DLIBUNWIND_INCLUDE_DOCS=OFF"
"-DLIBUNWIND_INCLUDE_TESTS=OFF"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
"-DLIBUNWIND_INSTALL_LIBRARY=OFF"
"-DLIBUNWIND_INSTALL_HEADERS=OFF"
"-DLIBCXXABI_INCLUDE_TESTS=OFF"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
"-DLIBCXXABI_USE_COMPILER_RT=ON"
"-DLIBCXXABI_INSTALL_LIBRARY=OFF"
"-DLIBCXXABI_INSTALL_HEADERS=OFF"
];
# Most of these can't find `bash` or `mkdir`, might just be hard-coded paths, or PATH is altered
extraPostPatch = ''
chmod +w -R ../libcxx/test/{libcxx,std}
cat ${./1000-libcxx-failing-tests.list} | xargs -d \\n rm
'';
};
compiler-rt = callPackage ./llvm.nix rec {
stdenv = rStdenv;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
targetName = "compiler-rt";
targetDir = "runtimes";
targetRuntimes = [
"libunwind"
"libcxxabi"
"libcxx"
targetName
];
extraCMakeFlags = [
"-DCOMPILER_RT_INCLUDE_TESTS=ON"
"-DCOMPILER_RT_USE_LLVM_UNWINDER=ON"
"-DCOMPILER_RT_CXX_LIBRARY=libcxx"
"-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF" # We can't run most of these
# Workaround having to build combined
"-DLIBUNWIND_INCLUDE_DOCS=OFF"
"-DLIBUNWIND_INCLUDE_TESTS=OFF"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
"-DLIBUNWIND_INSTALL_LIBRARY=OFF"
"-DLIBUNWIND_INSTALL_HEADERS=OFF"
"-DLIBCXXABI_INCLUDE_TESTS=OFF"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
"-DLIBCXXABI_USE_COMPILER_RT=ON"
"-DLIBCXXABI_INSTALL_LIBRARY=OFF"
"-DLIBCXXABI_INSTALL_HEADERS=OFF"
"-DLIBCXX_INCLUDE_DOCS=OFF"
"-DLIBCXX_INCLUDE_TESTS=OFF"
"-DLIBCXX_USE_COMPILER_RT=ON"
"-DLIBCXX_CXX_ABI=libcxxabi"
"-DLIBCXX_INSTALL_LIBRARY=OFF"
"-DLIBCXX_INSTALL_HEADERS=OFF"
];
extraPostPatch = ''
# `No such file or directory: 'ldd'`
substituteInPlace ../compiler-rt/test/lit.common.cfg.py \
--replace "'ldd'," "'${glibc.bin}/bin/ldd',"
# We can run these
substituteInPlace ../compiler-rt/test/CMakeLists.txt \
--replace "endfunction()" "endfunction()''\nadd_subdirectory(builtins)''\nadd_subdirectory(shadowcallstack)"
# Could not launch llvm-config in /build/source/runtimes/build/bin
mkdir -p build/bin
ln -s ${llvm}/bin/llvm-config build/bin
'';
extraLicenses = [ lib.licenses.mit ];
};
# Stage 3
# Helpers
rocmClangStdenv = overrideCC stdenv clang;
clang = wrapCCWith rec {
inherit libcxx bintools;
# We do this to avoid HIP pathing problems, and mimic a monolithic install
cc = stdenv.mkDerivation (finalAttrs: {
inherit (clang-unwrapped) pname version;
dontUnpack = true;
installPhase = ''
runHook preInstall
clang_version=`${clang-unwrapped}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
mkdir -p $out/{bin,include/c++/v1,lib/{cmake,clang/$clang_version/{include,lib}},libexec,share}
for path in ${llvm} ${clang-unwrapped} ${lld} ${libc} ${libunwind} ${libcxxabi} ${libcxx} ${compiler-rt}; do
cp -as $path/* $out
chmod +w $out/{*,include/c++/v1,lib/{clang/$clang_version/include,cmake}}
rm -f $out/lib/libc++.so
done
ln -s $out/lib/* $out/lib/clang/$clang_version/lib
ln -sf $out/include/* $out/lib/clang/$clang_version/include
runHook postInstall
'';
passthru.isClang = true;
});
extraPackages = [
llvm
lld
libc
libunwind
libcxxabi
compiler-rt
];
nixSupport.cc-cflags = [
"-resource-dir=$out/resource-root"
"-fuse-ld=lld"
"-rtlib=compiler-rt"
"-unwindlib=libunwind"
"-Wno-unused-command-line-argument"
];
extraBuildCommands = ''
clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
mkdir -p $out/resource-root
ln -s ${cc}/lib/clang/$clang_version/{include,lib} $out/resource-root
# Not sure why, but hardening seems to make things break
echo "" > $out/nix-support/add-hardening.sh
# GPU compilation uses builtin `lld`
substituteInPlace $out/bin/{clang,clang++} \
--replace "-MM) dontLink=1 ;;" "-MM | --cuda-device-only) dontLink=1 ;;''\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;"
'';
};
# Base
# Unfortunately, we cannot build `clang-tools-extra` separately.
clang-tools-extra = callPackage ./llvm.nix {
stdenv = rocmClangStdenv;
buildTests = false; # `invalid operands to binary expression ('std::basic_stringstream<char>' and 'const llvm::StringRef')`
targetName = "clang-tools-extra";
targetProjects = [
"clang"
"clang-tools-extra"
];
extraBuildInputs = [ gtest ];
extraCMakeFlags = [
"-DLLVM_INCLUDE_DOCS=OFF"
"-DLLVM_INCLUDE_TESTS=OFF"
"-DCLANG_INCLUDE_DOCS=OFF"
"-DCLANG_INCLUDE_TESTS=ON"
"-DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=ON"
];
extraPostInstall = ''
# Remove LLVM and Clang
for path in `find ${llvm} ${clang-unwrapped}`; do
if [ $path != ${llvm} ] && [ $path != ${clang-unwrapped} ]; then
rm -f $out''${path#${llvm}} $out''${path#${clang-unwrapped}} || true
fi
done
# Cleanup empty directories
find $out -type d -empty -delete
'';
requiredSystemFeatures = [ "big-parallel" ];
};
# Projects
libclc = let
spirv = (spirv-llvm-translator.override { inherit llvm; });
in callPackage ./llvm.nix rec {
stdenv = rocmClangStdenv;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
targetName = "libclc";
targetDir = targetName;
extraBuildInputs = [ spirv ];
# `spirv-mesa3d` isn't compiling with LLVM 15.0.0, it does with LLVM 14.0.0
# Try removing the `spirv-mesa3d` and `clspv` patches next update
# `clspv` tests fail, unresolved calls
extraPostPatch = ''
substituteInPlace CMakeLists.txt \
--replace "find_program( LLVM_CLANG clang PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
"find_program( LLVM_CLANG clang PATHS \"${clang}/bin\" NO_DEFAULT_PATH )" \
--replace "find_program( LLVM_SPIRV llvm-spirv PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
"find_program( LLVM_SPIRV llvm-spirv PATHS \"${spirv}/bin\" NO_DEFAULT_PATH )" \
--replace " spirv-mesa3d-" "" \
--replace " spirv64-mesa3d-" "" \
--replace "NOT \''${t} MATCHES" \
"NOT \''${ARCH} STREQUAL \"clspv\" AND NOT \''${ARCH} STREQUAL \"clspv64\" AND NOT \''${t} MATCHES"
'';
checkTargets = [ ];
isBroken = true; # ROCm 5.7.0 doesn't have IR/AttributeMask.h yet...?
};
lldb = callPackage ./llvm.nix rec {
stdenv = rocmClangStdenv;
buildTests = false; # FIXME: Bad pathing for clang executable in tests, using relative path most likely
targetName = "lldb";
targetDir = targetName;
extraNativeBuildInputs = [ python3Packages.sphinx-automodapi ];
extraBuildInputs = [
xz
swig
lua5_3
gtest
graphviz
];
extraCMakeFlags = [
"-DLLDB_EXTERNAL_CLANG_RESOURCE_DIR=${clang}/resource-root/lib/clang/$clang_version"
"-DLLDB_INCLUDE_TESTS=ON"
"-DLLDB_INCLUDE_UNITTESTS=ON"
];
extraPostPatch = ''
export clang_version=`clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
'';
checkTargets = [ "check-${targetName}" ];
};
mlir = callPackage ./llvm.nix rec {
stdenv = rocmClangStdenv;
buildDocs = false; # No decent way to hack this to work
buildMan = false; # No man pages to build
targetName = "mlir";
targetDir = targetName;
extraNativeBuildInputs = [ hip ];
extraBuildInputs = [
rocm-comgr
vulkan-headers
vulkan-loader
glslang
shaderc
];
extraCMakeFlags = [
"-DCMAKE_POLICY_DEFAULT_CMP0116=NEW"
"-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 = ''
chmod +w ../llvm
mkdir -p ../llvm/build/bin
ln -s ${lit}/bin/lit ../llvm/build/bin/llvm-lit
substituteInPlace test/CMakeLists.txt \
--replace "FileCheck count not" "" \
--replace "list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)" ""
substituteInPlace lib/ExecutionEngine/CMakeLists.txt \
--replace "return()" ""
# Remove problematic tests
rm test/CAPI/execution_engine.c
rm test/Target/LLVMIR/llvmir-intrinsics.mlir
rm test/Target/LLVMIR/llvmir.mlir
rm test/Target/LLVMIR/openmp-llvm.mlir
rm test/mlir-cpu-runner/*.mlir
rm test/mlir-vulkan-runner/*.mlir
'';
extraPostInstall = ''
mkdir -p $out/bin
mv bin/mlir-tblgen $out/bin
'';
checkTargets = [ "check-${targetName}" ];
requiredSystemFeatures = [ "big-parallel" ];
};
polly = callPackage ./llvm.nix rec {
stdenv = rocmClangStdenv;
targetName = "polly";
targetDir = targetName;
extraPostPatch = ''
# `add_library cannot create target "llvm_gtest" because an imported target with the same name already exists`
substituteInPlace CMakeLists.txt \
--replace "NOT TARGET gtest" "FALSE"
'';
checkTargets = [ "check-${targetName}" ];
};
flang = callPackage ./llvm.nix rec {
stdenv = rocmClangStdenv;
buildTests = false; # `Executable "flang1" doesn't exist!`
targetName = "flang";
targetDir = targetName;
extraNativeBuildInputs = [ python3Packages.sphinx-markdown-tables ];
extraBuildInputs = [ mlir ];
extraCMakeFlags = [
"-DCMAKE_POLICY_DEFAULT_CMP0116=NEW"
"-DCLANG_DIR=${clang-unwrapped}/lib/cmake/clang"
"-DFLANG_INCLUDE_TESTS=OFF"
"-DMLIR_TABLEGEN_EXE=${mlir}/bin/mlir-tblgen"
];
extraPostPatch = ''
substituteInPlace test/CMakeLists.txt \
--replace "FileCheck" "" \
--replace "count" "" \
--replace "not" ""
substituteInPlace docs/CMakeLists.txt \
--replace "CLANG_TABLEGEN_EXE clang-tblgen" "CLANG_TABLEGEN_EXE ${clang-unwrapped}/bin/clang-tblgen"
'';
};
openmp = callPackage ./llvm.nix rec {
stdenv = rocmClangStdenv;
buildTests = false; # Too many failures, most pass
targetName = "openmp";
targetDir = targetName;
extraPatches = [ ./0000-fix-openmp.patch ];
extraNativeBuildInputs = [ perl ];
extraBuildInputs = [
rocm-device-libs
rocm-runtime
elfutils
];
extraCMakeFlags = [
"-DCMAKE_MODULE_PATH=/build/source/llvm/cmake/modules" # For docs
"-DCLANG_TOOL=${clang}/bin/clang"
"-DCLANG_OFFLOAD_BUNDLER_TOOL=${clang-unwrapped}/bin/clang-offload-bundler"
"-DOPENMP_LLVM_TOOLS_DIR=${llvm}/bin"
"-DOPENMP_LLVM_LIT_EXECUTABLE=${lit}/bin/.lit-wrapped"
"-DDEVICELIBS_ROOT=${rocm-device-libs.src}"
];
extraPostPatch = ''
# We can't build this target at the moment
substituteInPlace libomptarget/DeviceRTL/CMakeLists.txt \
--replace "gfx1010" ""
'';
checkTargets = [ "check-${targetName}" ];
extraLicenses = [ lib.licenses.mit ];
};
# Runtimes
pstl = callPackage ./llvm.nix rec {
stdenv = rocmClangStdenv;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
buildTests = false; # Too many errors
targetName = "pstl";
targetDir = "runtimes";
targetRuntimes = [ targetName ];
checkTargets = [ "check-${targetName}" ];
};
}

View file

@ -0,0 +1,9 @@
{ callPackage
, recurseIntoAttrs
}:
let
rocmUpdateScript = callPackage ./update.nix { };
in {
llvm = recurseIntoAttrs (callPackage ./llvm/default.nix { inherit rocmUpdateScript; });
}

View file

@ -0,0 +1,53 @@
{ stdenv
, callPackage
, rocmUpdateScript
, wrapBintoolsWith
, overrideCC
}:
let
## Stage 1 ##
# Projects
llvm = callPackage ./stage-1/llvm.nix { inherit rocmUpdateScript; };
clang-unwrapped = callPackage ./stage-1/clang-unwrapped.nix { inherit rocmUpdateScript llvm; };
lld = callPackage ./stage-1/lld.nix { inherit rocmUpdateScript llvm; };
# Runtimes
runtimes = callPackage ./stage-1/runtimes.nix { inherit rocmUpdateScript llvm; };
## Stage 2 ##
# Helpers
bintools-unwrapped = callPackage ./stage-2/bintools-unwrapped.nix { inherit llvm lld; };
bintools = wrapBintoolsWith { bintools = bintools-unwrapped; };
rStdenv = callPackage ./stage-2/rstdenv.nix { inherit llvm clang-unwrapped lld runtimes bintools; };
in rec {
inherit
llvm
clang-unwrapped
lld
bintools;
# Runtimes
libc = callPackage ./stage-2/libc.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
libunwind = callPackage ./stage-2/libunwind.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
libcxxabi = callPackage ./stage-2/libcxxabi.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
libcxx = callPackage ./stage-2/libcxx.nix { inherit rocmUpdateScript; stdenv = rStdenv; };
compiler-rt = callPackage ./stage-2/compiler-rt.nix { inherit rocmUpdateScript llvm; stdenv = rStdenv; };
## Stage 3 ##
# Helpers
clang = callPackage ./stage-3/clang.nix { inherit llvm lld clang-unwrapped bintools libc libunwind libcxxabi libcxx compiler-rt; };
rocmClangStdenv = overrideCC stdenv clang;
# Projects
clang-tools-extra = callPackage ./stage-3/clang-tools-extra.nix { inherit rocmUpdateScript llvm clang-unwrapped; stdenv = rocmClangStdenv; };
libclc = callPackage ./stage-3/libclc.nix { inherit rocmUpdateScript llvm clang; stdenv = rocmClangStdenv; };
lldb = callPackage ./stage-3/lldb.nix { inherit rocmUpdateScript clang; stdenv = rocmClangStdenv; };
mlir = callPackage ./stage-3/mlir.nix { inherit rocmUpdateScript; stdenv = rocmClangStdenv; };
polly = callPackage ./stage-3/polly.nix { inherit rocmUpdateScript; stdenv = rocmClangStdenv; };
flang = callPackage ./stage-3/flang.nix { inherit rocmUpdateScript clang-unwrapped mlir; stdenv = rocmClangStdenv; };
openmp = callPackage ./stage-3/openmp.nix { inherit rocmUpdateScript llvm clang-unwrapped clang; stdenv = rocmClangStdenv; };
# Runtimes
pstl = callPackage ./stage-3/pstl.nix { inherit rocmUpdateScript; stdenv = rocmClangStdenv; };
}

View file

@ -0,0 +1,46 @@
{ callPackage
, rocmUpdateScript
, llvm
}:
callPackage ../base.nix rec {
inherit rocmUpdateScript;
targetName = "clang-unwrapped";
targetDir = "clang";
extraBuildInputs = [ llvm ];
extraCMakeFlags = [
"-DCLANG_INCLUDE_DOCS=ON"
"-DCLANG_INCLUDE_TESTS=ON"
];
extraPostPatch = ''
# Looks like they forgot to add finding libedit to the standalone build
ln -s ../cmake/Modules/FindLibEdit.cmake cmake/modules
substituteInPlace CMakeLists.txt \
--replace "include(CheckIncludeFile)" "include(CheckIncludeFile)''\nfind_package(LibEdit)"
# `No such file or directory: '/build/source/clang/tools/scan-build/bin/scan-build'`
rm test/Analysis/scan-build/*.test
rm test/Analysis/scan-build/rebuild_index/rebuild_index.test
# `does not depend on a module exporting 'baz.h'`
rm test/Modules/header-attribs.cpp
# We do not have HIP or the ROCm stack available yet
rm test/Driver/hip-options.hip
# ???? `ld: cannot find crti.o: No such file or directory` linker issue?
rm test/Interpreter/dynamic-library.cpp
# `fatal error: 'stdio.h' file not found`
rm test/OpenMP/amdgcn_emit_llvm.c
'';
extraPostInstall = ''
mv bin/clang-tblgen $out/bin
'';
requiredSystemFeatures = [ "big-parallel" ];
}

View file

@ -0,0 +1,13 @@
{ callPackage
, rocmUpdateScript
, llvm
}:
callPackage ../base.nix rec {
inherit rocmUpdateScript;
buildMan = false; # No man pages to build
targetName = "lld";
targetDir = targetName;
extraBuildInputs = [ llvm ];
checkTargets = [ "check-${targetName}" ];
}

View file

@ -0,0 +1,10 @@
{ stdenv
, callPackage
, rocmUpdateScript
}:
callPackage ../base.nix {
inherit rocmUpdateScript;
requiredSystemFeatures = [ "big-parallel" ];
isBroken = stdenv.isAarch64; # https://github.com/RadeonOpenCompute/ROCm/issues/1831#issuecomment-1278205344
}

View file

@ -0,0 +1,30 @@
{ lib
, callPackage
, rocmUpdateScript
, llvm
}:
callPackage ../base.nix rec {
inherit rocmUpdateScript;
buildDocs = false;
buildMan = false;
buildTests = false;
targetName = "runtimes";
targetDir = targetName;
targetRuntimes = [
"libunwind"
"libcxxabi"
"libcxx"
"compiler-rt"
];
extraBuildInputs = [ llvm ];
extraCMakeFlags = [
"-DLIBCXX_INCLUDE_BENCHMARKS=OFF"
"-DLIBCXX_CXX_ABI=libcxxabi"
];
extraLicenses = [ lib.licenses.mit ];
}

View file

@ -0,0 +1,28 @@
{ runCommand
, llvm
, lld
}:
runCommand "rocm-llvm-binutils-${llvm.version}" { preferLocalBuild = true; } ''
mkdir -p $out/bin
for prog in ${lld}/bin/*; do
ln -s $prog $out/bin/$(basename $prog)
done
for prog in ${llvm}/bin/*; do
ln -sf $prog $out/bin/$(basename $prog)
done
ln -s ${llvm}/bin/llvm-ar $out/bin/ar
ln -s ${llvm}/bin/llvm-as $out/bin/as
ln -s ${llvm}/bin/llvm-dwp $out/bin/dwp
ln -s ${llvm}/bin/llvm-nm $out/bin/nm
ln -s ${llvm}/bin/llvm-objcopy $out/bin/objcopy
ln -s ${llvm}/bin/llvm-objdump $out/bin/objdump
ln -s ${llvm}/bin/llvm-ranlib $out/bin/ranlib
ln -s ${llvm}/bin/llvm-readelf $out/bin/readelf
ln -s ${llvm}/bin/llvm-size $out/bin/size
ln -s ${llvm}/bin/llvm-strip $out/bin/strip
ln -s ${lld}/bin/lld $out/bin/ld
''

View file

@ -0,0 +1,63 @@
{ lib
, stdenv
, callPackage
, rocmUpdateScript
, llvm
, glibc
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
targetName = "compiler-rt";
targetDir = "runtimes";
targetRuntimes = [
"libunwind"
"libcxxabi"
"libcxx"
targetName
];
extraCMakeFlags = [
"-DCOMPILER_RT_INCLUDE_TESTS=ON"
"-DCOMPILER_RT_USE_LLVM_UNWINDER=ON"
"-DCOMPILER_RT_CXX_LIBRARY=libcxx"
"-DCOMPILER_RT_CAN_EXECUTE_TESTS=OFF" # We can't run most of these
# Workaround having to build combined
"-DLIBUNWIND_INCLUDE_DOCS=OFF"
"-DLIBUNWIND_INCLUDE_TESTS=OFF"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
"-DLIBUNWIND_INSTALL_LIBRARY=OFF"
"-DLIBUNWIND_INSTALL_HEADERS=OFF"
"-DLIBCXXABI_INCLUDE_TESTS=OFF"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
"-DLIBCXXABI_USE_COMPILER_RT=ON"
"-DLIBCXXABI_INSTALL_LIBRARY=OFF"
"-DLIBCXXABI_INSTALL_HEADERS=OFF"
"-DLIBCXX_INCLUDE_DOCS=OFF"
"-DLIBCXX_INCLUDE_TESTS=OFF"
"-DLIBCXX_USE_COMPILER_RT=ON"
"-DLIBCXX_CXX_ABI=libcxxabi"
"-DLIBCXX_INSTALL_LIBRARY=OFF"
"-DLIBCXX_INSTALL_HEADERS=OFF"
];
extraPostPatch = ''
# `No such file or directory: 'ldd'`
substituteInPlace ../compiler-rt/test/lit.common.cfg.py \
--replace "'ldd'," "'${glibc.bin}/bin/ldd',"
# We can run these
substituteInPlace ../compiler-rt/test/CMakeLists.txt \
--replace "endfunction()" "endfunction()''\nadd_subdirectory(builtins)''\nadd_subdirectory(shadowcallstack)"
# Could not launch llvm-config in /build/source/runtimes/build/bin
mkdir -p build/bin
ln -s ${llvm}/bin/llvm-config build/bin
'';
extraLicenses = [ lib.licenses.mit ];
}

View file

@ -0,0 +1,26 @@
{ stdenv
, callPackage
, rocmUpdateScript
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildMan = false; # No man pages to build
targetName = "libc";
targetDir = "runtimes";
targetRuntimes = [ targetName ];
extraPostPatch = ''
# `Failed to match ... against ...` `Match value not within tolerance value of MPFR result:`
# We need a better way, but I don't know enough sed magic and patching `CMakeLists.txt` isn't working...
substituteInPlace ../libc/test/src/math/log10_test.cpp \
--replace "i < N" "i < 0" \
--replace "test(mpfr::RoundingMode::Nearest);" "" \
--replace "test(mpfr::RoundingMode::Downward);" "" \
--replace "test(mpfr::RoundingMode::Upward);" "" \
--replace "test(mpfr::RoundingMode::TowardZero);" ""
'';
checkTargets = [ "check-${targetName}" ];
hardeningDisable = [ "fortify" ]; # Prevent `error: "Assumed value of MB_LEN_MAX wrong"`
}

View file

@ -0,0 +1,42 @@
{ stdenv
, callPackage
, rocmUpdateScript
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildMan = false; # No man pages to build
targetName = "libcxx";
targetDir = "runtimes";
targetRuntimes = [
"libunwind"
"libcxxabi"
targetName
];
extraCMakeFlags = [
"-DLIBCXX_INCLUDE_DOCS=ON"
"-DLIBCXX_INCLUDE_TESTS=ON"
"-DLIBCXX_USE_COMPILER_RT=ON"
"-DLIBCXX_CXX_ABI=libcxxabi"
# Workaround having to build combined
"-DLIBUNWIND_INCLUDE_DOCS=OFF"
"-DLIBUNWIND_INCLUDE_TESTS=OFF"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
"-DLIBUNWIND_INSTALL_LIBRARY=OFF"
"-DLIBUNWIND_INSTALL_HEADERS=OFF"
"-DLIBCXXABI_INCLUDE_TESTS=OFF"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
"-DLIBCXXABI_USE_COMPILER_RT=ON"
"-DLIBCXXABI_INSTALL_LIBRARY=OFF"
"-DLIBCXXABI_INSTALL_HEADERS=OFF"
];
# Most of these can't find `bash` or `mkdir`, might just be hard-coded paths, or PATH is altered
extraPostPatch = ''
chmod +w -R ../libcxx/test/{libcxx,std}
cat ${./1000-libcxx-failing-tests.list} | xargs -d \\n rm
'';
}

View file

@ -0,0 +1,37 @@
{ stdenv
, callPackage
, rocmUpdateScript
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
targetName = "libcxxabi";
targetDir = "runtimes";
targetRuntimes = [
"libunwind"
targetName
"libcxx"
];
extraCMakeFlags = [
"-DLIBCXXABI_INCLUDE_TESTS=ON"
"-DLIBCXXABI_USE_LLVM_UNWINDER=ON"
"-DLIBCXXABI_USE_COMPILER_RT=ON"
# Workaround having to build combined
"-DLIBUNWIND_INCLUDE_DOCS=OFF"
"-DLIBUNWIND_INCLUDE_TESTS=OFF"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
"-DLIBUNWIND_INSTALL_LIBRARY=OFF"
"-DLIBUNWIND_INSTALL_HEADERS=OFF"
"-DLIBCXX_INCLUDE_DOCS=OFF"
"-DLIBCXX_INCLUDE_TESTS=OFF"
"-DLIBCXX_USE_COMPILER_RT=ON"
"-DLIBCXX_CXX_ABI=libcxxabi"
"-DLIBCXX_INSTALL_LIBRARY=OFF"
"-DLIBCXX_INSTALL_HEADERS=OFF"
];
}

View file

@ -0,0 +1,26 @@
{ stdenv
, callPackage
, rocmUpdateScript
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildMan = false; # No man pages to build
targetName = "libunwind";
targetDir = "runtimes";
targetRuntimes = [ targetName ];
extraCMakeFlags = [
"-DLIBUNWIND_INCLUDE_DOCS=ON"
"-DLIBUNWIND_INCLUDE_TESTS=ON"
"-DLIBUNWIND_USE_COMPILER_RT=ON"
];
extraPostPatch = ''
# `command had no output on stdout or stderr` (Says these unsupported tests)
chmod +w -R ../libunwind/test
rm ../libunwind/test/floatregister.pass.cpp
rm ../libunwind/test/unwind_leaffunction.pass.cpp
rm ../libunwind/test/libunwind_02.pass.cpp
'';
}

View file

@ -0,0 +1,35 @@
{ stdenv
, overrideCC
, wrapCCWith
, llvm
, clang-unwrapped
, lld
, runtimes
, bintools
}:
overrideCC stdenv (wrapCCWith rec {
inherit bintools;
libcxx = runtimes;
cc = clang-unwrapped;
extraPackages = [
llvm
lld
];
nixSupport.cc-cflags = [
"-resource-dir=$out/resource-root"
"-fuse-ld=lld"
"-rtlib=compiler-rt"
"-unwindlib=libunwind"
"-Wno-unused-command-line-argument"
];
extraBuildCommands = ''
clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
mkdir -p $out/resource-root
ln -s ${cc}/lib/clang/$clang_version/include $out/resource-root
ln -s ${runtimes}/lib $out/resource-root
'';
})

View file

@ -0,0 +1,42 @@
{ stdenv
, callPackage
, rocmUpdateScript
, llvm
, clang-unwrapped
, gtest
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildTests = false; # `invalid operands to binary expression ('std::basic_stringstream<char>' and 'const llvm::StringRef')`
targetName = "clang-tools-extra";
targetProjects = [
"clang"
"clang-tools-extra"
];
extraBuildInputs = [ gtest ];
extraCMakeFlags = [
"-DLLVM_INCLUDE_DOCS=OFF"
"-DLLVM_INCLUDE_TESTS=OFF"
"-DCLANG_INCLUDE_DOCS=OFF"
"-DCLANG_INCLUDE_TESTS=ON"
"-DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=ON"
];
extraPostInstall = ''
# Remove LLVM and Clang
for path in `find ${llvm} ${clang-unwrapped}`; do
if [ $path != ${llvm} ] && [ $path != ${clang-unwrapped} ]; then
rm -f $out''${path#${llvm}} $out''${path#${clang-unwrapped}} || true
fi
done
# Cleanup empty directories
find $out -type d -empty -delete
'';
requiredSystemFeatures = [ "big-parallel" ];
}

View file

@ -0,0 +1,73 @@
{ stdenv
, wrapCCWith
, llvm
, lld
, clang-unwrapped
, bintools
, libc
, libunwind
, libcxxabi
, libcxx
, compiler-rt
}:
wrapCCWith rec {
inherit libcxx bintools;
# We do this to avoid HIP pathing problems, and mimic a monolithic install
cc = stdenv.mkDerivation (finalAttrs: {
inherit (clang-unwrapped) version;
pname = "rocm-llvm-clang";
dontUnpack = true;
installPhase = ''
runHook preInstall
clang_version=`${clang-unwrapped}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
mkdir -p $out/{bin,include/c++/v1,lib/{cmake,clang/$clang_version/{include,lib}},libexec,share}
for path in ${llvm} ${clang-unwrapped} ${lld} ${libc} ${libunwind} ${libcxxabi} ${libcxx} ${compiler-rt}; do
cp -as $path/* $out
chmod +w $out/{*,include/c++/v1,lib/{clang/$clang_version/include,cmake}}
rm -f $out/lib/libc++.so
done
ln -s $out/lib/* $out/lib/clang/$clang_version/lib
ln -sf $out/include/* $out/lib/clang/$clang_version/include
runHook postInstall
'';
passthru.isClang = true;
});
extraPackages = [
llvm
lld
libc
libunwind
libcxxabi
compiler-rt
];
nixSupport.cc-cflags = [
"-resource-dir=$out/resource-root"
"-fuse-ld=lld"
"-rtlib=compiler-rt"
"-unwindlib=libunwind"
"-Wno-unused-command-line-argument"
];
extraBuildCommands = ''
clang_version=`${cc}/bin/clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
mkdir -p $out/resource-root
ln -s ${cc}/lib/clang/$clang_version/{include,lib} $out/resource-root
# Not sure why, but hardening seems to make things break
echo "" > $out/nix-support/add-hardening.sh
# GPU compilation uses builtin `lld`
substituteInPlace $out/bin/{clang,clang++} \
--replace "-MM) dontLink=1 ;;" "-MM | --cuda-device-only) dontLink=1 ;;''\n--cuda-host-only | --cuda-compile-host-device) dontLink=0 ;;"
'';
}

View file

@ -0,0 +1,33 @@
{ stdenv
, callPackage
, rocmUpdateScript
, clang-unwrapped
, mlir
, python3Packages
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildTests = false; # `Executable "flang1" doesn't exist!`
targetName = "flang";
targetDir = targetName;
extraNativeBuildInputs = [ python3Packages.sphinx-markdown-tables ];
extraBuildInputs = [ mlir ];
extraCMakeFlags = [
"-DCMAKE_POLICY_DEFAULT_CMP0116=NEW"
"-DCLANG_DIR=${clang-unwrapped}/lib/cmake/clang"
"-DFLANG_INCLUDE_TESTS=OFF"
"-DMLIR_TABLEGEN_EXE=${mlir}/bin/mlir-tblgen"
];
extraPostPatch = ''
substituteInPlace test/CMakeLists.txt \
--replace "FileCheck" "" \
--replace "count" "" \
--replace "not" ""
substituteInPlace docs/CMakeLists.txt \
--replace "CLANG_TABLEGEN_EXE clang-tblgen" "CLANG_TABLEGEN_EXE ${clang-unwrapped}/bin/clang-tblgen"
'';
}

View file

@ -0,0 +1,36 @@
{ stdenv
, callPackage
, rocmUpdateScript
, llvm
, clang
, spirv-llvm-translator
}:
let
spirv = (spirv-llvm-translator.override { inherit llvm; });
in callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
targetName = "libclc";
targetDir = targetName;
extraBuildInputs = [ spirv ];
# `spirv-mesa3d` isn't compiling with LLVM 15.0.0, it does with LLVM 14.0.0
# Try removing the `spirv-mesa3d` and `clspv` patches next update
# `clspv` tests fail, unresolved calls
extraPostPatch = ''
substituteInPlace CMakeLists.txt \
--replace "find_program( LLVM_CLANG clang PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
"find_program( LLVM_CLANG clang PATHS \"${clang}/bin\" NO_DEFAULT_PATH )" \
--replace "find_program( LLVM_SPIRV llvm-spirv PATHS \''${LLVM_BINDIR} NO_DEFAULT_PATH )" \
"find_program( LLVM_SPIRV llvm-spirv PATHS \"${spirv}/bin\" NO_DEFAULT_PATH )" \
--replace " spirv-mesa3d-" "" \
--replace " spirv64-mesa3d-" "" \
--replace "NOT \''${t} MATCHES" \
"NOT \''${ARCH} STREQUAL \"clspv\" AND NOT \''${ARCH} STREQUAL \"clspv64\" AND NOT \''${t} MATCHES"
'';
checkTargets = [ ];
isBroken = true; # ROCm 5.7.0 doesn't have IR/AttributeMask.h yet...?
}

View file

@ -0,0 +1,39 @@
{ stdenv
, callPackage
, rocmUpdateScript
, clang
, xz
, swig
, lua5_3
, graphviz
, gtest
, python3Packages
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildTests = false; # FIXME: Bad pathing for clang executable in tests, using relative path most likely
targetName = "lldb";
targetDir = targetName;
extraNativeBuildInputs = [ python3Packages.sphinx-automodapi ];
extraBuildInputs = [
xz
swig
lua5_3
graphviz
gtest
];
extraCMakeFlags = [
"-DLLDB_EXTERNAL_CLANG_RESOURCE_DIR=${clang}/resource-root/lib/clang/$clang_version"
"-DLLDB_INCLUDE_TESTS=ON"
"-DLLDB_INCLUDE_UNITTESTS=ON"
];
extraPostPatch = ''
export clang_version=`clang -v 2>&1 | grep "clang version " | grep -E -o "[0-9.-]+"`
'';
checkTargets = [ "check-${targetName}" ];
}

View file

@ -0,0 +1,67 @@
{ stdenv
, callPackage
, rocmUpdateScript
# , hip
# , rocm-comgr
, vulkan-headers
, vulkan-loader
, glslang
, shaderc
, lit
}:
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;
# extraNativeBuildInputs = [ hip ];
extraBuildInputs = [
# rocm-comgr
vulkan-headers
vulkan-loader
glslang
shaderc
];
extraCMakeFlags = [
"-DCMAKE_POLICY_DEFAULT_CMP0116=NEW"
"-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 = ''
chmod +w ../llvm
mkdir -p ../llvm/build/bin
ln -s ${lit}/bin/lit ../llvm/build/bin/llvm-lit
substituteInPlace test/CMakeLists.txt \
--replace "FileCheck count not" "" \
--replace "list(APPEND MLIR_TEST_DEPENDS mlir_rocm_runtime)" ""
substituteInPlace lib/ExecutionEngine/CMakeLists.txt \
--replace "return()" ""
# Remove problematic tests
rm test/CAPI/execution_engine.c
rm test/Target/LLVMIR/llvmir-intrinsics.mlir
rm test/Target/LLVMIR/llvmir.mlir
rm test/Target/LLVMIR/openmp-llvm.mlir
rm test/mlir-cpu-runner/*.mlir
rm test/mlir-vulkan-runner/*.mlir
'';
extraPostInstall = ''
mkdir -p $out/bin
mv bin/mlir-tblgen $out/bin
'';
checkTargets = [ "check-${targetName}" ];
requiredSystemFeatures = [ "big-parallel" ];
}

View file

@ -0,0 +1,45 @@
{ lib
, stdenv
, callPackage
, rocmUpdateScript
, llvm
, clang
, clang-unwrapped
# , rocm-device-libs
# , rocm-runtime
, perl
, elfutils
, lit
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildTests = false; # Too many failures, most pass
targetName = "openmp";
targetDir = targetName;
extraNativeBuildInputs = [ perl ];
extraBuildInputs = [
# rocm-device-libs
# rocm-runtime
elfutils
];
extraCMakeFlags = [
"-DCMAKE_MODULE_PATH=/build/source/llvm/cmake/modules" # For docs
"-DCLANG_TOOL=${clang}/bin/clang"
"-DCLANG_OFFLOAD_BUNDLER_TOOL=${clang-unwrapped}/bin/clang-offload-bundler"
"-DOPENMP_LLVM_TOOLS_DIR=${llvm}/bin"
"-DOPENMP_LLVM_LIT_EXECUTABLE=${lit}/bin/.lit-wrapped"
# "-DDEVICELIBS_ROOT=${rocm-device-libs.src}"
];
extraPostPatch = ''
# We can't build this target at the moment
substituteInPlace libomptarget/DeviceRTL/CMakeLists.txt \
--replace "gfx1010" ""
'';
checkTargets = [ "check-${targetName}" ];
extraLicenses = [ lib.licenses.mit ];
}

View file

@ -0,0 +1,18 @@
{ stdenv
, callPackage
, rocmUpdateScript
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
targetName = "polly";
targetDir = targetName;
extraPostPatch = ''
# `add_library cannot create target "llvm_gtest" because an imported target with the same name already exists`
substituteInPlace CMakeLists.txt \
--replace "NOT TARGET gtest" "FALSE"
'';
checkTargets = [ "check-${targetName}" ];
}

View file

@ -0,0 +1,15 @@
{ stdenv
, callPackage
, rocmUpdateScript
}:
callPackage ../base.nix rec {
inherit stdenv rocmUpdateScript;
buildDocs = false; # No documentation to build
buildMan = false; # No man pages to build
buildTests = false; # Too many errors
targetName = "pstl";
targetDir = "runtimes";
targetRuntimes = [ targetName ];
checkTargets = [ "check-${targetName}" ];
}

View file

@ -12,7 +12,7 @@
let
pname =
if lib.hasPrefix "rocm-llvm-" name
then "llvmPackages_rocm.${lib.removePrefix "rocm-llvm-" name}"
then "rocmPackages_5.llvm.${lib.removePrefix "rocm-llvm-" name}"
else name;
updateScript = writeScript "update.sh" ''

View file

@ -8,7 +8,7 @@ with pkgs;
llvmTests = let
pkgSets = lib.pipe pkgNames [
(filter (lib.hasPrefix "llvmPackages"))
(filter (n: n != "llvmPackages_rocm"))
(filter (n: n != "rocmPackages.llvm"))
(filter (n: n != "llvmPackages_latest"))
(filter (n: n != "llvmPackages_git"))
];

View file

@ -7766,6 +7766,9 @@ with pkgs;
rar2fs = callPackage ../tools/filesystems/rar2fs { };
rocmPackages = rocmPackages_5;
rocmPackages_5 = recurseIntoAttrs (callPackage ../development/rocm-modules/5 { });
rune = callPackage ../development/interpreters/rune { };
s9fes = callPackage ../development/interpreters/s9fes { };
@ -15716,7 +15719,6 @@ with pkgs;
clangStdenv = if stdenv.cc.isClang then stdenv else lowPrio llvmPackages.stdenv;
clang-sierraHack-stdenv = overrideCC stdenv buildPackages.clang-sierraHack;
libcxxStdenv = if stdenv.isDarwin then stdenv else lowPrio llvmPackages.libcxxStdenv;
rocmClangStdenv = llvmPackages_rocm.rocmClangStdenv;
clean = callPackage ../development/compilers/clean { };
@ -16771,8 +16773,6 @@ with pkgs;
targetLlvm = targetPackages.llvmPackages_16.llvm or llvmPackages_16.llvm;
}));
llvmPackages_rocm = recurseIntoAttrs (callPackage ../development/compilers/llvm/rocm { });
lorri = callPackage ../tools/misc/lorri {
inherit (darwin.apple_sdk.frameworks) CoreServices Security;
};
@ -16958,7 +16958,7 @@ with pkgs;
rml = callPackage ../development/compilers/rml { };
composable_kernel = callPackage ../development/libraries/composable_kernel {
inherit (llvmPackages_rocm) openmp clang-tools-extra;
inherit (rocmPackages.llvm) openmp clang-tools-extra;
stdenv = rocmClangStdenv;
};
@ -16977,17 +16977,17 @@ with pkgs;
};
hip-common = callPackage ../development/compilers/hip-common {
inherit (llvmPackages_rocm) llvm;
inherit (rocmPackages.llvm) llvm;
stdenv = rocmClangStdenv;
};
hipcc = callPackage ../development/compilers/hipcc {
inherit (llvmPackages_rocm) llvm;
inherit (rocmPackages.llvm) llvm;
stdenv = rocmClangStdenv;
};
hip = callPackage ../development/compilers/hip {
inherit (llvmPackages_rocm) llvm;
inherit (rocmPackages.llvm) llvm;
inherit (cudaPackages) cudatoolkit;
stdenv = rocmClangStdenv;
};
@ -17009,7 +17009,7 @@ with pkgs;
};
hipsparse = callPackage ../development/libraries/hipsparse {
inherit (llvmPackages_rocm) openmp;
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
@ -17018,7 +17018,7 @@ with pkgs;
};
hipfft = callPackage ../development/libraries/hipfft {
inherit (llvmPackages_rocm) openmp;
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
@ -17031,7 +17031,7 @@ with pkgs;
};
migraphx = callPackage ../development/libraries/migraphx {
inherit (llvmPackages_rocm) clang-tools-extra openmp;
inherit (rocmPackages.llvm) clang-tools-extra openmp;
stdenv = rocmClangStdenv;
rocmlir = rocmlir-rock;
};
@ -17049,7 +17049,7 @@ with pkgs;
};
rocalution = callPackage ../development/libraries/rocalution {
inherit (llvmPackages_rocm) openmp;
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
@ -17122,7 +17122,7 @@ with pkgs;
};
rocfft = callPackage ../development/libraries/rocfft {
inherit (llvmPackages_rocm) openmp;
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
@ -17135,12 +17135,12 @@ with pkgs;
};
rocwmma = callPackage ../development/libraries/rocwmma {
inherit (llvmPackages_rocm) openmp;
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
rocblas = callPackage ../development/libraries/rocblas {
inherit (llvmPackages_rocm) openmp;
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
@ -17153,7 +17153,7 @@ with pkgs;
};
miopen = callPackage ../development/libraries/miopen {
inherit (llvmPackages_rocm) llvm clang-tools-extra;
inherit (rocmPackages.llvm) llvm clang-tools-extra;
stdenv = rocmClangStdenv;
rocmlir = rocmlir-rock;
boost = boost179.override { enableStatic = true; };
@ -17167,11 +17167,9 @@ with pkgs;
useOpenCL = true;
};
rocmUpdateScript = callPackage ../development/rocm-modules/update-script { };
# Requires GCC
roctracer = callPackage ../development/libraries/roctracer {
inherit (llvmPackages_rocm) clang;
inherit (rocmPackages.llvm) clang;
};
rtags = callPackage ../development/tools/rtags {
@ -39477,7 +39475,7 @@ with pkgs;
lie = callPackage ../applications/science/math/LiE { };
inherit (callPackage ../development/libraries/science/math/magma {
inherit (llvmPackages_rocm) openmp;
inherit (rocmPackages.llvm) openmp;
}) magma magma_2_7_2 magma_2_6_2;
magma-cuda = magma.override {

View file

@ -8349,7 +8349,7 @@ self: super: with self; {
open-meteo = callPackage ../development/python-modules/open-meteo { };
openai-triton = callPackage ../development/python-modules/openai-triton { llvmPackages = pkgs.llvmPackages_rocm; };
openai-triton = callPackage ../development/python-modules/openai-triton { llvmPackages = pkgs.rocmPackages.llvm; };
openai-triton-bin = callPackage ../development/python-modules/openai-triton/bin.nix { };
@ -13902,7 +13902,7 @@ self: super: with self; {
else pkgs.magma;
inherit (pkgs.darwin.apple_sdk.frameworks) Accelerate CoreServices;
inherit (pkgs.darwin) libobjc;
inherit (pkgs.llvmPackages_rocm) openmp;
inherit (pkgs.rocmPackages.llvm) openmp;
};
torch-bin = callPackage ../development/python-modules/torch/bin.nix {