Enable address sanitizer in rocm's llvm-amdgpu package. (#40570)

* enable address sanitizer in rocm's llvm-amdgpu package
* remove references to 5.7.0 for now
* fix style error
* address review comments
This commit is contained in:
Sreenivasa Murthy Kolam 2023-11-01 06:39:40 +05:30 committed by GitHub
parent e5cebb6b6f
commit cb018fd7eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 1 deletions

View file

@ -132,6 +132,7 @@ def install_targets(self):
else: else:
return ["install"] return ["install"]
def cmake_args(self):
args = [] args = []
if self.spec.satisfies("@:5.4.3"): if self.spec.satisfies("@:5.4.3"):
args.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared")) args.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared"))

View file

@ -161,7 +161,7 @@ class LlvmAmdgpu(CMakePackage):
# OpenMP clang toolchain looks for bitcode files in llvm/bin/../lib # OpenMP clang toolchain looks for bitcode files in llvm/bin/../lib
# as per 5.2.0 llvm code. It used to be llvm/bin/../lib/libdevice. # as per 5.2.0 llvm code. It used to be llvm/bin/../lib/libdevice.
# Below patch is to look in the old path. # Below patch is to look in the old path.
patch("adjust-openmp-bitcode-directory-for-llvm-link.patch", when="@5.2.0:") patch("adjust-openmp-bitcode-directory-for-llvm-link.patch", when="@5.2.0:5.6")
# Below patch is to set the flag -mcode-object-version=none until # Below patch is to set the flag -mcode-object-version=none until
# the below fix is available in device-libs release code. # the below fix is available in device-libs release code.
@ -227,6 +227,44 @@ class LlvmAmdgpu(CMakePackage):
when="@master +rocm-device-libs", when="@master +rocm-device-libs",
) )
for d_version, d_shasum in [
("5.6.1", "4de9a57c2092edf9398d671c8a2c60626eb7daf358caf710da70d9c105490221"),
("5.6.0", "30875d440df9d8481ffb24d87755eae20a0efc1114849a72619ea954f1e9206c"),
]:
resource(
name="hsa-runtime",
placement="hsa-runtime",
url=f"https://github.com/RadeonOpenCompute/ROCR-Runtime/archive/rocm-{d_version}.tar.gz",
sha256=d_shasum,
when="@{0}".format(d_version),
)
resource(
name="hsa-runtime",
placement="hsa-runtime",
git="https://github.com/RadeonOpenCompute/ROCR-Runtime.git",
branch="master",
when="@master",
)
for d_version, d_shasum in [
("5.6.1", "0a85d84619f98be26ca7a32c71f94ed3c4e9866133789eabb451be64ce739300"),
("5.6.0", "9396a7238b547ee68146c669b10b9d5de8f1d76527c649133c75d8076a185a72"),
]:
resource(
name="comgr",
placement="comgr",
url=f"https://github.com/RadeonOpenCompute/ROCm-CompilerSupport/archive/rocm-{d_version}.tar.gz",
sha256=d_shasum,
when="@{0}".format(d_version),
)
resource(
name="comgr",
placement="comgr",
git="https://github.com/RadeonOpenCompute/ROCm-CompilerSupport.git",
branch="amd-stg-open",
when="@master",
)
def cmake_args(self): def cmake_args(self):
llvm_projects = ["clang", "lld", "clang-tools-extra", "compiler-rt"] llvm_projects = ["clang", "lld", "clang-tools-extra", "compiler-rt"]
llvm_runtimes = [] llvm_runtimes = []
@ -292,6 +330,12 @@ def cmake_args(self):
if self.spec.satisfies("@5.5.0:"): if self.spec.satisfies("@5.5.0:"):
args.append("-DCLANG_DEFAULT_RTLIB=compiler-rt") args.append("-DCLANG_DEFAULT_RTLIB=compiler-rt")
args.append("-DCLANG_DEFAULT_UNWINDLIB=libgcc") args.append("-DCLANG_DEFAULT_UNWINDLIB=libgcc")
if self.spec.satisfies("@5.6.0:"):
hsainc_path = os.path.join(self.stage.source_path, "hsa-runtime/src/inc")
comgrinc_path = os.path.join(self.stage.source_path, "comgr/lib/comgr/include")
args.append("-DSANITIZER_HSA_INCLUDE_PATH={0}".format(hsainc_path))
args.append("-DSANITIZER_COMGR_INCLUDE_PATH={0}".format(comgrinc_path))
args.append("-DSANITIZER_AMDGPU:Bool=ON")
return args return args
@run_after("install") @run_after("install")