Skip to content

[WIP] hip-lang support - #4411

Open
scheibelp wants to merge 70 commits into
spack:developfrom
scheibelp:hip-lang
Open

[WIP] hip-lang support#4411
scheibelp wants to merge 70 commits into
spack:developfrom
scheibelp:hip-lang

Conversation

@scheibelp

@scheibelp scheibelp commented Apr 20, 2026

Copy link
Copy Markdown
Member

Apply changes from spack/spack#49673 that apply to spack-packages.

Needs

Notes:

  • HIP language support spack#49673 changed SPACK_TEST_COMMAND=dump-env to dump-var, but that would be harder to change (the tests that use this are in spack-core ) and it didn't look essential
  • I edited a few cases of requires("%[virtuals=c,cxx] llvm-amdgpu") to include when='%c' to accommodate externals that do not specify a compiler (and in a couple cases I swapped requires for depends_on for the same reason)

Other than that this should be a copy of spack/spack#49673

@spackbot-triage spackbot-triage Bot added dependencies Modifications with a `depends_on()` directive virtual-dependencies Modifications to virtual package dependencies update-package Modifications to packages in the repository labels Apr 20, 2026
Apply changes from spack/spack#49673 that apply to
spack-packages.

Co-authored-by: Peter Scheibel <scheibel1@llnl.gov>
Signed-off-by: Peter Josef Scheibel <scheibel1@llnl.gov>
@scheibelp

Copy link
Copy Markdown
Member Author

This will have to update the Spack commit used in .ci/env to use at least a5b4056 (from March 27) to pass the package audit (Currently pinned to a commit from March 20)

@haampie

haampie commented Apr 21, 2026

Copy link
Copy Markdown
Member

You have to bump the package api

Signed-off-by: Peter Josef Scheibel <scheibel1@llnl.gov>
…rom spack core

Signed-off-by: Peter Josef Scheibel <scheibel1@llnl.gov>
@scheibelp
scheibelp requested a review from a team as a code owner April 21, 2026 18:28
… as of March 26, preceding new commit that is used)

Signed-off-by: Peter Josef Scheibel <scheibel1@llnl.gov>
@spackbot-triage spackbot-triage Bot added the tests General test capability(ies) label Apr 21, 2026
Signed-off-by: Peter Josef Scheibel <scheibel1@llnl.gov>
Comment thread repos/spack_repo/builtin/build_systems/rocm.py Outdated
Signed-off-by: Peter Josef Scheibel <scheibel1@llnl.gov>
@spackbot-triage
spackbot-triage Bot requested a review from haampie April 21, 2026 22:51
depends_on("zlib-api", type="link")
depends_on("z3", type="link")
depends_on("ncurses", type="link")
requires("%[virtuals=c,cxx] llvm-amdgpu", when="%c")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The when=%c can be dropped here and elsewhere, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to be able to create a comgr external without having to specify %llvm-amdgpu on the spec

@alalazo alalazo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the comment, we may want to delay merging this, so that the next release of the repository is still readable by Spack v1.1

Comment thread repos/spack_repo/builtin/repo.yaml Outdated
Signed-off-by: Peter Josef Scheibel <scheibel1@llnl.gov>
Comment thread stacks/e4s/spack.yaml
Comment on lines +381 to +383
- adios2 +kokkos +rocm
- amrex +rocm
- arborx +rocm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is +rocm added if it's also under all:prefer?

Returns the path to libclang_rt.builtins-x86_64.a by running
amdclang++ --print-resource-dir and searching for the library.
"""
import llnl.util.filesystem as fs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not import anything besides spack.package. This modules doesn't even exist. Why did that not break for you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you hard-code an architecture? Looks wrong/unnecessary.

"7.13.0",
]:
# llvm libs are linked statically, so this *could* be a build dep
# in reality this should be a link type dep, but libLLVM is linked statically,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm-amdgpu is a link dep here, the rephrased comment suggests it's not. Better to leave the comment as it was.

Comment thread repos/spack_repo/builtin/packages/legion/package.py Outdated
c_names = ["amdclang"]
cxx_names = ["amdclang++"]
fortran_names = ["amdflang"]
hip_lang_names = ["amdclang++"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shadows cxx_names, so you end up with compilers detected for the languages c, fortran, hip-lang, but cxx will be missing.

def hip(self) -> Optional[str]:
assert self.spec.concrete, "cannot retrieve HIP compiler, spec is not concrete"
if self.spec.external:
return self.spec.extra_attributes["compilers"].get("hip", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is "hip" but in detection it's "hip-lang".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, extra_attributes["compilers"] is used here which is not consistent with the defensive extra_attributes.get("compiler", {}) elsewhere. I think the defensive version is better.

return "."

def setup_build_environment(self, env: EnvironmentModifications) -> None:
env.set("CXX", self.spec["hip"].hipcc)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with rocblas/rocsolver, why remove this only here?

return None

@property
def hip(self) -> Optional[str]:

@haampie haampie Aug 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it useful to add this and produce str | None? It looks brittle. In particular I think you now run in a potential TypeError in compiler-wrapper when it is None in the _var_list.append(("hip-lang", "hip", "HIPCXX", "SPACK_HIPCXX")) bit.

In the GCC package we have the invariant that if languages=c then c is provided. Here you have something like hip is maybe provided. Would be good to make the None state impossible.

@haampie

haampie commented Aug 12, 2026

Copy link
Copy Markdown
Member

Can you extract changes that are not related to hip-lang as a virtual? That makes reverts easier.

@spackbot-triage
spackbot-triage Bot requested a review from haampie August 13, 2026 02:16
rbberger pushed a commit that referenced this pull request Aug 19, 2026
* extract legion changes for rocm build from #4411

* this issue has been fixed for legion after 26.06
Comment on lines +145 to +148
needs: [hip-compiler]
- group: hip-compiler
specs:
- llvm-amdgpu

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-systems Related to package build systems dependencies Modifications with a `depends_on()` directive don't-merge-yet new-version Modifications to packages' `depends_on()` directives update-package Modifications to packages in the repository virtual-dependencies Modifications to virtual package dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.