llvm / llvm/llvm-project

[openmp] cannot build openmp anymore without flang-rt if Fortran compiler present

Open
#210,864 8 comments 0 reactions 0 assignees View on GitHub
build-problem openmp
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

In our distribution, builds are separated into components. We used to build openmp with `cmake build ../openmp`, which as of v23.1.0-rc1 errors with
```
The legacy standalone build mode has been removed. Please change
cmake /openmp
to
cmake /runtimes -DLLVM_ENABLE_RUNTIMES=openmp
```
Having updated the invocation as instructed, things continue building fine, except on windows, where we also have a Fortran compiler present to do build the openmp fortran modules with `-DLIBOMP_FORTRAN_MODULES=ON` (our main openmp implementation on unix is libgomp, so we haven't had reason to require the fortran modules for LLVM's openmp yet, which is why they're only built on windows currently).

AFAICT, the error happens because
https://github.com/llvm/llvm-project/blob/de44ed3488693686dd1f65baad5d7bd3797eddca/openmp/module/CMakeLists.txt#L35
is unconditionally depending on a function
https://github.com/llvm/llvm-project/blob/b290a41af4fbaea42bd3c7aa2f90b6592065dd15/runtimes/cmake/config-Fortran.cmake#L251
which does not seem to get included here, despite the fact that the following condition would look like it should
https://github.com/llvm/llvm-project/blob/278c31bfb8ceb7ea17dbfd11a4fb21e6634af957/runtimes/CMakeLists.txt#L296-L298
Either way, the build fails with
```
CMake Error at C:/bld/openmp_1784598877764/work/openmp/module/CMakeLists.txt:35 (flang_module_target):
Unknown CMake command "flang_module_target".
```
The top of that file says
https://github.com/llvm/llvm-project/blob/de44ed3488693686dd1f65baad5d7bd3797eddca/openmp/module/CMakeLists.txt#L9
so I must assume that the presence of the Fortran compiler (or `-DLIBOMP_FORTRAN_MODULES=ON`) also plays a role.

CC @Meinersbur for https://github.com/llvm/llvm-project/commit/bafde6fbb860e9b2f887a649c19f3b3ebb168041; https://github.com/llvm/llvm-project/commit/5b6236c37658b2b1341b20e9b2463d075745d108 may also be relevant tangentially.

Contributor guide

Open the contributing guide

Research direction

Start with openmp/module/CMakeLists.txt around the flang_module_target call, then compare runtimes/cmake/config-Fortran.cmake and runtimes/CMakeLists.txt around the condition described in the issue. Reproduce the Windows configuration with LIBOMP_FORTRAN_MODULES=ON and a Fortran compiler; done means the runtimes-based OpenMP build configures and builds its Fortran modules without the unknown-command error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, fortran
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.