<span style=" font-size:10pt;font-family:sans-serif">Hi Joachim,</span><br><br><span style=" font-size:10pt;font-family:sans-serif">> Does your
libomp contain an implementation of ompt_start_tool?</span><br><br><span style=" font-size:10pt;font-family:sans-serif">It seems to be
there.</span><br><br><span style=" font-size:10pt;font-family:sans-serif">$ readelf --syms
/home/kli/clang-install/lib/libomp.so | grep ompt_start_tool</span><br><span style=" font-size:10pt;font-family:sans-serif">   323:
000000000011bb40   188 FUNC    WEAK   DEFAULT  
11 ompt_start_tool@@VERSION         [<localentry>:
8] </span><br><span style=" font-size:10pt;font-family:sans-serif">   166:
000000000015f1b0     8 OBJECT  LOCAL  DEFAULT  
25 _ZL22ompt_start_tool_resu</span><br><span style=" font-size:10pt;font-family:sans-serif">  3457: 000000000011bb40
  188 FUNC    WEAK   DEFAULT   11 ompt_start_tool
        [<localentry>: 8] </span><br><br><span style=" font-size:10pt;font-family:sans-serif"><br>Kelvin<br></span><br><br><br><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">From:
       </span><span style=" font-size:9pt;font-family:sans-serif">Joachim
Protze <protze.joachim@gmail.com></span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">To:
       </span><span style=" font-size:9pt;font-family:sans-serif">Kelvin
Li <kli@ca.ibm.com></span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Cc:
       </span><span style=" font-size:9pt;font-family:sans-serif">Jim
Cownie <jcownie@gmail.com>, openmp-dev@lists.llvm.org</span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Date:
       </span><span style=" font-size:9pt;font-family:sans-serif">2020/10/28
01:26 PM</span><br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Subject:
       </span><span style=" font-size:9pt;font-family:sans-serif">[EXTERNAL]
Re: [Openmp-dev] : undefined symbol: ompt_start_tool</span><br><hr noshade><br><br><br><tt><span style=" font-size:10pt">Hi Kelvin,<br><br>Am 28.10.20 um 17:16 schrieb Kelvin Li:<br>> I tried both commands with LD_DEBUG.  It seems that somehow the
<br>> libarcher.so cannot be found to resolve ompt_start_tool.<br>> <br><br>libomp calls ompt_start_tool directly (by name) in<br><br></span></tt><a href="https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/ompt-general.cpp#L237"><tt><span style=" font-size:10pt">https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/ompt-general.cpp#L237</span></tt></a><tt><span style=" font-size:10pt"><br><br>In a typical execution, this will find the implementation in libomp:<br><br></span></tt><a href="https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/ompt-general.cpp#L136"><tt><span style=" font-size:10pt">https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/ompt-general.cpp#L136</span></tt></a><tt><span style=" font-size:10pt"><br><br>If I did not miss something, implementation and call should be in the<br>same ifdef branch, i.e., both active or not.<br><br>Reasoning: This explicit call by name is necessary to catch the case of<br>a static tool compiled in the application (linker will prefer<br>ompt_start_tool from the static tool). Such static version might not be<br>found by dlsym.<br><br><br>Later, libomp implicitly assumes "libarcher to be the last entry in<br>OMPT_TOOL_LIBRARIES", dlopens libarcher and dlsyms ompt_start_tool:<br></span></tt><a href="https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/ompt-general.cpp#L275"><tt><span style=" font-size:10pt">https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/ompt-general.cpp#L275</span></tt></a><tt><span style=" font-size:10pt"><br><br>Therefore you see libarcher in the LD_DEBUG output.<br><br>This is how it looks for me:<br>$ LD_DEBUG=bindings ./a.out 2>&1| grep ompt_start_tool<br>      1568:            
    binding file libomp.so [0] to libomp.so [0]: normal
symbol<br>`ompt_start_tool' [VERSION]<br>      1568:            
    binding file libarcher.so [0] to libarcher.so [0]:
normal<br>symbol `ompt_start_tool'<br><br><br>> $ LD_DEBUG=bindings LD_LIBRARY_PATH=/home/kli/clang-install/lib ./a.out
<br>> 2>&1| grep ompt_start_tool<br>>       9105:     binding file /home/kli/clang-install/lib/libomp.so
[0] to <br>> /home/kli/clang-install/lib/libomp.so [0]: normal symbol `ompt_start_tool'
<br>> [VERSION]<br>>       9105:     /home/kli/clang-install/lib/libomp.so:
error: symbol <br>> lookup error: undefined symbol: ompt_start_tool (fatal)<br><br>Here the execution complains about the missing symbol, but does not<br>abort. It is unclear to me, why the execution does not abort in this case.<br><br>>       9105:     binding file /home/kli/clang-install/lib/libarcher.so
[0] <br>> to /home/kli/clang-install/lib/libarcher.so [0]: normal symbol <br>> `ompt_start_tool'<br>> <br>> $ LD_DEBUG=bindings LD_LIBRARY_PATH=/home/kli/clang-install/lib mpirun
-np <br>> 1 ./a.out 2>&1| grep ompt_start_tool<br>>      27652:     binding file /home/kli/clang-install/lib/libomp.so
[0] to <br>> /home/kli/clang-install/lib/libomp.so [0]: normal symbol `ompt_start_tool'
<br>> [VERSION]<br>>      27652:     /home/kli/clang-install/lib/libomp.so:
error: symbol <br>> lookup error: undefined symbol: ompt_start_tool (fatal)<br><br>Same message as above, but now the execution aborts:<br><br>> ./a.out: symbol lookup error: /home/kli/clang-install/lib/libomp.so:
<br>> undefined symbol: ompt_start_tool<br><br>Since the dlopen for libarcher is after the explicit call to<br>ompt_start_tool, it is clear that the message about libarcher is missing<br>here.<br><br><br>Does your libomp contain an implementation of ompt_start_tool?<br><br>nm /home/kli/clang-install/lib/libomp.so | grep ompt_start_tool<br>or<br>readelf --syms /home/kli/clang-install/lib/libomp.so | grep ompt_start_tool<br><br>- Joachim<br><br></span></tt><br><br><BR>