Hi all, it turned out that 'declare target' with 'link' clause was broken in multiple ways. The main fix is the attached patch, i.e. namely pushing the variables already to the offload-vars list already in the FE. When implementing it, I noticed: * C has a similar issue when using nested functions, which is a GNU extension →https://gcc.gnu.org/115574 * When doing partial mapping of arrays (which is one of the reasons for 'link'), offsets are mishandled in Fortran (not tested in C), see FIXME in the patch) There: arr2(10) should print 10 but with map(arr2(10:)) it prints 19. (I will file a PR about this). * It might happen that linked variables do not get linked. I have not investigated why, but 'arr2' gives link errors – while 'arr' works. See FIXME in the patch. (I will file a PR about this) * For COMMON blocks, map(/common/) is rejected,https://gcc.gnu.org/PR115577 * When then mapping map(a,b,c) which is identical for 'common /mycom/ a,b,c', it fails to link the device side as the 'mycom_' symbol cannot be found on the device side. (I will file a PR about this) As COMMON as issues, an alternative would be to defer the trans-common.cc changes to a later patch. Comments, questions, concerns? Tobias PS: Tested with nvptx offloading with a page-migration supporting system with nvptx and GCN offloading configured and no new fails observed.