<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/153569>153569</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            libomp.so doesn't link in Debug build with gcc-15 libstdc++
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            openmp:libomp
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rorth
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycll9v4joWwD-NeTlK5DgkwAMPAUq3utze0bTVvdqXyHEOxFtjR7YD5duv7MBMO-1Iq0VISWyf4_P3Z3Pn5EEjLkmxIsVmwgffGbu0xvpu0pj2svy7Qw3NIFUr9QFISZVszLFPnSElBaPDkOu5FYkbdOKM4lY6lmZZmCZsLlNMwXcIOUsa6ZMW93xQHoQ59lKhJWwBZ-m7uIaU9CBEkhVROO7lfCsIW4V_SQlbg_Sw51I58AaU1K8krwitwuT4p9W2etjdbUhegZINYdufFtOKFKs0TUmxIbR60S3upcYWvv7tpXUeLO7RohbYElqBuxwbo34jMP6khr1USGhV__vJs6yuD0o24u2t5s6h9XUw_9sfQj7R-onW0FvzHxTeEbY1PepjT9jWDtrLIxK2dVYQtl3_yV9xKxXGVcc-baUlbPt67Gvhhr431qei71PzSyieO-5vNhM2D7nybYhYXn1pFmFz0XELwmjnCatiwLUPj0_jvwwsYn4WIB3cwir1pySmzqQlKWkK8C9zxlMogPUtlbdC4HHDX2vtbAbVgkZsw_oGowi2oxApqVBcH36UCpw7qTBUi3RfryxpMNB30oHgDlOA5_AePo321iiFLTSXILB7WP3157f65emufnrerL992z2s4FqP506KLkg59MEwUtJttXu6C_qbC9zqfYzFFwmOqd1J513q3_xV6c2Ca89d9989PP5x973eVY_3L9X93dWDr9W-q5v3ytNQIKEuQppkG1I7g473PerPbTj9TRuOcUPoufNXhQ_gBtej8GNAg_YBQzjCur1RypyDL6Lj-oDQoD8j6o8bcd1-AMDnxk6SBAjbDi7U_kEEB7MpYVuphRra4PXNxjCRspQStn2bl3U5TXrxAU5s28jYclcJYfReHtIOGGXThC6SjEEWTKAFyauCpkW-KFg2pSUQtqKMBntum60-WVX8zqoizf5Pq4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