Global BSS symbol not initialized properly if built with -fopenmp-targets=nvptx64

I am revisiting this possible compiler bug in Clang 8.0.0.

In the source code I am developing, there’s a global static variable, nest::sli_neuron::recordablesMap_ put in the BSS section and it is expected to be fully initialized by the time nest::sli_neuron::sli_neuron() gets called, however in a gdb session:

(gdb) p nest::sli_neuron::recordablesMap_
Python Exception <type ‘exceptions.AttributeError’> ‘gdb.Type’ object has no attribute ‘name’:
$1 = {<std::map<Name, double (nest::sli_neuron::)() const, std::less, std::allocator<std::pair<Name const, double (nest::sli_neuron::)() const> > >> = std::map with 0 elements, _vptr$RecordablesMap = 0x0}

this doesn’t happen when -fopenmp-targets is not used, is it not trivial to come up a reproducer, thus I am sending a work-in-progress report hoping someone will shed some light on this.


Setting a watchpoint on the static object, nest::sli_neuron::recordablesMap_ in a GDB session taught me:

The NEST binary built without -fopenmp-targets flag correctly init the object, while the NEST binary built with the -fopenmp-targets flag does nothing on the object.

Alexey agreed this is a bug of Clang and is working on a fix, as during the global initialization phase, the instance’s pointer to the vtable is never set.

I did not agreed that this is the bug in clang, I’m still investigating the problem.

Best regards,
Alexey Bataev

Could you point us to the corresponding LLVM Bug entry?

There is no such entry, just a patch to fix the problem.

Best regards,
Alexey Bataev

I’m trying to build the trunk which now requires C++14, but a build configured below keeps failing on POWER8:


can someone point out what I am doing wrong?

Check if you meet minimal requirements fir LLVM

Also, would be good to see the build log.

Best regards,
Alexey Bataev

Hi Alexey,
I confirm my application NEST does not crash at run time even it is built with the offloading flags.

Thank you very much!

Thanks for the pointer, on PowerPC indeed CentOS 7’s host GCC 4.8.5 is too old now and
libc++ is never supported on PowerPC, choosing a recent GCC is critical.