Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions repos/spack_repo/builtin/packages/hip/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,10 @@ def set_variables(self, env):
# to the hip prefix directory for non-external builds so that the
# bin/.hipVersion file can still be parsed.
# See also https://github.com/ROCm/HIP/issues/2223
env.append_path(
"HIPCC_COMPILE_FLAGS_APPEND", f"--rocm-path={paths['rocm-path']}", separator=" "
)
env.append_path(
"HIPCC_LINK_FLAGS_APPEND", f"--rocm-path={paths['rocm-path']}", separator=" "
)
env.append_path(
"HIPCC_COMPILE_FLAGS_APPEND",
f"-isystem {paths['rocm-core']}/include",
separator=" ",
env.append_flags("HIPCC_COMPILE_FLAGS_APPEND", f"--rocm-path={paths['rocm-path']}")
env.append_flags("HIPCC_LINK_FLAGS_APPEND", f"--rocm-path={paths['rocm-path']}")
env.append_flags(
"HIPCC_COMPILE_FLAGS_APPEND", f"-isystem {paths['rocm-core']}/include"
)
elif self.spec.satisfies("+cuda"):
env.set("CUDA_PATH", self.spec["cuda"].prefix)
Expand All @@ -427,17 +421,19 @@ def set_variables(self, env):
# being used to compile. This is only important for external ROCm
# installations, which may otherwise pick up the wrong GCC toolchain.
if self.spec.external and self.spec.satisfies("%gcc"):
# This is picked up by hipcc.
env.append_path(
"HIPCC_COMPILE_FLAGS_APPEND",
f"--gcc-toolchain={self.compiler.prefix}",
separator=" ",
)
env.append_path(
"HIPCC_LINK_FLAGS_APPEND", f"--gcc-toolchain={self.compiler.prefix}", separator=" "
gcc = Executable(self.compiler.cc)
libgcc_path = gcc("-print-file-name=libgcc.a", output=str, fail_on_error=False).strip()
libgcc_dir = os.path.abspath(os.path.dirname(libgcc_path))
gcc_install_dir_flag = (
f"--gcc-install-dir={libgcc_dir}" if os.path.exists(libgcc_dir) else None
)
# This is picked up by CMake when using HIP as a CMake language.
env.append_path("HIPFLAGS", f"--gcc-toolchain={self.compiler.prefix}", separator=" ")

if gcc_install_dir_flag:
# This is picked up by hipcc.
env.append_flags("HIPCC_COMPILE_FLAGS_APPEND", gcc_install_dir_flag)
env.append_flags("HIPCC_LINK_FLAGS_APPEND", gcc_install_dir_flag)
# This is picked up by CMake when using HIP as a CMake language.
env.append_flags("HIPFLAGS", gcc_install_dir_flag)

def setup_build_environment(self, env: EnvironmentModifications) -> None:
self.set_variables(env)
Expand Down
Loading