Issue 153569
Summary libomp.so doesn't link in Debug build with gcc-15 libstdc++
Labels openmp:libomp
Assignees
Reporter rorth
    When building `libomp.so` on `sparc-sun-solaris2.11` (i.e. the 32-bit-default compiler) with the `gcc-15` `libstdc++`, it fails to link:
```
FAILED: lib/libomp.so
[...]
Undefined                       first referenced
 symbol                             in file
_ZSt21__glibcxx_assert_failPKciS0_S0_ projects/openmp/runtime/src/CMakeFiles/omp.dir/kmp_csupport.cpp.o
```
That symbol (`std::__glibcxx_assert_fail(char const*, int, char const*, char const*)`) is defined in `libstdc++.so.6`.  However, to link with that, `libomp.so` would need to be linked with `clang++` while it is linked with `clang` in this case.  This is controlled by `LIBOMP_USE_STDCPPLIB `, which is set to `FALSE` by default in `openmp/runtime/CMakeLists.txt`, controlling `LIBOMP_LINKER_LANGUAGE` in `openmp/runtime/src/CMakeLists.txt`.

This didnt' happen with the `gcc-14` `libstdc++` in the past.

I suspect this is due to the following change between `gcc-14` and `gcc-15`:
```
--- /usr/gcc/14/include/c++/14.2.0/x86_64-pc-solaris2.11/bits/c++config.h 2024-09-12 10:05:50.539521406 +0200
+++ /usr/gcc/15/include/c++/15.1.0/x86_64-pc-solaris2.11/bits/c++config.h 2025-07-31 19:22:00.623100695 +0200
@@ -574,7 +618,7 @@
 {
 #pragma GCC visibility push(default)
   // Don't use <cassert> because this should be unaffected by NDEBUG.
-  extern "C++" _GLIBCXX_NORETURN
+  extern "C++" _GLIBCXX_NORETURN __attribute__((__cold__))
   void
 __glibcxx_assert_fail /* Called when a precondition violation is detected. */
     (const char* __file, int __line, const char* __function,
@@ -590,14 +634,17 @@
```
Whatever the case, the assumption that you can link a C++ library without the corresponding runtime seems very fragile, to say the least.

For the moment, I've used `-DLIBOMP_USE_STDCPPLIB=TRUE` as a workaround, but this is no more than a hack.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to