On 4/22/25 11:04 AM, Tobias Burnus wrote:
Jason Merrill wrote:
This is OK with a FIXME; presumably if we want to support running
static constructors on the offload target we will eventually want to
support that in modules as well.
Well, the code that added support for static constructors
on the offload target exposed the issue. Thus, GCC already
supports this (but not in combination of modules).
The current patch is surely useful as it avoids issues
even when there is actually no constructor on the offload
side.
The question is why does this code trigger at all, given
that there is OpenMP but no offload code at all? And how
to fix it in case there is offload code and modules are used.
This seems to be because of:
if (module_global_init_needed ())
{
// Make sure there's a default priority entry.
if (!static_init_fini_fns[true])
static_init_fini_fns[true] = priority_map_t::create_ggc ();
if (static_init_fini_fns[true]->get_or_insert (DEFAULT_INIT_PRIORITY))
has_module_inits = true;
if (flag_openmp)
{
if (!static_init_fini_fns[2 + true])
static_init_fini_fns[2 + true] = priority_map_t::create_ggc ();
static_init_fini_fns[2 + true]->get_or_insert (DEFAULT_INIT_PRIORITY);
}
}
Here we're forcing a target module init function as well as host. If we
remove the flag_openmp block, Nathaniel's patch is unnecessary (but may
still be desirable).
Jason