Skip to content

Commit 2bf7d33

Browse files
committed
Implicitly enable Flang-RT
1 parent b14ff22 commit 2bf7d33

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

flang-rt/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ can be any compiler supporting the same ABI.
9191
In addition to the compiler, the build be able to find LLVM development tools
9292
such as `lit` and `FileCheck` that are not found in an LLVM's install
9393
directory. Use `CMAKE_BINARY_DIR` to point to directory where LLVM has
94-
been built. A simple build configuration might look like the following:
94+
been built. When building Flang as part of a bootstrapping build
95+
(`LLVM_ENABLE_PROJECTS=flang`), Flang-RT has already been automatically added
96+
unless configured with `-DFLANG_ENABLE_FLANG_RT=OFF`. Add that option to avoid
97+
having two conflicting versions of the same library.
98+
99+
A simple build configuration might look like the following:
95100

96101
```bash
97102
cmake -S <path-to-llvm-project-source>/runtimes \

llvm/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES)
187187
endif()
188188
endforeach()
189189

190+
option(FLANG_ENABLE_FLANG_RT "Implicitly add LLVM_ENABLE_RUNTIMES=flang-rt when compiling Flang" ON)
191+
if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
192+
if (NOT "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
193+
message(STATUS "Enabling Flang-RT as a dependency of Flang"
194+
"Flang-RT is required for a fully working Flang toolchain."
195+
"If you intend to compile Flang-RT separately following the instructions at"
196+
"https://github.com/llvm/llvm-project/blob/main/flang-rt/README.md#standalone-runtimes-build"
197+
"you should use -DFLANG_ENABLE_FLANG_RT=OFF to not build Flang-RT as part of this build."
198+
)
199+
list(APPEND LLVM_ENABLE_RUNTIMES "flang-rt")
200+
endif()
201+
endif ()
202+
190203
# Set a shorthand option to enable the GPU build of the 'libc' project.
191204
option(LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF)
192205
if(LIBC_GPU_BUILD)

0 commit comments

Comments
 (0)