Issue |
152360
|
Summary |
Compilation of a valid OpenMP program fails with linker error
|
Labels |
openmp:libomp,
openmp:libomptarget
|
Assignees |
|
Reporter |
jprotze
|
```
#include <omp.h>
#include <stdio.h>
int main(int argc, char **argv) {
printf("omp_target_is_present(%p, %i): %i\n", argv, omp_get_initial_device(),
omp_target_is_present(argv, omp_get_initial_device()));
return 0;
}
```
Compiling the program results in a linker error:
```
$ clang -fopenmp omp_target_is_present.c
/usr/bin/ld: /tmp/omp_target_is_present-96f7d7.o: in function `main':
omp_target_is_present.c:(.text+0x3a): undefined reference to `omp_target_is_present'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```
Expected behavior: Clang should compile and link all valid OpenMP programs with `-fopenmp` flag.
Solution: libomp should implement (weak) stub versions of all target-related functions. If we don't want to pay the cost of propagating the function calls from libomp to libomptarget (as for example currently done for `omp_get_initial_device()`), we could simply change the link ordering and link libomptarget before libomp.
@mjklemm @jhuber6 @Meinersbur what do you think?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs