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>
foo()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>
main(int argc,char ** argv)14 int main(int argc, char **argv) {
15   void *Handle = dlopen(argv[1], RTLD_NOW);
16   int (*Foo)(void);
17 
18   if (Handle == NULL) {
19     printf("dlopen() failed: %s\n", dlerror());
20     return 1;
21   }
22   Foo = (int (*)(void)) dlsym(Handle, "foo");
23   if (Handle == NULL) {
24     printf("dlsym() failed: %s\n", dlerror());
25     return 1;
26   }
27   // CHECK: DONE.
28   // CHECK-NOT: {{abort|fault}}
29   return Foo();
30 }
31 #endif
32