Can OMPT component be statically linked to an application

Hi,

I’m trying to link my app statically with the upstream LLVM/Clang, but
I get this at the last stage:

[100%] Linking CXX executable nest
/usr/lib/gcc/aarch64-redhat-linux/4.8.5/…/…/…/…/lib64/libpthread.a(libpthread.o): In function sem_open': (.text+0x7810): warning: the use of mktemp’ is dangerous, better use mkstemp' /home/itaru/opt/llvm+clang-upstream/bin/../lib/libomp.a(ompt-general.cpp.o): In function ompt_start_tool’:
/home/itaru/projects/llvm/projects/openmp/runtime/src/ompt-general.cpp:144: undefined reference to dlsym' /home/itaru/opt/llvm+clang-upstream/bin/../lib/libomp.a(ompt-general.cpp.o): In function ompt_try_start_tool(unsigned int, char const*)’:
ompt-general.cpp:(.text+0xf00): undefined reference to dlopen' ompt-general.cpp:(.text+0xf20): undefined reference to dlsym’
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [nest/CMakeFiles/nest.dir/build.make:135: nest/nest] Error 1
make[2]: *** [CMakeFiles/Makefile2:735: nest/CMakeFiles/nest.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:747: nest/CMakeFiles/nest.dir/rule] Error 2
make: *** [Makefile:364: nest] Error 2

I’m building a tool placing openmp and clang under projects and tools respectively under the top llvm directory. Any way to disable the OMPT
completely as currently it is underdevelopment and have no interest in
using it at the moment.

Hi,

Thanks, for reporting this. The error you listed below, does this come from OpenMP repository or from your project?

You can link statically, but still need to link libdl (-ldl).

To turn off OMPT completely: -DLIBOMP_OMPT_SUPPORT=off

Best
Joachim

Hi,

I'm trying to link my app statically with the upstream LLVM/Clang, but
I get this at the last stage:

[100%] Linking CXX executable nest
/usr/lib/gcc/aarch64-redhat-linux/4.8.5/../../../../lib64/libpthread.a(libpthread.o):
In function `sem_open':
(.text+0x7810): warning: the use of `mktemp' is dangerous, better use
`mkstemp'
/home/itaru/opt/llvm+clang-upstream/bin/../lib/libomp.a(ompt-general.cpp.o):
In function `ompt_start_tool':
/home/itaru/projects/llvm/projects/openmp/runtime/src/ompt-general.cpp:144:
undefined reference to `dlsym'
/home/itaru/opt/llvm+clang-upstream/bin/../lib/libomp.a(ompt-general.cpp.o):
In function `ompt_try_start_tool(unsigned int, char const*)':
ompt-general.cpp:(.text+0xf00): undefined reference to `dlopen'
ompt-general.cpp:(.text+0xf20): undefined reference to `dlsym'

These symbols are in libdl.so which you probably need to add manually when linking statically.

clang-8: error: linker command failed with exit code 1 (use -v to see
invocation)
make[3]: *** [nest/CMakeFiles/nest.dir/build.make:135: nest/nest]
Error 1
make[2]: *** [CMakeFiles/Makefile2:735: nest/CMakeFiles/nest.dir/all]
Error 2
make[1]: *** [CMakeFiles/Makefile2:747: nest/CMakeFiles/nest.dir/rule]
Error 2
make: *** [Makefile:364: nest] Error 2

I'm building a tool placing openmp and clang under projects and tools
respectively under the top llvm directory. Any way to disable the OMPT
completely as currently it is underdevelopment and have no interest in
using it at the moment.

When building the OpenMP runtime you can add -DLIBOMP_OMPT_SUPPORT=OFF to CMake. This should disable support for OMPT and hence the references to dl* should go away.

Cheers,
Jonas

Joachim, Jonas,

I ended up setting KMP_DYNAMIC_LIB to 0 so I don’t get
the error, but is this the right approach for producing statically
linked applications?