roastduck / FreeTensor

A language and compiler for irregular tensor programs.

Home Page:https://roastduck.github.io/FreeTensor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect link to OpenMP when building

roastduck opened this issue · comments

I have both LLVM and GCC in the environment, and set to use GCC via export CC=gcc and export CXX=g++. However, FreeTensor was compiled with GCC, but linked to LLVM's OpenMP (as ldd shows). It results in an undefined symbol of GOMP_loop_ull_nonmonotonic_dynamic_next when running.

Building with GCC 10.2.1 (on nico cluster), with LLVM 9 aside.

CMake found the following libraries:

OpenMP_CXX_LIB_NAMES = gomp;pthread  # Names of libraries to link
OpenMP_gomp_LIBRARY = /home/spack/opt/spack/linux-debian11-cascadelake/gcc-10.2.1/llvm-12.0.1-6gord7wz6zbserjbu5jc5qpzezjgeayi/lib/libgomp.so  # All found location(s) of gomp
OpenMP_CXX_LIBRARIES = /home/spack/opt/spack/linux-debian11-cascadelake/gcc-10.2.1/llvm-12.0.1-6gord7wz6zbserjbu5jc5qpzezjgeayi/lib/libgomp.so;/usr/lib/x86_64-linux-gnu/libpthread.so  # Decided libraries to link

It seems that CMake only found the libgomp from LLVM, and it did not find the one from GCC, but why?

Besides, OpenMP from GCC and LLVM are all named libgomp. Are they compatible or not? Actually, libgomp.so in LLVM is a soft link to its own libomp. (Unloading LLVM from the nico cluster does solve the problem, but I found the OpenMP library we use from the yes cluster is also from LLVM)

It seems LLVM's OpenMP is truly compatible with GCC, but the version of LLVM must not be too old. I tested LLVM 9 and LLVM 12, only LLVM 12 is working. (Actually, when I was testing against LLVM 12 as the note above, FreeTensor had already been working fine. But I though the problem was not solved when I saw it was still linked against LLVM but not GCC)