llvm / llvm/llvm-project

[OpenMP] offload duplicate symbol issue when the same library appears twice on the link line

Open
#198,017 5 comments 0 reactions 1 assignee Claimed by @syhhyl View on GitHub
openmp
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.