xref: /llvm-project/offload/test/offloading/static_linking.c (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compile-generic -DLIBRARY -c -o %t.o
2 // RUN: ar rcs %t.a %t.o
3 // RUN: %libomptarget-compile-generic %t.a && %libomptarget-run-generic 2>&1 | %fcheck-generic
4 
5 #ifdef LIBRARY
6 int x = 42;
7 #pragma omp declare target(x)
8 
foo()9 int foo() {
10   int value;
11 #pragma omp target map(from : value)
12   value = x;
13   return value;
14 }
15 #else
16 #include <stdio.h>
17 int foo();
18 
main()19 int main() {
20   int x = foo();
21 
22   // CHECK: PASS
23   if (x == 42)
24     printf("PASS\n");
25 }
26 #endif
27