Hello everyone, I have a larger program that I am trying to convert so that the computationally intensive part will run on an NVidia GPU using OpenMP. However, I am running into trouble when compiling the program. The part of the program to run on the GPU contains calls to subroutines, where variables declared in a separate module are used. This seems to be creating issues. I have reduced the problem to the attached files. I compile as follows: gfortran test_link.f90 common_vars.f90 parameters.f90 -O0 -fopenmp -Wall -Wextra -o test_link With the file test_link.f90 as attached, the program compiles and runs without a problem. If I remove the comments for the subroutine TEST() and comment out line 31 in test_link.f90 (the line "I = NR") the compilation gives the following error: ptxas /tmp/ccw3FqJD.o, line 52; error   : Illegal operand type to instruction 'ld' ptxas /tmp/ccw3FqJD.o, line 52; error   : Unknown symbol '__common_vars_MOD_nr$linkptr' ptxas fatal   : Ptx assembly aborted due to errors nvptx-as: ptxas returned 255 exit status mkoffload: fatal error: /home/myself/apps/gcc-10.2.0/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc returned 1 exit status compilation terminated. lto-wrapper: fatal error: /home/myself/apps/gcc-10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0//accel/nvptx-none/mkoffload returned 1 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status Is this a bug in gfortran or have I misunderstood how DECLARE TARGET LINK works in combination with using subroutines? And a last point: If I use -O3 during compilation the program compiles and runs fine in both cases. I assume that TEST() is inlined in this case and the error disappears? Any help to overcome this issue is more than welcome. Best regards, Ioannis E. Venetis PS1: The problem happens with gcc 10.2 that I compiled myself: $ ~/apps/gcc-10.2.0/bin/gfortran -v Using built-in specs. COLLECT_GCC=/home/myself/apps/gcc-10.2.0/bin/gfortran COLLECT_LTO_WRAPPER=/home/myself/apps/gcc-10.2.0/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-pc-linux-gnu Configured with: ../gcc-10.2.0/configure --enable-offload-targets=nvptx-none --with-cuda-driver-include=/usr/local/cuda/include --with-cuda-driver-lib=/usr/local/cuda/lib64 --disable-bootstrap --disable-multilib --enable-languages=c,c++,fortran,lto --prefix=/home/myself/apps/gcc-10.2.0 Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (GCC) PS2: Same problem also happens with gcc 9.3 as installed on Ubuntu 16.04 from apt: $ gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2~16.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2~16.04)