Skip to content

Commit

Permalink
🔮 Sync llvm and rocm fork (#228)
Browse files Browse the repository at this point in the history
This moves us to an LLVM version that is compatible with comgr and
device-libs from the ROCm LLVM fork. This way we can keep depending
mainly on upstream LLVM but still get to use newer versions of AMD's
libraries.

The version bumps in this commit are tuned and tested to pass the amdgpu
examples. The clr commit lags behind a bit, but the next commit would
cause segfaults due to a bumped default code object version.
  • Loading branch information
aaronmondal authored Apr 29, 2024
1 parent c63dc11 commit 3b76f6c
Show file tree
Hide file tree
Showing 26 changed files with 2,389 additions and 2,514 deletions.
8 changes: 3 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ llvm_project_overlay = use_extension(
"llvm_project_overlay",
)
llvm_project_overlay.configure(
commit = "ffa7c7897c14223c591249dde41f33ecb3c4c148",
commit = "7378fb30645ad5398491acea3960a8115d1b171c",
patches = [
"@rules_ll//patches:mallinfo2_patch.diff",
"@rules_ll//patches:rules_ll_overlay_patch.diff",
"@rules_ll//patches:llvm-project-fix-bazel-7.diff",
"@rules_ll//patches:llvm-project-fix-zlib-includes.diff",
],
sha256 = "c515f808ee7984294c315e3f04a232609e08b6bc168502dc2db329b1c4aca1ec",
sha256 = "8b6a6edc4d651e280ac2e52cb693df1ab13739e2ba38076fb7cd5be1d5623b50",
targets = [
"AMDGPU",
"NVPTX",
Expand All @@ -63,9 +62,8 @@ rules_ll_dependencies = use_extension(
use_repo(
rules_ll_dependencies,
"clr",
"comgr",
"hip",
"rocm-device-libs",
"llvm-project-rocm",
"rocr",
"roct",
"zlib-ng",
Expand Down
26 changes: 13 additions & 13 deletions ll/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ ll_toolchain(
address_sanitizer = select({
":bootstrap": [],
"//conditions:default": [
"@llvm-project//compiler-rt/lib/asan:clang_rt.asan",
"@llvm-project//compiler-rt/lib/asan:clang_rt.asan_static",
"@llvm-project//compiler-rt/lib/asan:clang_rt.asan_cxx",
"@llvm-project//compiler-rt:clang_rt.asan",
"@llvm-project//compiler-rt:clang_rt.asan_static",
"@llvm-project//compiler-rt:clang_rt.asan_cxx",
],
}),
compiler_runtime = select({
":bootstrap": [],
"//conditions:default": [
"@llvm-project//compiler-rt:libll_compiler-rt",
"@llvm-project//compiler-rt/lib/builtins:crt",
"@llvm-project//compiler-rt:crt",
],
}),
cpp_abihdrs = select({
Expand Down Expand Up @@ -143,7 +143,7 @@ ll_toolchain(
leak_sanitizer = select({
":bootstrap": [],
"//conditions:default": [
"@llvm-project//compiler-rt/lib/lsan:clang_rt.lsan",
"@llvm-project//compiler-rt:clang_rt.lsan",
],
}),
libomp = select({
Expand All @@ -153,8 +153,8 @@ ll_toolchain(
memory_sanitizer = select({
":bootstrap": [],
"//conditions:default": [
"@llvm-project//compiler-rt/lib/msan:clang_rt.msan",
"@llvm-project//compiler-rt/lib/msan:clang_rt.msan_cxx",
"@llvm-project//compiler-rt:clang_rt.msan",
"@llvm-project//compiler-rt:clang_rt.msan_cxx",
],
}),
omp_header = select({
Expand All @@ -163,24 +163,24 @@ ll_toolchain(
}),
profile = select({
":bootstrap": None,
"//conditions:default": "@llvm-project//compiler-rt/lib/profile:clang_rt.profile",
"//conditions:default": "@llvm-project//compiler-rt:clang_rt.profile",
}),
rocm_device_libs = select({
":hip_amdgpu": "@rocm-device-libs//:rocm-device-libs",
":hip_amdgpu": "@llvm-project-rocm//:rocm-device-libs",
"//conditions:default": None,
}),
thread_sanitizer = select({
":bootstrap": None,
"//conditions:default": [
"@llvm-project//compiler-rt/lib/tsan:clang_rt.tsan",
"@llvm-project//compiler-rt/lib/tsan:clang_rt.tsan_cxx",
"@llvm-project//compiler-rt:clang_rt.tsan",
"@llvm-project//compiler-rt:clang_rt.tsan_cxx",
],
}),
undefined_behavior_sanitizer = select({
":bootstrap": [],
"//conditions:default": [
"@llvm-project//compiler-rt/lib/ubsan:clang_rt.ubsan_standalone",
"@llvm-project//compiler-rt/lib/ubsan:clang_rt.ubsan_standalone_cxx",
"@llvm-project//compiler-rt:clang_rt.ubsan_standalone",
"@llvm-project//compiler-rt:clang_rt.ubsan_standalone_cxx",
],
}),
unwind_library = select({
Expand Down
36 changes: 15 additions & 21 deletions ll/init.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,17 @@ def _initialize_rules_ll_impl(_):
patch_args = ["-p1"],
)

http_archive(
name = "comgr",
build_file = "@rules_ll//third-party-overlays:comgr.BUILD.bazel",
strip_prefix = "ROCm-CompilerSupport-8c0f3bc3e1ad6d6f693c066a9ab96e612f86e606",
integrity = "sha256-uUqfGHJV3aV3uUNDwsjj4sG9Ds/47ksX6cs6DQgTgyQ=",
urls = [
"https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/archive/8c0f3bc3e1ad6d6f693c066a9ab96e612f86e606.zip",
],
patches = [
"@rules_ll//patches:comgr_bc2h.diff",
],
patch_args = ["-p1"],
)
# This commit needs further treatment. It changes the default code object
# version from 4 to 5 which appears to cause segfaults.
# clr_commit = "2eab055436e4ccda8b52ad801bfaa44adfda885c"

http_archive(
name = "clr",
build_file = "@rules_ll//third-party-overlays:clr.BUILD.bazel",
strip_prefix = "clr-6e86d29a582e28d40d6d8acd55b9f4c32e974e87",
integrity = "sha256-pL0EV8AXK5NsLJGoyNJCEaUlOSmK/uy9qXwX6JHmd18=",
strip_prefix = "clr-8c8c00f64c4fa860f75b713d338edd364229326f",
integrity = "sha256-+7BpjDZqUrjZONoqaesYF6UvOvcj+H7iWMKlH5OIwec=",
urls = [
"https://github.com/ROCm/clr/archive/6e86d29a582e28d40d6d8acd55b9f4c32e974e87.zip",
"https://github.com/ROCm/clr/archive/8c8c00f64c4fa860f75b713d338edd364229326f.zip",
],
patches = [
"@rules_ll//patches:hipamd_deprecate_fix.diff",
Expand All @@ -118,13 +108,17 @@ def _initialize_rules_ll_impl(_):
)

http_archive(
name = "rocm-device-libs",
build_file = "@rules_ll//third-party-overlays:rocm-device-libs.BUILD.bazel",
integrity = "sha256-Q2GrctM0GQjAnWDlFeiQXVIBHWS1xtzP+k9OWtgqGMM=",
strip_prefix = "ROCm-Device-Libs-rocm-6.0.2",
name = "llvm-project-rocm",
build_file = "@rules_ll//third-party-overlays:llvm-project-rocm.BUILD.bazel",
integrity = "sha256-wPNx2by33XA4kDw2xUADzI9xpTqqGukH7qhZG9BbYUU=",
strip_prefix = "llvm-project-e80d300ecf0c235948345e81264af62adb479f02",
urls = [
"https://github.com/RadeonOpenCompute/ROCm-Device-Libs/archive/refs/tags/rocm-6.0.2.zip",
"https://github.com/ROCm/llvm-project/archive/e80d300ecf0c235948345e81264af62adb479f02.zip",
],
patches = [
"@rules_ll//patches:comgr_bc2h.diff",
],
patch_args = ["-p1"],
)

rules_ll_dependencies = module_extension(
Expand Down
4 changes: 4 additions & 0 deletions ll/llvm_project_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Targets from the `llvm-project-overlay` used in `depends_on_llvm`.
LLVM_PROJECT_DEPS = [
# Clang libraries.
"@llvm-project//clang:analysis",
"@llvm-project//clang:apinotes",
"@llvm-project//clang:arc_migrate",
"@llvm-project//clang:ast",
"@llvm-project//clang:ast-diff",
Expand Down Expand Up @@ -78,9 +79,12 @@ LLVM_PROJECT_DEPS = [
"@llvm-project//llvm:ExecutionEngine",
# "@llvm-project//llvm:Exegesis", # Not working properly.
"@llvm-project//llvm:FileCheckLib",
"@llvm-project//llvm:FrontendDriver",
"@llvm-project//llvm:FrontendHLSL",
"@llvm-project//llvm:FrontendOffloading",
"@llvm-project//llvm:FrontendOpenACC",
"@llvm-project//llvm:FrontendOpenMP",
"@llvm-project//llvm:HipStdPar",
"@llvm-project//llvm:IPO",
"@llvm-project//llvm:IRPrinter",
"@llvm-project//llvm:IRReader",
Expand Down
Loading

0 comments on commit 3b76f6c

Please sign in to comment.