[llvm] [DRAFT][Runtimes] Don't execute flang during the runtimes configure step (PR #205458)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 06:49:46 PDT 2026
================
@@ -88,15 +88,27 @@ if (CMAKE_Fortran_COMPILER)
# cannot use CMAKE_Fortran_COMPILER_ID.
cmake_path(GET CMAKE_Fortran_COMPILER STEM _Fortran_COMPILER_STEM)
if (_Fortran_COMPILER_STEM STREQUAL "flang-new" OR _Fortran_COMPILER_STEM STREQUAL "flang")
+ # Force the Fortran compiler identity instead of letting CMake detect it by
+ # executing the compiler. enable_language(Fortran) below would otherwise run
+ # `flang` for both compiler identification and ABI detection. In a
+ # bootstrapping runtimes build, the just-built `flang` and its shared
+ # libraries (e.g. libFortranLower.so) are produced by independent build
+ # steps, so executing `flang` during the (deliberately early, see #198205)
+ # runtimes configure step can race with the linking or relinking of those
+ # libraries -- "error while loading shared libraries: ...: file too short".
+ # Forcing the identity keeps the runtimes configure off flang's build
+ # critical path while avoiding that race (llvm-project#205360).
+ # CMAKE_Fortran_COMPILER_ID_RUN skips compiler identification and
+ # CMAKE_Fortran_COMPILER_FORCED skips the ABI/works probe, so neither
+ # executes flang.
+ set(CMAKE_Fortran_COMPILER_ID "LLVMFlang")
+ set(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
+ set(CMAKE_Fortran_COMPILER_FORCED TRUE)
----------------
Meinersbur wrote:
This is unfortunately [unsupported by CMake](https://cmake.org/cmake/help/latest/module/CMakeForceCompiler.html)
> Deprecated since version 3.6: Do not use.
I don't think Kitware would be happy if we start using this well after its deprecation. When using it, I also encountered significant problems such as it would not be passed to `try_compile` and so any introspection would fail.
I prepared different PR to solve the problem, if you would like to have a look: #209482
https://github.com/llvm/llvm-project/pull/205458
More information about the llvm-commits
mailing list