diff options
author | afzpatel <122491982+afzpatel@users.noreply.github.com> | 2024-03-27 12:40:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-27 09:40:21 -0700 |
commit | 6d4dd33c46d736ff46313f871486fe974c9e2612 (patch) | |
tree | 132d3aa07cc716a6753566be7e4c8531c8eb778b /lib | |
parent | 579bad05a8e6f5d6d8ce474ecc35f5507fef8ecf (diff) | |
download | spack-6d4dd33c46d736ff46313f871486fe974c9e2612.tar.gz spack-6d4dd33c46d736ff46313f871486fe974c9e2612.tar.bz2 spack-6d4dd33c46d736ff46313f871486fe974c9e2612.tar.xz spack-6d4dd33c46d736ff46313f871486fe974c9e2612.zip |
Enable ASAN in ROCm packages (#42704)
* Initial commit to enable ASAN
* fix styling
* fix styling
* add asan option for hip-tensor and roctracer-dev
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_systems/rocm.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/spack/spack/build_systems/rocm.py b/lib/spack/spack/build_systems/rocm.py index a986c5e5b9..440cab7fde 100644 --- a/lib/spack/spack/build_systems/rocm.py +++ b/lib/spack/spack/build_systems/rocm.py @@ -75,6 +75,8 @@ # does not like its directory structure. # +import os + import spack.variant from spack.directives import conflicts, depends_on, variant from spack.package_base import PackageBase @@ -154,6 +156,32 @@ class ROCmPackage(PackageBase): archs = ",".join(amdgpu_target) return "--amdgpu-target={0}".format(archs) + # ASAN + @staticmethod + def asan_on(env, llvm_path): + env.set("CC", llvm_path + "/bin/clang") + env.set("CXX", llvm_path + "/bin/clang++") + env.set("ASAN_OPTIONS", "detect_leaks=0") + + for root, dirs, files in os.walk(llvm_path): + if "libclang_rt.asan-x86_64.so" in files: + asan_lib_path = root + env.prepend_path("LD_LIBRARY_PATH", asan_lib_path) + SET_DWARF_VERSION_4 = "" + try: + # This will throw an error if imported on a non-Linux platform. + import distro + + distname = distro.id() + except ImportError: + distname = "unknown" + if "rhel" in distname or "sles" in distname: + SET_DWARF_VERSION_4 = "-gdwarf-5" + + env.set("CFLAGS", "-fsanitize=address -shared-libasan -g " + SET_DWARF_VERSION_4) + env.set("CXXFLAGS", "-fsanitize=address -shared-libasan -g " + SET_DWARF_VERSION_4) + env.set("LDFLAGS", "-Wl,--enable-new-dtags -fuse-ld=lld -fsanitize=address -g -Wl,") + # HIP version vs Architecture # TODO: add a bunch of lines like: |