Skip to content

clr(hip): ABI clean up on MSVC and GCC - #9920

Merged
mikeqinamd merged 3 commits into
developfrom
users/mqin/abi-cleanup
Sep 17, 2026
Merged

mikeqinamd merged 3 commits into
developfrom
users/mqin/abi-cleanup

Conversation

@mikeqinamd

@mikeqinamd mikeqinamd commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

This PR cleans up a few ABI/API issues.

Motivation

Unwanted Symbols

Currently, we expose a few unwanted symbols, and this PR removes them.

  • Mangled version of hipExtModuleLaunchKernel and hipHccModuleLaunchKernel. They need to be extern "C".
  • __gnu_h2f_ieee and __gnu_f2h_ieee. These are from libgcc. We should not be providing these symbols.

MSVC Warning

Right now MSVC generates many warnings because of a cast from hipError_t to uint32_t. This PR uses C++ enum classes to fix this warning. This explicitly specifies that hipError_t should be a uint32_t, which makes the ABI clearer (under Windows).

Hidden Visibility by Default.

Under Linux, all symbols are visible by default. While this is the default behaviour, it can cause unwanted conflicts during loading (because ELF uses a flat namespace). This PR uses -fvisibililty=hidden to hide symbols by default.

To expose public APIs, we define HIP_PUBLIC_API as __attribute__((visibility=default)) so that the compiler can expose this during compilation phase. Under GCC, this is essential to prevent compiler from optimizing the function into internal linkage.

We also need to remove HIP_PUBLIC_API from the public header, since now this contains symbol visibility attribute and we do not want to force applications to export our symbols. This macro is moved to hip_internal.hpp and it's exclusively designed for HIP developers now: if you would like to implement a public API (in hip_runtime_api.h), include hip_internal.hpp and decorate your function with HIP_PUBLIC_API.

Issue Tracking

JIRAID : AIRUNTIME-2633 Close

Test Result

All tests link and pass fine. We shouldn't use the private ABI for tests.

Submission Checklist

@therock-pr-bot

therock-pr-bot Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/clr/hipamd/include/hip/amd_detail/amd_channel_descriptor.h, projects/clr/hipamd/src/hip_activity.cpp, projects/clr/hipamd/src/hip_deprecated_abi.cpp, projects/clr/hipamd/src/hip_global.cpp, projects/clr/hipamd/src/hip_intercept.cpp (+6 more); no test file found
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

@mikeqinamd mikeqinamd changed the title ABI clean up on MSVC and GCC clr(hip): ABI clean up on MSVC and GCC Aug 11, 2026
@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch from bc7f60d to a174c65 Compare August 18, 2026 18:02
@jungx098

Copy link
Copy Markdown
Contributor

@github-copilot review

@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch 2 times, most recently from 8a56a52 to 3095c53 Compare August 18, 2026 19:30
@kjayapra-amd

Copy link
Copy Markdown
Contributor

I agree with exposing a uniform "C" only interface.

But, we need to make sure the APIs were not exposed in C++ for a specific reason. @mangupta can you please confirm?

I believe this is also a breaking change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Cleans up HIP ABI exposure across MSVC and GCC builds.

Changes:

  • Gives hipError_t a fixed C++ underlying type.
  • Consolidates C-linkage kernel wrappers.
  • Configures runtime linkage and symbol visibility.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
projects/hip/include/hip/hip_runtime_api.h Updates hipError_t representation.
projects/clr/hipamd/src/hip_table_interface.cpp Adds C linkage to kernel APIs.
projects/clr/hipamd/src/hip_table_interface_c.cpp Removes duplicate wrappers.
projects/clr/hipamd/src/CMakeLists.txt Adjusts sources and visibility.
projects/clr/CMakeLists.txt Modernizes MSVC runtime selection.
Suppressed comments (1)

projects/clr/hipamd/src/hip_table_interface.cpp:2560

  • This moved definition likewise has no prior HIP_PUBLIC_API declaration in this translation unit (hip_ext.h:68-76 is not included). Once amdhip64 is compiled with hidden visibility, the deprecated but public C entry point cannot be exported by the version script. Give the definition default visibility or include the public declaration.
extern "C" hipError_t hipHccModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX,

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread projects/clr/CMakeLists.txt Resolved
Comment thread projects/clr/hipamd/src/CMakeLists.txt Resolved
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 20, 2026
@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch from e351f61 to 36d1f91 Compare August 28, 2026 14:57
@mikeqinamd
mikeqinamd requested a review from a team as a code owner August 28, 2026 14:57
@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch 2 times, most recently from 608fd87 to e3e62c3 Compare September 2, 2026 18:18
@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch from 129d34a to 2decb2f Compare September 11, 2026 19:18
warning clean up on MSVC
@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch 2 times, most recently from 03df86f to 648994a Compare September 14, 2026 20:18
@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch 2 times, most recently from e5dfbd7 to b86d492 Compare September 14, 2026 21:34
Comment thread projects/clr/hipamd/src/CMakeLists.txt Resolved
Previous attempt was broken and we need more work to enable this. This is because compilers under Linux are allowed to do crazy optimizations under `-fvisibility=hidden` and we need to make the compilers (not linkers) aware of public APIs.
@mikeqinamd
mikeqinamd force-pushed the users/mqin/abi-cleanup branch from f9ee3b3 to b025a8d Compare September 15, 2026 16:07
Comment thread projects/clr/hipamd/src/hip_hcc.map.in Resolved
@mikeqinamd

Copy link
Copy Markdown
Contributor Author

Here's what I use to dump the exported symbols.

(venv) mqin@canmkmqinlnx (git)-[main]!-% nm -D --defined-only hipamd/lib/libamdhip64.so | awk '$2 ~ /^[TWD]$/ {print $3}' | sort

Before and after this PR:

(venv) mqin@canmkmqinlnx (git)-[main]!-% diff -u old.txt new.txt
--- old.txt     2026-09-14 14:32:02.843411499 -0400
+++ new.txt     2026-09-14 16:11:16.036595112 -0400
@@ -1,8 +1,6 @@
 amd_dbgapi_get_build_id@@hip_4.5
 amd_dbgapi_get_build_name@@hip_4.5
 amd_dbgapi_get_git_hash@@hip_4.5
-__gnu_f2h_ieee@@hip_4.2
-__gnu_h2f_ieee@@hip_4.2
 hipApiName@@hip_4.2
 hipArray3DCreate@@hip_4.2
 hipArray3DGetDescriptor@@hip_5.6
@@ -565,5 +563,3 @@
 hipUserObjectRelease@@hip_5.3
 hipUserObjectRetain@@hip_5.3
 hipWaitExternalSemaphoresAsync@@hip_4.3
-_Z24hipExtModuleLaunchKernelP18ihipModuleSymbol_tjjjjjjmP12ihipStream_tPPvS4_P11ihipEvent_tS6_j@@hip_4.2
-_Z24hipHccModuleLaunchKernelP18ihipModuleSymbol_tjjjjjjmP12ihipStream_tPPvS4_P11ihipEvent_tS6_@@hip_4.2

@mikeqinamd
mikeqinamd merged commit f14e2d2 into develop Sep 17, 2026
75 of 93 checks passed
@mikeqinamd
mikeqinamd deleted the users/mqin/abi-cleanup branch September 17, 2026 18:04
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

@pfultz2

pfultz2 commented Sep 22, 2026

Copy link
Copy Markdown

Here's what I use to dump the exported symbols.

(venv) mqin@canmkmqinlnx (git)-[main]!-% nm -D --defined-only hipamd/lib/libamdhip64.so | awk '$2 ~ /^[TWD]$/ {print $3}' | sort

Before and after this PR:

(venv) mqin@canmkmqinlnx (git)-[main]!-% diff -u old.txt new.txt
--- old.txt     2026-09-14 14:32:02.843411499 -0400
+++ new.txt     2026-09-14 16:11:16.036595112 -0400
@@ -1,8 +1,6 @@
 amd_dbgapi_get_build_id@@hip_4.5
 amd_dbgapi_get_build_name@@hip_4.5
 amd_dbgapi_get_git_hash@@hip_4.5
-__gnu_f2h_ieee@@hip_4.2
-__gnu_h2f_ieee@@hip_4.2
 hipApiName@@hip_4.2
 hipArray3DCreate@@hip_4.2
 hipArray3DGetDescriptor@@hip_5.6
@@ -565,5 +563,3 @@
 hipUserObjectRelease@@hip_5.3
 hipUserObjectRetain@@hip_5.3
 hipWaitExternalSemaphoresAsync@@hip_4.3
-_Z24hipExtModuleLaunchKernelP18ihipModuleSymbol_tjjjjjjmP12ihipStream_tPPvS4_P11ihipEvent_tS6_j@@hip_4.2
-_Z24hipHccModuleLaunchKernelP18ihipModuleSymbol_tjjjjjjmP12ihipStream_tPPvS4_P11ihipEvent_tS6_@@hip_4.2

Doesnt this break ABI compatibility, shouldn't the major version be updated?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants