1 | // RUN: %libomptarget-compile-generic -DSHARED -fPIC -shared -o %t.so && %clang %flags %s -o %t -ldl && %libomptarget-run-generic %t.so 2>&1 | %fcheck-generic |
2 | |
3 | #ifdef SHARED |
4 | #include <stdio.h> |
5 | int foo() { |
6 | #pragma omp target |
7 | ; |
8 | printf("%s\n" , "DONE." ); |
9 | return 0; |
10 | } |
11 | #else |
12 | #include <dlfcn.h> |
13 | #include <stdio.h> |
14 | int main(int argc, char **argv) { |
15 | #pragma omp target |
16 | ; |
17 | |
18 | void *Handle = dlopen(file: argv[1], RTLD_NOW); |
19 | int (*Foo)(void); |
20 | |
21 | if (Handle == NULL) { |
22 | printf(format: "dlopen() failed: %s\n" , dlerror()); |
23 | return 1; |
24 | } |
25 | Foo = (int (*)(void))dlsym(handle: Handle, name: "foo" ); |
26 | if (Handle == NULL) { |
27 | printf(format: "dlsym() failed: %s\n" , dlerror()); |
28 | return 1; |
29 | } |
30 | // CHECK: DONE. |
31 | // CHECK-NOT: {{abort|fault}} |
32 | return Foo(); |
33 | } |
34 | #endif |
35 | |