Standalone Flang build Not building omp_lib.mod on M1 Mac

Hi, I’ve been trying to install the standalone Flang compiler, as I have Clang and Clang++ installed from Homebrew. I was following the instructions and thought I was doing fine, but noticed that I couldn’t get omp_lib.mod to build ONLY with the standalone build.

I’m using these flags to build llvm to build flang off of:

mkdir root
cd root
rm -rf build
mkdir build
rm -rf install
mkdir install
ROOTDIR=pwd
INSTALLDIR=$ROOTDIR/install

cd build

cmake … -DCMAKE_C_COMPILER=blang -DCMAKE_CXX_COMPILER=blang++
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=$INSTALLDIR
-DCMAKE_CXX_STANDARD=17
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_CXX_LINK_FLAGS=“-Wl,-rpath,$LD_LIBRARY_PATH”
-DFLANG_ENABLE_WERROR=ON
-DLLVM_ENABLE_ASSERTIONS=ON
-DLLVM_TARGETS_TO_BUILD=host
-DLLVM_LIT_ARGS=-v
-DLLVM_ENABLE_PROJECTS=“clang;mlir;flang;openmp”
-DDEFAULT_SYSROOT=“$(xcrun --show-sdk-path)”
…/llvm-project/llvm

make
(I had to name LLVM compilers “blang” and “blang++” to prevent conflict from Apple’s own Clang compilers)

When I do that, everything is fine; omp_lib.mod gets built in the build folder. I then follow the standalone instructions and use these flags for my Flang build:

cd llvm-project/flang
rm -rf build
mkdir build
cd build

cmake … -DCMAKE_C_COMPILER=blang -DCMAKE_CXX_COMPILER=blang++
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_STANDARD=17
-DCMAKE_CXX_LINK_FLAGS=“-Wl,-rpath,$LD_LIBRARY_PATH”
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DFLANG_ENABLE_WERROR=ON
-DLLVM_TARGETS_TO_BUILD=host
-DLLVM_ENABLE_ASSERTIONS=ON
-DLLVM_BUILD_MAIN_SRC_DIR=$ROOTDIR/build/lib/cmake/llvm
-DLLVM_EXTERNAL_LIT=$ROOTDIR/build/bin/llvm-lit
-DLLVM_LIT_ARGS=-v
-DLLVM_DIR=$ROOTDIR/build/lib/cmake/llvm
-DCLANG_DIR=$ROOTDIR/build/lib/cmake/clang
-DMLIR_DIR=$ROOTDIR/build/lib/cmake/mlir
-DCMAKE_INSTALL_PREFIX=/opt/flang

make

Whenever This gets made however, I get a notifications stating “Not building omp_lib.mod, no OpenMP runtime in LLVM_ENABLED_PROJECTS”. I’ve tried several things to get this to work, including putting the flag -DLLVM_ENABLE_PROJECTS=“openmp” in the standalone flags, but they get ignored. Can someone let me know what I am doing incorrectly? Thanks.

Hi,
could you please try to add the OpenMP runtime build as a runtime project via LLVM_ENABLE_RUNTIMES=openmp? Then, it should build the OpenMP runtime and therefore also omp_lib.mod.

If that does not work, please open a GitHub issue and mention me (mjklemm) in the comment, so that I can it up.

Kind regards,
-michael

1 Like

PS: The other option is to build OpenMP as a separate runtime project after you have built Flang.

I tried both using `LLVM_ENABLE_RUNTIMES=openmp’ flag and building OpenMP as a separate runtime project, but it still doesn’t work unfortunately. The flag was not used again and when I built OpenMP as a separate runtime project, it still did not give me OpenMP functionality for Flang.

I will open up a GitHub issue as soon as I can and mention you.