On Tue, Jun 17, 2025 at 10:07:04AM +0200, Tobias Burnus wrote:
> --- a/gcc/omp-offload.cc
> +++ b/gcc/omp-offload.cc
> @@ -261,7 +261,8 @@ omp_discover_declare_target_tgt_fn_r (tree *tp, int
> *walk_subtrees, void *data)
> DECL_ATTRIBUTES (decl)))
> return NULL_TREE;
>
> - if (!DECL_EXTERNAL (decl) && DECL_SAVED_TREE (decl))
> + if (DECL_SAVED_TREE (decl)
> + && (!DECL_EXTERNAL (decl) || DECL_DECLARED_INLINE_P (decl)))
> ((vec<tree> *) data)->safe_push (decl);
> DECL_ATTRIBUTES (decl) = tree_cons (id, NULL_TREE,
> DECL_ATTRIBUTES (decl));
This looks ok to me.
> diff --git a/libgomp/testsuite/libgomp.c++/declare_target-2.C
> b/libgomp/testsuite/libgomp.c++/declare_target-2.C
> new file mode 100644
> index 00000000000..6d6c94c514d
> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.c++/declare_target-2.C
> @@ -0,0 +1,30 @@
> +// { dg-do link }
> +
> +// Actually not needed: -fipa-cp is default with -O2:
> +// { dg-additional-options "-O2 -fipa-cp -foffload=amdgcn-amdhsa" }
But am not sure how this will work if amdgcn offloading is not configured.
> +// The code failed because 'std::endl' becoḿes implicitly 'declare target'
> +// but not the 'widen' function it calls. While the linker had no issues
> +// (endl is never called, either because it is inlined or optimized away),
> +// the IPA-CP (enabled by -O2 and higher) failed as the definition for
> +// 'widen' did not exist on the offload side.
> +
> +// Nvptx fails because of PR libstdc++/120680
> +// { dg-bogus "_ZN9__gnu_cxx21zoneinfo_dir_overrideEv" "" { xfail
> offload_target_nvptx } 0 }
> +// { dg-xfail-if "PR120680" { offload_target_nvptx } }
And why are the xfails needed for nvptx when -foffload is passed for some
other offload target.
Jakub