From 7a4df732e1a6b6eaf6d6a9675c5857e7e53d5445 Mon Sep 17 00:00:00 2001 From: Brian Van Essen Date: Thu, 9 Nov 2023 10:08:37 -0800 Subject: DiHydrogen, Hydrogen, and Aluminum CachedCMakePackage (#39714) --- lib/spack/spack/build_systems/cached_cmake.py | 16 +++++++++++++++- lib/spack/spack/package.py | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/cached_cmake.py b/lib/spack/spack/build_systems/cached_cmake.py index d85c2b7e19..74304f1dc6 100644 --- a/lib/spack/spack/build_systems/cached_cmake.py +++ b/lib/spack/spack/build_systems/cached_cmake.py @@ -34,6 +34,11 @@ def cmake_cache_option(name, boolean_value, comment="", force=False): return 'set({0} {1} CACHE BOOL "{2}"{3})\n'.format(name, value, comment, force_str) +def cmake_cache_filepath(name, value, comment=""): + """Generate a string for a cmake cache variable of type FILEPATH""" + return 'set({0} "{1}" CACHE FILEPATH "{2}")\n'.format(name, value, comment) + + class CachedCMakeBuilder(CMakeBuilder): #: Phases of a Cached CMake package #: Note: the initconfig phase is used for developer builds as a final phase to stop on @@ -257,6 +262,15 @@ class CachedCMakeBuilder(CMakeBuilder): entries.append( cmake_cache_path("HIP_CXX_COMPILER", "{0}".format(self.spec["hip"].hipcc)) ) + llvm_bin = spec["llvm-amdgpu"].prefix.bin + llvm_prefix = spec["llvm-amdgpu"].prefix + # Some ROCm systems seem to point to //rocm-/ and + # others point to //rocm-/llvm + if os.path.basename(os.path.normpath(llvm_prefix)) != "llvm": + llvm_bin = os.path.join(llvm_prefix, "llvm/bin/") + entries.append( + cmake_cache_filepath("CMAKE_HIP_COMPILER", os.path.join(llvm_bin, "clang++")) + ) archs = self.spec.variants["amdgpu_target"].value if archs[0] != "none": arch_str = ";".join(archs) @@ -277,7 +291,7 @@ class CachedCMakeBuilder(CMakeBuilder): "#------------------{0}".format("-" * 60), "# CMake executable path: {0}".format(self.pkg.spec["cmake"].command.path), "#------------------{0}\n".format("-" * 60), - cmake_cache_path("CMAKE_PREFIX_PATH", cmake_prefix_path), + cmake_cache_string("CMAKE_PREFIX_PATH", cmake_prefix_path), self.define_cmake_cache_from_variant("CMAKE_BUILD_TYPE", "build_type"), ] diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index c537a7103a..ee6fb0ed8c 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -32,6 +32,7 @@ from spack.build_systems.autotools import AutotoolsPackage from spack.build_systems.bundle import BundlePackage from spack.build_systems.cached_cmake import ( CachedCMakePackage, + cmake_cache_filepath, cmake_cache_option, cmake_cache_path, cmake_cache_string, -- cgit v1.2.3-70-g09d2