https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120680
Bug ID: 120680 Summary: [nvptx] Linker errors with absent weak symbol 'zoneinfo_dir_override' Product: gcc Version: 16.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: tschwinge at gcc dot gnu.org Target Milestone: --- Target: nvptx I get link errors with -O0 for some C++ programs failing with: unresolved symbol _ZN9__gnu_cxx21zoneinfo_dir_overrideEv ----------------------- Example ----------------------- #include <iostream> int main() { #pragma omp target std::cout << "Hello World" << std::endl; } ------------------------------------------------------- It works with AMD GCN. The problem seems to be the lacking support of nvptx for weak symbols. Looking at libstdc++-v3/src/c++20/tzdb.cc, the current code has: ------------------------------------------------------- namespace __gnu_cxx { #ifdef _AIX // Cannot override weak symbols on AIX. const char* (*zoneinfo_dir_override)() = nullptr; #else [[gnu::weak]] const char* zoneinfo_dir_override(); #if defined(__APPLE__) || defined(__hpux__) \ || (defined(__VXWORKS__) && !defined(__RTP__)) // Need a weak definition for Mach-O et al. [[gnu::weak]] const char* zoneinfo_dir_override() { #ifdef _GLIBCXX_ZONEINFO_DIR return _GLIBCXX_ZONEINFO_DIR; #else return nullptr; #endif } #endif #endif } ------------------------------------------------------- And later: ------------------------------------------------------- if (__gnu_cxx::zoneinfo_dir_override) { if (auto override_dir = __gnu_cxx::zoneinfo_dir_override()) path = override_dir; ------------------------------------------------------- This obvious fails as the 'if' does not evaluate to false. Solution: Either the __APPLE__/__HPUX_/… or the _AIX seems to make sense for nvptx as well.