[OpenMP] offload duplicate symbol issue when the same library appears twice on the link line
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
It seems that the issue is not just in flang #195188
foo.cpp
```
#pragma omp declare target
int aa;
#pragma omp end declare target
void foo()
{
aa = 1;
}
```
main.cpp
```
extern int aa;
void foo();
int main()
{
aa = 1;
foo();
}
```
run_clang.sh
```
clang++ -fopenmp --offload-arch=gfx906 foo.cpp -c
rm foo.a
ar qc foo.a foo.o
ranlib foo.a
clang++ -fopenmp --offload-arch=gfx906 main.cpp foo.a foo.a
```
failure
```bash
$ bash run_clang.sh
ld.lld: error: duplicate symbol: aa
>>> defined in /tmp/foo-amdgcn-amd-amdhsa-gfx906-18599b.o
>>> defined in /tmp/foo-amdgcn-amd-amdhsa-gfx906-c89a83.o
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)
/soft/llvm/main-20260413/bin/clang-linker-wrapper: error: 'clang' failed
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```
Contributor guide
Assessment
This issue has not been assessed yet.