On Thu, 14 Jul 2022 at 15:53, Thomas Schwinge wrote: > > Hi! > > In context of '[OpenMP][AMDGCN][nvptx] > C++ offloading: unresolved _Znwm = "operator new(unsigned long)"' > I'm looking into building GCN, nvptx offloading libstdc++ "freestanding" > ('--disable-hosted-libstdcxx') with '-fno-rtti', '-fno-exceptions'. > (I've basically got these things wired up; details to be shared later.) > > For nvptx, I'm running into: > > In function ‘(static initializers for [...]/libstdc++-v3/libsupc++/eh_alloc.cc)’: > cc1plus: sorry, unimplemented: global constructors not supported on this target > make[4]: *** [Makefile:777: eh_alloc.lo] Error 1 > > ... because, indeed, "global constructors not supported" for nvptx at > this time. This may change, but I'd first like to get clarified > conceptually to which extent 'libstdc++-v3/libsupc++/eh_alloc.cc' is > actually relevant for such a libstdc++ configuration, It depends. Does your target *ever* support exceptions? Building libstdc++ with -fno-exceptions means that the library code can't throw or catch exceptions, but in theory user code linking to that libstdc++ build could still be compiled with -fexceptions. In such a scenario, the __cxxabiv1::__cxa_allocate_exception and __cxxabiv1::__cxa_free_exception functions (which are required by the C++ ABI) are still needed. But if your target completely disallows -fexceptions, you probably don't need anything in that file. > and/or whether this > should be expected to compile fine already? I think a few people have built libstdc++ with -fno-rtti and -fno-exceptions recently, and that should work. The problem here is the lack of global ctors, which is much less common. You might find other parts of libstdc++ that don't build for the same reason, although maybe those other parts are all disabled for freestanding builds. > Do certain things simply > need to be '#if'-conditionalized, or similar, for example? Yes, I think so. > I've not yet > looked into the details; hoping that's maybe easy for you to answer? Does the attached patch work?