[all-commits] [llvm/llvm-project] 5a98e9: [Flang][CMake] Use fakeflang as dispatcher (#209482)
Michael Kruse via All-commits
all-commits at lists.llvm.org
Thu Jul 16 04:19:28 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5a98e96135e223890cbf0640584e30c0db695ecf
https://github.com/llvm/llvm-project/commit/5a98e96135e223890cbf0640584e30c0db695ecf
Author: Michael Kruse <llvm-project at meinersbur.de>
Date: 2026-07-16 (Thu, 16 Jul 2026)
Changed paths:
M flang/test/Driver/fakeflang.F
M flang/tools/CMakeLists.txt
M flang/tools/fakeflang/CMakeLists.txt
R flang/tools/fakeflang/ensure_flang_exists.cmake
M flang/tools/fakeflang/fakeflang.cpp
M flang/tools/flang-driver/CMakeLists.txt
M llvm/cmake/modules/LLVMExternalProjectUtils.cmake
Log Message:
-----------
[Flang][CMake] Use fakeflang as dispatcher (#209482)
With #203481 where `runtimes-configure` does not depend on `flang`
anymore, the following race could happen in incremental builds: While
ninja/make builds some of the libFortran*.so libraries in a
BUILD_SHARED_LIBS=ON build, CMake tries to execute flang which tries to
load the .so libraries while they are linked. This race condition can
only happen in incremental builds because before the real bin/flang is
built completely the first time, it points to fakeflang which would be
working. Only in an incremental build, would the real bin/flang already
been built created before, pointing to the currently re-built flang.
I did not think this would be possible because CMake only needs to probe
flang once and thereafter (in the incremental build) remembers the probe
result in `CMakeFiles/<version>/CMakeFortranCompiler.cmake`. CMake does
not support changing the compiler once configured and errors-out if you
try to change `CMAKE_Fortran_COMPILER`. I do not know why/when CMake is
re-probing the compiler in some incremental builds, but has been
reported to do so in #205360.
This patch avoids any replacement of build artifacts and instead decides
in fakeflang when to call real flang or to emulate the Flang
preprocessor. The decision is made based of on the FLANG_BOOTSTRAP_PROBE
environment variable that is set only in the configure step. The feature
that allows this is unfortunately only available starting in CMake 4.2.
All suppported CMake versions before CMake 4.2 use the filename
`CMakeFortranCompilerId.F`, so make the decision based on that when
using earlier versions of CMake.
Tested with CMake 3.20, 3.28, 3.31, 4.1, and 4.2.
Fixes #205360
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list