On 4/22/25 1:21 PM, Tobias Burnus wrote:
Jason Merrill wrote:
On 4/22/25 11:04 AM, Tobias Burnus wrote:
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).

I currently do not see whether the code is needed in this case or not, but I assume it is, if we want to support static initializers?!?

I don't think so. For the host, we force create a map with a single entry because we always want to emit a module init function. The openmp block is saying we also always want a target init function in a module, even if it's empty, which I don't think is correct. Or if it is, we need to specify how to mangle it and agree that that's part of the module ABI.

In any case, it seems as if the condition 'if (flag_openmp)' additionally requires '&& lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl))'.

Tobias

PS: Sorry, I badly need to finish a couple of other things, first – and I am already way behind (related to any of several GCC topics, filing one OpenMP_VV bug, to GSoC and to something hobby related – but first victualing before the shop closes).


Reply via email to