Skip to content

Commit

Permalink
Fix build.sh for rocm (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
yxsamliu authored Jun 20, 2024
1 parent d9b495f commit 64e557e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
13 changes: 6 additions & 7 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ dascandy-contracts-trunk)
;;
rocm-*)
if [[ "${VERSION#rocm-}" == "trunk" ]]; then
BRANCH=amd-stging
BRANCH=amd-staging
VERSION=rocm-trunk-$(date +%Y%m%d)
CMAKE_EXTRA_ARGS+=("-DLLVM_ENABLE_ASSERTIONS=1")
ROCM_VERSION=999999 # trunk builds are "infinitely" far into the future
LLVM_ENABLE_RUNTIMES+=";libunwind"
else
TAG=${VERSION}
if [[ "${VERSION}" =~ rocm-([0-9]+)\.([0-9]+)\.[^.]+ ]]; then
Expand All @@ -155,16 +156,14 @@ rocm-*)
if (( ROCM_VERSION < 601 )); then
ROCM_DEVICE_LIBS_BRANCH=${VERSION}
ROCM_DEVICE_LIBS_URL=https://github.com/ROCm/ROCm-Device-Libs.git
else
CMAKE_EXTRA_ARGS+=(
"-DLLVM_EXTERNAL_PROJECTS=device-libs;comgr"
"-DLLVM_EXTERNAL_DEVICE_LIBS_SOURCE_DIR=${ROOT}/llvm-project/amd/device-libs"
"-DLLVM_EXTERNAL_COMGR_SOURCE_DIR=${ROOT}/llvm-project/amd/comgr"
)
fi
URL=https://github.com/ROCm/llvm-project.git
LLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra;compiler-rt"
CMAKE_EXTRA_ARGS+=("-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86")
ROCM_PATCH="${ROOT}/patches/ce-clang-${VERSION}.patch"
if [[ -e "$ROCM_PATCH" ]]; then
PATCHES_TO_APPLY+=("$ROCM_PATCH")
fi
;;
llvm-spirv)
BASENAME=llvm-spirv
Expand Down
23 changes: 23 additions & 0 deletions build/patches/ce-clang-rocm-6.0.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/clang/tools/amdgpu-arch/CMakeLists.txt b/clang/tools/amdgpu-arch/CMakeLists.txt
index b37a6c998..403064d3a 100644
--- a/clang/tools/amdgpu-arch/CMakeLists.txt
+++ b/clang/tools/amdgpu-arch/CMakeLists.txt
@@ -12,14 +12,7 @@ find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/

add_clang_tool(amdgpu-arch AMDGPUArch.cpp)

-# If we find the HSA runtime we link with it directly.
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
-if(hsa-runtime64_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P EQUAL 4))
- message(STATUS "Building amdgpu-arch linked against libhsa")
- set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
- target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64 clangBasic)
-else()
- message(STATUS "Building amdgpu-arch for dlopened libhsa")
- target_compile_definitions(amdgpu-arch PRIVATE "DYNAMIC_HSA")
- target_link_libraries(amdgpu-arch PRIVATE clangBasic)
-endif()
+# Do not link static hsa-runtime64 since it depends on higher libstdc++ version
+message(STATUS "Building amdgpu-arch for dlopened libhsa")
+target_compile_definitions(amdgpu-arch PRIVATE "DYNAMIC_HSA")
+target_link_libraries(amdgpu-arch PRIVATE clangBasic)

0 comments on commit 64e557e

Please sign in to comment.