<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117369>117369</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang][OpenMP] Weak alias fails on OpenMP targets
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Jason-VanBeusekom
</td>
</tr>
</table>
<pre>
Reproducer test file:
```
int __One(void) { return 1; }
int One(void) __attribute__ ((weak, alias("__One")));
int main(){
return One();
}
```
When compiling:
```
clang -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa test.c
test.c:3:37: error: alias must point to a defined variable or function
3 | int One(void) __attribute__ ((weak, alias("__One")));
| ^
test.c:3:37: note: the function or variable specified in an alias must refer to its mangled name
test.c:3:37: note: function by that name is mangled as "__One"
3 | int One(void) __attribute__ ((weak, alias("__One")));
| ^~~~~~~~~~~~~~
| alias("__One")
test.c:3:37: error: alias must point to a defined variable or function
3 | int One(void) __attribute__ ((weak, alias("__One")));
| ^
test.c:3:37: note: the function or variable specified in an alias must refer to its mangled name
test.c:3:37: note: function by that name is mangled as "__One"
3 | int One(void) __attribute__ ((weak, alias("__One")));
| ^~~~~~~~~~~~~~
| alias("__One")
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /ptmp2/vanbeuse-ptmp2/clang_install/bin/clang-20 -cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -Werror=atomic-alignment -emit-llvm-bc -emit-llvm-uselists -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name test.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/ocml.bc -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/oclc_daz_opt_off.bc -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/oclc_unsafe_math_off.bc -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/oclc_finite_only_off.bc -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/oclc_wavefrontsize64_on.bc -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/oclc_isa_version_908.bc -mlink-builtin-bitcode /opt/rocm-6.2.0/amdgcn/bitcode/oclc_abi_version_500.bc -target-cpu gfx908 -debugger-tuning=gdb -fdebug-compilation-dir=/ptmp2/vanbeuse-ptmp2/CAST-30331 -resource-dir /ptmp2/vanbeuse-ptmp2/clang_install/lib/clang/20 -internal-isystem /ptmp2/vanbeuse-ptmp2/clang_install/lib/clang/20/include/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem /ptmp2/vanbeuse-ptmp2/clang_install/lib/clang/20/include/llvm_libc_wrappers -internal-isystem /ptmp2/vanbeuse-ptmp2/clang_install/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /ptmp2/vanbeuse-ptmp2/clang_install/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fvisibility=protected -fopenmp -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -fopenmp-is-target-device -fopenmp-host-ir-file-path /tmp/test-3dcfd8.bc -faddrsig -o /tmp/test-223d72.bc -x c test.c
1. <eof> parser at end of file
2. Per-file LLVM IR generation
#0 0x00007fe39a249c1d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /ptmp2/vanbeuse-ptmp2/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
#1 0x00007fe39a24a0db PrintStackTraceSignalHandler(void*) /ptmp2/vanbeuse-ptmp2/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x00007fe39a24827f llvm::sys::RunSignalHandlers() /ptmp2/vanbeuse-ptmp2/llvm-project/llvm/lib/Support/Signals.cpp:105:5
#3 0x00007fe39a24a7ae SignalHandler(int) /ptmp2/vanbeuse-ptmp2/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007fe397a3fdc0 __restore_rt (/lib64/libc.so.6+0x4adc0)
#5 0x00007fe3a1efe2fc llvm::Value::getType() const /ptmp2/vanbeuse-ptmp2/llvm-project/llvm/include/llvm/IR/Value.h:255:34
#6 0x00007fe3a1f8bff5 llvm::GlobalValue::getType() const /ptmp2/vanbeuse-ptmp2/llvm-project/llvm/include/llvm/IR/GlobalValue.h:294:65
#7 0x00007fe3a287ddbc clang::CodeGen::CodeGenModule::checkAliases() /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:736:61
#8 0x00007fe3a287f0bc clang::CodeGen::CodeGenModule::Release() /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:898:3
#9 0x00007fe3a2a652dd (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:0:18
#10 0x00007fe3a28401e5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:273:10
#11 0x00007fe391c28e4b clang::ParseAST(clang::Sema&, bool, bool) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/Parse/ParseAST.cpp:191:12
#12 0x00007fe39ed0b057 clang::ASTFrontendAction::ExecuteAction() /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1193:1
#13 0x00007fe3a2844692 clang::CodeGenAction::ExecuteAction() /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1140:5
#14 0x00007fe39ed0aab2 clang::FrontendAction::Execute() /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1081:7
#15 0x00007fe39ec06ff5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1062:23
#16 0x00007fe3a34292ba clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:296:8
#17 0x00000000002487e8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/tools/driver/cc1_main.cpp:286:13
#18 0x000000000023b8ae ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/tools/driver/driver.cpp:218:5
#19 0x000000000023a652 clang_main(int, char**, llvm::ToolContext const&) /ptmp2/vanbeuse-ptmp2/llvm-project/clang/tools/driver/driver.cpp:259:5
#20 0x000000000026cc45 main /ptmp2/vanbeuse-ptmp2/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:17:3
#21 0x00007fe397a2a24d __libc_start_main (/lib64/libc.so.6+0x3524d)
#22 0x000000000023a11a _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 20.0.0git
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /ptmp2/vanbeuse-ptmp2/clang_install/bin
Build config: +uno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