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

    <tr>
        <th>Summary</th>
        <td>
            openmp: recent link issue `ompt_callback.cpp:function ompt_init(): error: undefined reference to 'dlsym'`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            openmp,
            build-problem
      </td>
    </tr>

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

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

<pre>
    On linux on Debian bullseye:
```
[5831/9215] : && /build/source/build-llvm/./bin/clang++ -fPIC -fstack-protector-strong -Wformat -Werror=format-security -Wno-unused-command-line-argument -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -ffile-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -ffile-prefix-map=/build/source/= -no-canonical-prefixes -Wall -Wcast-qual -Wformat-pedantic -Wimplicit-fallthrough -Wsign-compare -Wno-enum-constexpr-conversion -Wno-extra -Wno-pedantic -std=c++17 -O2 -DNDEBUG -g1  -Wl,-z,relro -Wl,--build-id -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=gold   -Wl,--gc-sections -shared -Wl,-soname,libomptarget.so.16 -o lib/libomptarget.so.16 projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/api.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/device.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/interface.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/interop.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/omptarget.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/ompt_callback.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/rtl.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/LegacyAPI.cpp.o  -Wl,-rpath,"\$ORIGIN:/build/source/build-llvm/tools/clang/stage2-bins/projects/openmp/libomptarget/src/..:/build/source/build-llvm/tools/clang/stage2-bins/lib:"  -Wl,--version-script=/build/source/openmp/libomptarget/src/exports  lib/libLLVM-16.so.1 && :
FAILED: lib/libomptarget.so.16 
: && /build/source/build-llvm/./bin/clang++ -fPIC -fstack-protector-strong -Wformat -Werror=format-security -Wno-unused-command-line-argument -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -ffile-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -ffile-prefix-map=/build/source/= -no-canonical-prefixes -Wall -Wcast-qual -Wformat-pedantic -Wimplicit-fallthrough -Wsign-compare -Wno-enum-constexpr-conversion -Wno-extra -Wno-pedantic -std=c++17 -O2 -DNDEBUG -g1  -Wl,-z,relro -Wl,--build-id -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=gold   -Wl,--gc-sections -shared -Wl,-soname,libomptarget.so.16 -o lib/libomptarget.so.16 projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/api.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/device.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/interface.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/interop.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/omptarget.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/ompt_callback.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/rtl.cpp.o projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/LegacyAPI.cpp.o  -Wl,-rpath,"\$ORIGIN:/build/source/build-llvm/tools/clang/stage2-bins/projects/openmp/libomptarget/src/..:/build/source/build-llvm/tools/clang/stage2-bins/lib:"  -Wl,--version-script=/build/source/openmp/libomptarget/src/exports  lib/libLLVM-16.so.1 && :
projects/openmp/libomptarget/src/CMakeFiles/omptarget.dir/ompt_callback.cpp.o:ompt_callback.cpp:function ompt_init(): error: undefined reference to 'dlsym'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

@kiranchandramohan seems that you recently landed a bunch of openmp changes.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWF1v2zYU_TXyC0HDkr8f_JDGdREgbYpuXbGngqKuZC4UqZGUG_fX71BybHdrtwBNXgYDgmRekof3mwfObbFf3RmmlWkfmDVsTbkShuWt1p72lIyvktE6GV0ls9Hh6YfTV9PFOE2yzTJLp8l0zbCSJdkMDz6bvFW6wNfb1kl6FHCtdzUGwyhQBm-phamS7BUexsv3N9d4-yDkPW-cDSSDddwHZ03F-KfSuloE_CDnrEvG617APcnWqbDHjLG8Na2ngktb18LgSGWIC1e1NZm4txCBeFA1Mb7-vLn78OvN5vfPv9x9_HD9GojZUQsgeQJCUJIrE8g11qug4CJe7pRXudI4ElPxAM-3qijInOl2ds5R1pqqFa6AdmInlBYHDENfsEhoH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