summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorafzpatel <122491982+afzpatel@users.noreply.github.com>2024-08-14 11:46:04 -0400
committerGitHub <noreply@github.com>2024-08-14 08:46:04 -0700
commite01151a200c56133a6742a33ee2ead566fb96e6c (patch)
tree9d8acff47730ab028527a3f13b9ba7d0e31dc5b2
parent29b50527a614862727e4a62f23379d8a13a62ee7 (diff)
downloadspack-e01151a200c56133a6742a33ee2ead566fb96e6c.tar.gz
spack-e01151a200c56133a6742a33ee2ead566fb96e6c.tar.bz2
spack-e01151a200c56133a6742a33ee2ead566fb96e6c.tar.xz
spack-e01151a200c56133a6742a33ee2ead566fb96e6c.zip
enable asan in remaining rocm packages (#45192)
* initial commit to enable asan in remaining rocm packages * remove os import * add rocm-opencl rocm-dbgapi rocm-debug-agent * add libclang path to LD_LIBRARY_PATH * enable asan for rocfft * add f-string and add +asan dependencies for hip and rocm-opencl * add conflicts for centos7/8 and rhel 9
-rw-r--r--var/spack/repos/builtin/packages/hip/package.py26
-rw-r--r--var/spack/repos/builtin/packages/llvm-amdgpu/package.py8
-rw-r--r--var/spack/repos/builtin/packages/migraphx/package.py21
-rw-r--r--var/spack/repos/builtin/packages/miopen-hip/package.py13
-rw-r--r--var/spack/repos/builtin/packages/mivisionx/package.py14
-rw-r--r--var/spack/repos/builtin/packages/rocalution/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rocblas/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rocfft/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rocm-core/package.py18
-rw-r--r--var/spack/repos/builtin/packages/rocm-dbgapi/package.py16
-rw-r--r--var/spack/repos/builtin/packages/rocm-debug-agent/package.py15
-rw-r--r--var/spack/repos/builtin/packages/rocm-opencl/package.py26
-rw-r--r--var/spack/repos/builtin/packages/rocprim/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rocrand/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rocsolver/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rocsparse/package.py12
-rw-r--r--var/spack/repos/builtin/packages/rpp/package.py21
17 files changed, 261 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/hip/package.py b/var/spack/repos/builtin/packages/hip/package.py
index 7bd920a6b8..413984b199 100644
--- a/var/spack/repos/builtin/packages/hip/package.py
+++ b/var/spack/repos/builtin/packages/hip/package.py
@@ -46,8 +46,14 @@ class Hip(CMakePackage):
variant("rocm", default=True, description="Enable ROCm support")
variant("cuda", default=False, description="Build with CUDA")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
conflicts("+cuda +rocm", msg="CUDA and ROCm support are mutually exclusive")
conflicts("~cuda ~rocm", msg="CUDA or ROCm support is required")
+ conflicts("~rocm +asan", msg="ROCm must be enabled for asan")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
depends_on("cuda", when="+cuda")
@@ -60,6 +66,8 @@ class Hip(CMakePackage):
with when("+rocm"):
depends_on("gl@4.5:")
depends_on("py-cppheaderparser", type="build", when="@5.3.3:")
+ depends_on("libx11", when="+asan")
+ depends_on("xproto", when="+asan")
for ver in [
"5.3.0",
"5.3.3",
@@ -532,6 +540,24 @@ class Hip(CMakePackage):
args.append(self.define("HIP_PLATFORM", "amd"))
if self.spec.satisfies("@5.6.0:"):
args.append(self.define("HIP_LLVM_ROOT", self.spec["llvm-amdgpu"].prefix))
+ if self.spec.satisfies("@6.1.0:") and self.spec.satisfies("+asan"):
+ args.append(self.define("ADDRESS_SANITIZER", "ON"))
+ args.append(
+ self.define("CMAKE_C_COMPILER", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ )
+ args.append(
+ self.define(
+ "CMAKE_CXX_COMPILER", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++"
+ )
+ )
+ args.append(
+ self.define(
+ "CMAKE_CXX_FLAGS",
+ f"-I{self.spec['libx11'].prefix.include} "
+ f"-I{self.spec['mesa'].prefix.include} "
+ f"-I{self.spec['xproto'].prefix.include}",
+ )
+ )
if self.spec.satisfies("+cuda"):
args.append(self.define("HIP_PLATFORM", "nvidia"))
diff --git a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py
index 3e4556dd64..fd451f796c 100644
--- a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py
+++ b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py
@@ -275,3 +275,11 @@ class LlvmAmdgpu(CMakePackage, CompilerPackage):
def setup_dependent_run_environment(self, env, dependent_spec):
llvm_amdgpu_home = self.spec["llvm-amdgpu"].prefix
env.prepend_path("LD_LIBRARY_PATH", llvm_amdgpu_home + "/llvm/lib")
+
+ # Required for enabling asan on dependent packages
+ def setup_dependent_build_environment(self, env, dependent_spec):
+ for root, _, files in os.walk(self.spec["llvm-amdgpu"].prefix):
+ if "libclang_rt.asan-x86_64.so" in files:
+ asan_lib_path = root
+ env.prepend_path("LD_LIBRARY_PATH", asan_lib_path)
+ env.prune_duplicate_paths("LD_LIBRARY_PATH")
diff --git a/var/spack/repos/builtin/packages/migraphx/package.py b/var/spack/repos/builtin/packages/migraphx/package.py
index 03a266d1e8..a4c8882a79 100644
--- a/var/spack/repos/builtin/packages/migraphx/package.py
+++ b/var/spack/repos/builtin/packages/migraphx/package.py
@@ -37,6 +37,12 @@ class Migraphx(CMakePackage):
version("5.3.3", sha256="91d91902bbedd5e1951a231e8e5c9a328360b128c731912ed17c8059df38e02a")
version("5.3.0", sha256="d0b7283f42e03fb38b612868b8c94f46f27a6e0b019ae95fde5b9086582a1c69")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
+
depends_on("c", type="build") # generated
depends_on("cxx", type="build") # generated
@@ -117,6 +123,15 @@ class Migraphx(CMakePackage):
ver = None
return ver
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
+
def cmake_args(self):
spec = self.spec
abspath = spec["abseil-cpp"].prefix.include
@@ -134,6 +149,12 @@ class Migraphx(CMakePackage):
args.append(
self.define("GPU_TARGETS", "gfx906;gfx908;gfx90a;gfx1030;gfx1100;gfx1101;gfx1102")
)
+ if self.spec.satisfies("@6.1:") and self.spec.satisfies("+asan"):
+ args.append(
+ self.define(
+ "CMAKE_CXX_FLAGS", "-fsanitize=address -shared-libasan -I{0}".format(abspath)
+ )
+ )
return args
def test_unit_tests(self):
diff --git a/var/spack/repos/builtin/packages/miopen-hip/package.py b/var/spack/repos/builtin/packages/miopen-hip/package.py
index 84b5f1f0aa..52d9a28c1b 100644
--- a/var/spack/repos/builtin/packages/miopen-hip/package.py
+++ b/var/spack/repos/builtin/packages/miopen-hip/package.py
@@ -38,6 +38,12 @@ class MiopenHip(CMakePackage):
version("5.3.3", sha256="7efc98215d23a2caaf212378c37e9a6484f54a4ed3e9660719286e4f287d3715")
version("5.3.0", sha256="c5819f593d71beeda2eb24b89182912240cc40f83b2b8f9de695a8e230aa4ea6")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
+
depends_on("cxx", type="build") # generated
depends_on("cmake@3.5:", type="build")
@@ -112,6 +118,13 @@ class MiopenHip(CMakePackage):
def setup_build_environment(self, env):
lib_dir = self.spec["zlib-api"].libs.directories[0]
env.prepend_path("LIBRARY_PATH", lib_dir)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
if self.spec.satisfies("%gcc@8.0:8.9") and self.spec.satisfies("@6.1:"):
env.append_flags("LDFLAGS", "-lstdc++fs")
diff --git a/var/spack/repos/builtin/packages/mivisionx/package.py b/var/spack/repos/builtin/packages/mivisionx/package.py
index e4e2daae19..404b3f9843 100644
--- a/var/spack/repos/builtin/packages/mivisionx/package.py
+++ b/var/spack/repos/builtin/packages/mivisionx/package.py
@@ -53,6 +53,11 @@ class Mivisionx(CMakePackage):
variant("opencl", default=False, description="Use OPENCL as the backend")
variant("hip", default=True, description="Use HIP as backend")
variant("add_tests", default=False, description="add tests and samples folder")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
patch("0001-add-half-include-path.patch", when="@5.5")
patch("0001-add-half-include-path-5.6.patch", when="@5.6:")
@@ -288,6 +293,15 @@ class Mivisionx(CMakePackage):
if self.spec.satisfies("@6.1:"):
env.prepend_path("LD_LIBRARY_PATH", self.spec["hsa-rocr-dev"].prefix.lib)
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
+
def flag_handler(self, name, flags):
spec = self.spec
protobuf = spec["protobuf"].prefix.include
diff --git a/var/spack/repos/builtin/packages/rocalution/package.py b/var/spack/repos/builtin/packages/rocalution/package.py
index 94802cd208..02f11b33a8 100644
--- a/var/spack/repos/builtin/packages/rocalution/package.py
+++ b/var/spack/repos/builtin/packages/rocalution/package.py
@@ -54,6 +54,11 @@ class Rocalution(CMakePackage):
values=auto_or_any_combination_of(*amdgpu_targets),
sticky=True,
)
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
depends_on("cmake@3.5:", type="build")
@@ -91,6 +96,13 @@ class Rocalution(CMakePackage):
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
def patch(self):
with working_dir("src/base/hip"):
diff --git a/var/spack/repos/builtin/packages/rocblas/package.py b/var/spack/repos/builtin/packages/rocblas/package.py
index 4c91b3bd04..5df351eb62 100644
--- a/var/spack/repos/builtin/packages/rocblas/package.py
+++ b/var/spack/repos/builtin/packages/rocblas/package.py
@@ -53,6 +53,11 @@ class Rocblas(CMakePackage):
sticky=True,
)
variant("tensile", default=True, description="Use Tensile as a backend")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
# https://reviews.llvm.org/D124866
# https://github.com/ROCm/HIP/issues/2678
@@ -144,6 +149,13 @@ class Rocblas(CMakePackage):
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
@classmethod
def determine_version(cls, lib):
diff --git a/var/spack/repos/builtin/packages/rocfft/package.py b/var/spack/repos/builtin/packages/rocfft/package.py
index eb56ae2131..39c6f295db 100644
--- a/var/spack/repos/builtin/packages/rocfft/package.py
+++ b/var/spack/repos/builtin/packages/rocfft/package.py
@@ -53,6 +53,11 @@ class Rocfft(CMakePackage):
values=auto_or_any_combination_of(*amdgpu_targets),
sticky=True,
)
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
depends_on("cmake@3.16:", type="build")
depends_on("python@3.6:", type="build")
@@ -104,6 +109,13 @@ class Rocfft(CMakePackage):
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
if self.spec.satisfies("%gcc@8.0:8.9") and self.spec.satisfies("@6.1:"):
env.append_flags("LDFLAGS", "-lstdc++fs")
diff --git a/var/spack/repos/builtin/packages/rocm-core/package.py b/var/spack/repos/builtin/packages/rocm-core/package.py
index c57faf1bd2..fd6f96fe23 100644
--- a/var/spack/repos/builtin/packages/rocm-core/package.py
+++ b/var/spack/repos/builtin/packages/rocm-core/package.py
@@ -32,8 +32,26 @@ class RocmCore(CMakePackage):
version("5.5.1", sha256="bc73060432ffdc2e210394835d383890b9652476074ef4708d447473f273ce76")
version("5.5.0", sha256="684d3312bb14f05dc280cf136f5eddff38ba340cd85c383d6a217d8e27d3d57d")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
+
depends_on("cxx", type="build") # generated
+ for ver in ["6.1.0", "6.1.1", "6.1.2"]:
+ depends_on("llvm-amdgpu", when=f"@{ver}+asan")
+
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("+asan"):
+ env.set("CC", self.spec["llvm-amdgpu"].prefix + "/bin/clang")
+ env.set("CXX", self.spec["llvm-amdgpu"].prefix + "/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
+
def cmake_args(self):
args = [self.define("ROCM_VERSION", self.spec.version)]
return args
diff --git a/var/spack/repos/builtin/packages/rocm-dbgapi/package.py b/var/spack/repos/builtin/packages/rocm-dbgapi/package.py
index baca1f2b9f..fa5c8503e1 100644
--- a/var/spack/repos/builtin/packages/rocm-dbgapi/package.py
+++ b/var/spack/repos/builtin/packages/rocm-dbgapi/package.py
@@ -42,8 +42,13 @@ class RocmDbgapi(CMakePackage):
version("5.3.3", sha256="3c81cb23fe671d391557a63c13b6a13d4dc367db5cb5de55592a6758284d8a3f")
version("5.3.0", sha256="afffec78e34fe70952cd41efc3d7ba8f64e43acb2ad20aa35c9b8b591bed48ca")
- depends_on("cxx", type="build") # generated
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
+ depends_on("cxx", type="build") # generated
depends_on("cmake@3:", type="build")
depends_on("hwdata", when="@5.5.0:")
@@ -99,6 +104,15 @@ class RocmDbgapi(CMakePackage):
"CMakeLists.txt",
)
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
+
def cmake_args(self):
args = []
if self.spec.satisfies("@5.3.0:"):
diff --git a/var/spack/repos/builtin/packages/rocm-debug-agent/package.py b/var/spack/repos/builtin/packages/rocm-debug-agent/package.py
index a40c9523ab..2cbc7d7f68 100644
--- a/var/spack/repos/builtin/packages/rocm-debug-agent/package.py
+++ b/var/spack/repos/builtin/packages/rocm-debug-agent/package.py
@@ -35,6 +35,12 @@ class RocmDebugAgent(CMakePackage):
version("5.3.3", sha256="7170312d08e91334ee03586aa1f23d67f33d9ec0df25a5556cbfa3f210b15b06")
version("5.3.0", sha256="8dfb6aa442ce136207c0c089321c8099042395977b4a488e4ca219661df0cd78")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
+
depends_on("cxx", type="build") # generated
depends_on("cmake@3:", type="build")
@@ -89,6 +95,15 @@ class RocmDebugAgent(CMakePackage):
)
return None
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
+
def cmake_args(self):
spec = self.spec
args = [self.define("CMAKE_MODULE_PATH", spec["hip"].prefix.lib.cmake.hip)]
diff --git a/var/spack/repos/builtin/packages/rocm-opencl/package.py b/var/spack/repos/builtin/packages/rocm-opencl/package.py
index ea6e3779bf..92d3373eff 100644
--- a/var/spack/repos/builtin/packages/rocm-opencl/package.py
+++ b/var/spack/repos/builtin/packages/rocm-opencl/package.py
@@ -53,12 +53,20 @@ class RocmOpencl(CMakePackage):
version("5.3.3", sha256="cab394e6ef16c35bab8de29a66b96a7dc0e7d1297aaacba3718fa1d369233c9f")
version("5.3.0", sha256="d251e2efe95dc12f536ce119b2587bed64bbda013969fa72be58062788044a9e")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
+
depends_on("c", type="build") # generated
depends_on("cxx", type="build") # generated
depends_on("cmake@3:", type="build")
depends_on("gl@4.5:", type="link")
depends_on("numactl", type="link")
+ depends_on("libx11", when="+asan")
+ depends_on("xproto", when="+asan")
for d_version, d_shasum in [
("5.6.1", "cc9a99c7e4de3d9360c0a471b27d626e84a39c9e60e0aff1e8e1500d82391819"),
@@ -152,9 +160,27 @@ class RocmOpencl(CMakePackage):
if self.spec.satisfies("@5.7:"):
args.append(self.define("CLR_BUILD_HIP", False))
args.append(self.define("CLR_BUILD_OCL", True))
+ if self.spec.satisfies("+asan"):
+ args.append(
+ self.define(
+ "CMAKE_CXX_FLAGS",
+ f"-I{self.spec['libx11'].prefix.include} "
+ f"-I{self.spec['mesa'].prefix.include} "
+ f"-I{self.spec['xproto'].prefix.include}",
+ )
+ )
return args
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
+
def setup_run_environment(self, env):
env.prepend_path("LD_LIBRARY_PATH", self.prefix.lib),
env.set("OCL_ICD_VENDORS", self.prefix.vendors + "/")
diff --git a/var/spack/repos/builtin/packages/rocprim/package.py b/var/spack/repos/builtin/packages/rocprim/package.py
index db959c565e..dd4f2d9cd7 100644
--- a/var/spack/repos/builtin/packages/rocprim/package.py
+++ b/var/spack/repos/builtin/packages/rocprim/package.py
@@ -44,6 +44,11 @@ class Rocprim(CMakePackage):
values=auto_or_any_combination_of(*amdgpu_targets),
sticky=True,
)
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
depends_on("cmake@3.10.2:", type="build")
depends_on("numactl", type="link")
@@ -77,6 +82,13 @@ class Rocprim(CMakePackage):
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
def cmake_args(self):
args = [
diff --git a/var/spack/repos/builtin/packages/rocrand/package.py b/var/spack/repos/builtin/packages/rocrand/package.py
index b3fb00b0e4..482d922d12 100644
--- a/var/spack/repos/builtin/packages/rocrand/package.py
+++ b/var/spack/repos/builtin/packages/rocrand/package.py
@@ -54,6 +54,11 @@ class Rocrand(CMakePackage):
sticky=True,
)
variant("hiprand", default=True, when="@5.1.0:", description="Build the hiprand library")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
depends_on("cmake@3.10.2:", type="build")
@@ -126,6 +131,13 @@ class Rocrand(CMakePackage):
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
@classmethod
def determine_version(cls, lib):
diff --git a/var/spack/repos/builtin/packages/rocsolver/package.py b/var/spack/repos/builtin/packages/rocsolver/package.py
index 4cc1e485eb..404adac95d 100644
--- a/var/spack/repos/builtin/packages/rocsolver/package.py
+++ b/var/spack/repos/builtin/packages/rocsolver/package.py
@@ -36,6 +36,11 @@ class Rocsolver(CMakePackage):
size and compile time by adding specialized kernels \
for small matrix sizes",
)
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
license("BSD-2-Clause")
@@ -138,6 +143,13 @@ class Rocsolver(CMakePackage):
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
@run_after("build")
@on_package_attributes(run_tests=True)
diff --git a/var/spack/repos/builtin/packages/rocsparse/package.py b/var/spack/repos/builtin/packages/rocsparse/package.py
index 93b5122b1a..d5af36e08c 100644
--- a/var/spack/repos/builtin/packages/rocsparse/package.py
+++ b/var/spack/repos/builtin/packages/rocsparse/package.py
@@ -32,6 +32,11 @@ class Rocsparse(CMakePackage):
sticky=True,
)
variant("test", default=False, description="Build rocsparse-test client")
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
license("MIT")
version("6.1.2", sha256="e8989c28085275e7c044b19fd2bc86d8493ce6a1b8545126f787722c535fe6eb")
@@ -244,6 +249,13 @@ class Rocsparse(CMakePackage):
def setup_build_environment(self, env):
env.set("CXX", self.spec["hip"].hipcc)
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang++")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
@classmethod
def determine_version(cls, lib):
diff --git a/var/spack/repos/builtin/packages/rpp/package.py b/var/spack/repos/builtin/packages/rpp/package.py
index 957d90bba4..9bafc3826d 100644
--- a/var/spack/repos/builtin/packages/rpp/package.py
+++ b/var/spack/repos/builtin/packages/rpp/package.py
@@ -60,6 +60,11 @@ class Rpp(CMakePackage):
default=False,
description="add utilities folder which contains rpp unit tests",
)
+ variant("asan", default=False, description="Build with address-sanitizer enabled or disabled")
+
+ conflicts("+asan", when="os=rhel9")
+ conflicts("+asan", when="os=centos7")
+ conflicts("+asan", when="os=centos8")
patch("0001-include-half-openmp-through-spack-package.patch", when="@:5.7")
patch("0002-declare-handle-in-header.patch")
@@ -75,6 +80,13 @@ class Rpp(CMakePackage):
filter_file(
"${ROCM_PATH}/llvm", self.spec["llvm-amdgpu"].prefix, "CMakeLists.txt", string=True
)
+ if self.spec.satisfies("+asan"):
+ filter_file(
+ "CMAKE_CXX_COMPILER clang++",
+ "CMAKE_CXX_COMPILER {0}/bin/clang++".format(self.spec["llvm-amdgpu"].prefix),
+ "CMakeLists.txt",
+ string=True,
+ )
if self.spec.satisfies("+opencl"):
filter_file(
"${ROCM_PATH}",
@@ -153,6 +165,15 @@ class Rpp(CMakePackage):
if self.spec.satisfies("@6.1:"):
env.prepend_path("LD_LIBRARY_PATH", self.spec["hsa-rocr-dev"].prefix.lib)
+ def setup_build_environment(self, env):
+ if self.spec.satisfies("+asan"):
+ env.set("CC", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("CXX", f"{self.spec['llvm-amdgpu'].prefix}/bin/clang")
+ env.set("ASAN_OPTIONS", "detect_leaks=0")
+ env.set("CFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("CXXFLAGS", "-fsanitize=address -shared-libasan")
+ env.set("LDFLAGS", "-fuse-ld=lld")
+
def cmake_args(self):
spec = self.spec
args = []