[compiler-rt] [UBSan][Offload] Guard musttail for PowerPC in dlsym interceptor (PR #224273)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 04:42:25 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Midhunesh (midhuncodes7)
<details>
<summary>Changes</summary>
`[[clang::musttail]]` in the offload `dlsym` interceptor fails to build on PowerPC — indirect/external tail calls aren't supported on PPC (Linux or AIX). Guard it behind `#if defined(__powerpc__)`, falling back to a normal call there. No behavior change on x86_64/aarch64; no existing tests cover this file.
---
Full diff: https://github.com/llvm/llvm-project/pull/224273.diff
1 Files Affected:
- (modified) compiler-rt/lib/ubsan/offload/ubsan_offload_hsa_interceptors.cpp (+11-1)
``````````diff
diff --git a/compiler-rt/lib/ubsan/offload/ubsan_offload_hsa_interceptors.cpp b/compiler-rt/lib/ubsan/offload/ubsan_offload_hsa_interceptors.cpp
index 5f251c2fc2a3ab..b186350143d2ff 100644
--- a/compiler-rt/lib/ubsan/offload/ubsan_offload_hsa_interceptors.cpp
+++ b/compiler-rt/lib/ubsan/offload/ubsan_offload_hsa_interceptors.cpp
@@ -93,6 +93,15 @@ static bool FromHsa(void *P) {
static void BindRealDlsym();
+// Guaranteed tail calls to external/indirect functions are not supported by
+// the PowerPC backend (both AIX and Linux), so 'musttail' cannot be used
+// there. Fall back to an ordinary call on that target.
+#if defined(__powerpc__)
+#define UBSAN_DLSYM_MUSTTAIL
+#else
+#define UBSAN_DLSYM_MUSTTAIL [[clang::musttail]]
+#endif
+
// OpenMP and sometimes HIP access HSA through 'dlsym' so we need to intercept
// it here if we want to reliably override its definitions.
INTERCEPTOR(void *, dlsym, void *Handle, const char *Name) {
@@ -101,7 +110,7 @@ INTERCEPTOR(void *, dlsym, void *Handle, const char *Name) {
// This interceptor interferes with the order of 'RTLD_NEXT'. Force a tail
// call to bypass this process in the stack.
- if (Handle == RTLD_NEXT) [[clang::musttail]]
+ if (Handle == RTLD_NEXT) UBSAN_DLSYM_MUSTTAIL
return REAL(dlsym)(Handle, Name);
void *Sym = REAL(dlsym)(Handle, Name);
@@ -113,6 +122,7 @@ INTERCEPTOR(void *, dlsym, void *Handle, const char *Name) {
return Sym;
return Wrapper;
}
+#undef UBSAN_DLSYM_MUSTTAIL
static void BindRealDlsym() {
if (LIKELY(REAL(dlsym)))
``````````
</details>
https://github.com/llvm/llvm-project/pull/224273
More information about the llvm-commits
mailing list