Hi,
We have a problem with declare target variables in fortran modules, here is a
small reproducer:
+++++ share.f90:
module share
integer :: var_x
!$omp declare target(var_x)
end module
+++++ test.f90:
use share
var_x = 10
!$omp target update to(var_x)
end
+++++
$ gfortran -fopenmp -c share.f90
$ gfortran -fopenmp -c test.f90
$ gfortran -fopenmp share.o test.o
$ ./a.out
libgomp: Duplicate node
+++++
This happens because the var_x is added into offload tables for both share.o and
test.o. The patch below fixes this issue. Regtested on x86_64-linux and
i686-linux. However I'm not sure how to create a regression test, which would
compile 2 separate objects, and check run-time result.
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 707f62f..5929d92 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -173,7 +173,7 @@ varpool_node::get_create (tree decl)
node = varpool_node::create_empty ();
node->decl = decl;
- if ((flag_openacc || flag_openmp)
+ if ((flag_openacc || flag_openmp) && !DECL_EXTERNAL (decl)
&& lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
{
node->offloadable = 1;
Thanks,
-- Ilya