Skip to content

Fix wrong hip compiler in subproject#4663

Open
macurtis-amd wants to merge 1 commit intoROCm:mainfrom
macurtis-amd:fix-wrong-hip-compiler
Open

Fix wrong hip compiler in subproject#4663
macurtis-amd wants to merge 1 commit intoROCm:mainfrom
macurtis-amd:fix-wrong-hip-compiler

Conversation

@macurtis-amd
Copy link
Copy Markdown

Motivation

If CMAKE_HIP_COMPILER is not set, sub-projects will incorrectly find /opt/rocm*/lib/llvm/bin/clang++.

This may causes a build failure if the installed compiler is missing features needed by the sub-project.

I was seeing:

FAILED: catch_tests/unit/rtc/CMakeFiles/RTC.dir/RtcFunctions.cpp.o
/opt/rocm-7.1.1/lib/llvm/bin/clang++  ...
In file included from .../rocm-systems/projects/hip-tests/catch/unit/rtc/RtcFunctions.cpp:14:
In file included from .../core/clr/dist/include/hip/hip_fp16.h:13:
.../core/clr/dist/include/hip/amd_detail/amd_hip_fp16.h:952:21: error: use of undeclared identifier '__builtin_elementwise_exp10'
  952 |   return __half_raw{__builtin_elementwise_exp10(static_cast<__half_raw>(x).data)};
      |                     ^

Technical Details

Sets HIP-specific variables to the corresponding CXX variable for amd-hip toolchains.

Test Plan

Test Result

Submission Checklist

If CMAKE_HIP_COMPILER is not set, sub-projects will incorrectly find
/opt/rocm*/lib/llvm/bin/clang++.

This may causes a build failure if the installed compiler is missing features
needed by the sub-project.

I was seeing:

```
FAILED: catch_tests/unit/rtc/CMakeFiles/RTC.dir/RtcFunctions.cpp.o
/opt/rocm-7.1.1/lib/llvm/bin/clang++  ...
In file included from .../rocm-systems/projects/hip-tests/catch/unit/rtc/RtcFunctions.cpp:14:
In file included from .../core/clr/dist/include/hip/hip_fp16.h:13:
.../core/clr/dist/include/hip/amd_detail/amd_hip_fp16.h:952:21: error: use of undeclared identifier '__builtin_elementwise_exp10'
  952 |   return __half_raw{__builtin_elementwise_exp10(static_cast<__half_raw>(x).data)};
      |                     ^
```
@macurtis-amd macurtis-amd force-pushed the fix-wrong-hip-compiler branch from 73285d9 to 1969318 Compare April 20, 2026 11:25
Comment on lines +1604 to +1605
string(APPEND _toolchain_contents "set(CMAKE_HIP_COMPILER \"\${CMAKE_CXX_COMPILER}\")\n")
string(APPEND _toolchain_contents "set(CMAKE_HIP_FLAGS_INIT \"\${CMAKE_CXX_FLAGS_INIT}\")\n")
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.

If CMAKE_HIP_COMPILER is not set, sub-projects will incorrectly find /opt/rocm*/lib/llvm/bin/clang++.

Including these options here in TheRock is fine, but I suspect we should also fix this somehow in the rocm projects themselves. See #3976 for a description of the broader problem. Discovering a (likely different/mismatched) tool from somewhere on the system other than the current install could be more risky than just raising an exception and requiring setting it explicitly (like what this PR does).

Do you know where this CMAKE_HIP_COMPILER is falling back to /opt/rocm/ if unset?

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

Labels

None yet

Projects

Status: TODO

Development

Successfully merging this pull request may close these issues.

2 participants