tpp-mlir icon indicating copy to clipboard operation
tpp-mlir copied to clipboard

Build issues on Ubuntu 24.04 - incorrect openmp linkage in CMake

Open dbabokin opened this issue 1 year ago • 0 comments

OpenMP libraries a linked using the library name (i.e. omp): https://github.com/plaidml/tpp-mlir/blob/9c53a05fb56128cda8869a563b999e90b31f2e17/cmake/modules/xsmm-dnn.cmake#L47-L50 https://github.com/plaidml/tpp-mlir/blob/9c53a05fb56128cda8869a563b999e90b31f2e17/tools/tpp-run/CMakeLists.txt#L12-L14

This is not portable, as it assumes the libomp.so is in standard location, which might not be the case. And it seems that what happens on Ubuntu 24.04 with libomp-dev package installed. -lomp5 works, but not -lomp.

The recommended way to handle this is the following:

target_link_libraries(xsmm_dnn_mlp PRIVATE OpenMP::OpenMP_C)

And that fix perfectly fixes the first code snippet.

For the second case it's a bit messy, because of --no-as-needed/--as-needed hack. I suggest using OpenMP_C_LIBRARIES instead of -lomp, though it brings two libraries on my machine: /usr/lib/llvm-18/lib/libomp.so;/lib/aarch64-linux-gnu/libpthread.a

dbabokin avatar Aug 29 '24 19:08 dbabokin