-
Notifications
You must be signed in to change notification settings - Fork 13.2k
[Flang] Remove FLANG_INCLUDE_RUNTIME #124126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flang] Remove FLANG_INCLUDE_RUNTIME #124126
Conversation
3818238
to
b05c9a0
Compare
bd152c5
to
c515d13
Compare
Hi @Meinersbur is this the only patch that is left to be merged? Could you please rebase it so that I can try it on top-of-tree? |
8757bf4
to
698bcd0
Compare
698bcd0
to
b14ff22
Compare
Rebased and added implicitly adding |
Add `depends_on_projects=['flang-rt']`, and `checks=['check-flang-rt']` to the ppc64-flang-aix builder. The prepares the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. Split off from #333 Affected builders: * ppc64-flang-aix Affected workers: * ppc64-flang-aix-test (production) Admins listed for those workers: * LLVM on Power <[email protected]> * Mark Danial <[email protected]>
Add `enable_runtimes=['flang-rt']`, `depends_on_projects=['flang-rt']`, and `add_lit_checks=['check-flang-rt']` to all OpenMPBuilder-based builders that build flang. This prepares the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. Split off from #333 Affected builders: * openmp-offload-amdgpu-clang-flang * openmp-offload-sles-build-only * openmp-offload-rhel-9_4 * openmp-offload-rhel-8_8 Affected workers: * rocm-worker-hw-01 (staging) * rocm-worker-hw-04-sles * rocm-worker-hw-04-rhel-9_4 (staging) * rocm-worker-hw-04-rhel-8_8 (staging) Admins listed for those workers: * AMD <[email protected]>
Thank you for the rebase, @Meinersbur. Please give me some time to adjust build tools on my side to make it work with |
Add `depends_on_projects=['flang-rt']` and `checks=['check-flang-rt']` to Linaro's builders that are based on UnifiedTreeBuilder. This prepares the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. Affected builders: * flang-aarch64-dylib * flang-aarch64-sharedlibs * flang-aarch64-debug-reverse-iteration * flang-aarch64-libcxx * flang-aarch64-release * flang-aarch64-rel-assert * flang-aarch64-latest-gcc Affected workers: * linaro-flang-aarch64-dylib * linaro-flang-aarch64-sharedlibs * linaro-flang-aarch64-debug-reverse-iteration * linaro-flang-aarch64-libcxx * linaro-flang-aarch64-release * linaro-flang-aarch64-rel-assert * linaro-flang-aarch64-latest-gcc
With the option `checkout_flang=True`, ClangBuilder-based builders also compile Flang. Modify ClangBuilder to use `LLVM_ENABLE_RUNTIMES=flang-rt`. This prepares the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. Affected builders: * clang-aarch64-full-2stage * clang-aarch64-sve-vla * clang-aarch64-sve-vla-2stage * clang-aarch64-sve-vls * clang-aarch64-sve-vls-2stage * clang-aarch64-sve2-vla * clang-aarch64-sve2-vla-2stage * clang-arm64-windows-msvc * clang-arm64-windows-msvc-2stage Affected workers: * linaro-clang-aarch64-full-2stage * linaro-g3-01 * linaro-g3-02 * linaro-g3-03 * linaro-g3-04 * linaro-g4-01 * linaro-g4-02 * linaro-armv8-windows-msvc-04 * linaro-armv8-windows-msvc-02
Add `depends_on_projects=['flang-rt']`, to the amdgpu-offload-* builders. The prepares the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. The corresponding change in the LLVM repository is llvm/llvm-project#129692 Affected builders (production): * [amdgpu-offload-ubuntu-22-cmake-build-only](https://lab.llvm.org/buildbot/#/builders/203) * [amdgpu-offload-rhel-9-cmake-build-only](https://lab.llvm.org/buildbot/#/builders/205) * [amdgpu-offload-rhel-8-cmake-build-only](https://lab.llvm.org/buildbot/#/builders/204) Affected workers (production): * [rocm-docker-ubu-22](https://lab.llvm.org/buildbot/#/workers/162) * [rocm-docker-rhel-9](https://lab.llvm.org/buildbot/#/workers/163) * [rocm-docker-rhel-8](https://lab.llvm.org/buildbot/#/workers/164)
Add `depends_on_projects=['flang-rt']`, and `checks=['check-flang-rt']` to the ppc64le-flang-rhel-clang builder. The prepares the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. Affected builders (production): * [ppc64le-flang-rhel-clang](https://lab.llvm.org/buildbot/#/builders/157) Affected workers (production): * [ppc64le-flang-rhel-test](https://lab.llvm.org/buildbot/#/workers/152)
Update premerge-monolithic-windows and premerge-monolithic-linux to prepare for the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. This does not change the actual premerge GitHub action, which is done by llvm/llvm-project#128678 For premerge-monolithic-linux, add flang-rt to the LLVM_ENABLE_RUNTIMES list, indirectly by adding it to `depends_on_projects` which also updated the build scheduler. For premerge-monolithic-windows, remove building flang to match the actual pre-merge build which disabled building flang on Windows in llvm/llvm-project@e4b424a. Adding flang-rt would also require compiler-rt (which was always required on Windows, but now there is a regression test for it) and check-compiler-rt is currently failing. Split off from #333. Verified to work locally using instruction from https://llvm.org/docs/HowToAddABuilder.html#testing-a-builder-config-locally. With the exception of `-gmlt` which seems to be a Google-only extention of Clang. Affected builders: * [premerge-monolithic-windows](https://lab.llvm.org/buildbot/#/builders/35) * [premerge-monolithic-linux](https://lab.llvm.org/buildbot/#/builders/153) Affected workers: * [premerge-windows-1](https://lab.llvm.org/buildbot/#/workers/153) * [premerge-linux-1](https://lab.llvm.org/buildbot/#/workers/110)
Add `depends_on_projects=['flang-rt']` to the flang-runtime-cuda-gcc and flang-runtime-cuda-clang builders. This prepares the removal of the "projects" build of the flang runtime in llvm/llvm-project#124126. Affected builders: * flang-runtime-cuda-gcc This previously only built the runtime using the top-level CMakeLists.txt in `flang/runtime/CMakeLists.txt`. This is going to be replaced with the "standalone runtimes build", with the top-level `runtimes/CMakeLists.txt`. This still needs Flang to successed, hence replacing with a bootstrap-build where the `FLANG_RT_*` options are internally forwarded to the runtimes build. * flang-runtime-cuda-clang This is a manual bootstrapping build which first compiles Clang, then the runtime out-of-tree. This is replaced with a standalone runtimes build as described above. Because it needs Flang, also adding Flang to the enabled projects of the stage1 build. Neither build runs the `check-*` targets, probably due to the lack of actual CUDA hardware which running the runtime unittests require. Affected workers: * as-builder-7
Make `FlangBuilder.getFlangOutOfTreeBuildFactory` build the flang-rt runtime as an out-of-tree runtimes build with additional steps. Fixes some issues with FlangBuilder too: * Clears the build directories with the clean_obj flag set. Usually buildbot deletes the build directory whenever a CMakeLists.txt in a depends_on_projects subdirectory changes to get a clean build. Otherwise, an incompatible CMakeCache.txt will carry on forever. * Add `flang` and `flang-rt` as depends_on_projects. Otherwise, changes in these subdirectories do not trigger a build. Even worse, breaking commits will be attributed to the next commit in llvm/clang/mlir/openmp, as happed in e.g. https://lab.llvm.org/buildbot/#/builders/53/builds/11759 (commit causing the failure was llvm/llvm-project@fe8b323 ) This PR is not strictly necessary for llvm/llvm-project#124126, it just wouldn't build the runtime anymore. Affected builders: * flang-aarch64-out-of-tree Affected workers: * linaro-flang-aarch64-out-of-tree Tested locally on x86_64.
@llvm/pr-subscribers-flang-semantics @llvm/pr-subscribers-flang-runtime Author: Michael Kruse (Meinersbur) ChangesRemove the FLANG_INCLUDE_RUNTIME option which was replaced by LLVM_ENABLE_RUNTIMES=flang-rt. The FLANG_INCLUDE_RUNTIME option was added in #122336 which disables the non-runtimes build instructions for the Flang runtime so they do not conflict with the LLVM_ENABLE_RUNTIMES=flang-rt option added in #110217. In order to not maintain multiple build instructions for the same thing, this PR completely removes the old build instructions (effectively forcing FLANG_INCLUDE_RUNTIME=OFF). As per discussion in https://discourse.llvm.org/t/buildbot-changes-with-llvm-enable-runtimes-flang-rt/83571/2 we now implicitly add LLVM_ENABLE_RUNTIMES=flang-rt whenever Flang is compiled in a bootstrapping (non-standalone) build. Because it is possible to build Flang-RT separately, this behavior can be disabled using This PR will remains in draft status until the buildbots' configurations have been updated. Due to LLVM_ENABLE_RUNTIMES=flang-rt being added automatically, most of them would probably continue to work, except the out-of-tree builders which require some adjustment. Series of buildbot updates:
Patch is 22.78 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/124126.diff 14 Files Affected:
diff --git a/flang-rt/README.md b/flang-rt/README.md
index 449546cef9748..db585708de7ed 100644
--- a/flang-rt/README.md
+++ b/flang-rt/README.md
@@ -91,7 +91,12 @@ can be any compiler supporting the same ABI.
In addition to the compiler, the build must be able to find LLVM development
tools such as `lit` and `FileCheck` that are not found in an LLVM's install
directory. Use `CMAKE_BINARY_DIR` to point to directory where LLVM has
-been built. A simple build configuration might look like the following:
+been built. When building Flang as part of a bootstrapping build
+(`LLVM_ENABLE_PROJECTS=flang`), Flang-RT has already been automatically added
+unless configured with `-DFLANG_ENABLE_FLANG_RT=OFF`. Add that option to avoid
+having two conflicting versions of the same library.
+
+A simple build configuration might look like the following:
```bash
cmake -S <path-to-llvm-project-source>/runtimes \
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 4b703b456cae2..48ea3e3c04551 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -23,7 +23,6 @@ if (LLVM_ENABLE_EH)
endif()
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang-rt")
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed. \
@@ -243,24 +242,8 @@ else()
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
endif()
-set(FLANG_INCLUDE_RUNTIME_default ON)
-if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
- set(FLANG_INCLUDE_RUNTIME_default OFF)
-endif ()
-option(FLANG_INCLUDE_RUNTIME "Build the runtime in-tree (deprecated; to be replaced with LLVM_ENABLE_RUNTIMES=flang-rt)" ${FLANG_INCLUDE_RUNTIME_default})
-if (FLANG_INCLUDE_RUNTIME)
- if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
- message(WARNING "Building Flang-RT using LLVM_ENABLE_RUNTIMES. FLANG_INCLUDE_RUNTIME=${FLANG_INCLUDE_RUNTIME} ignored.")
- set(FLANG_INCLUDE_RUNTIME OFF)
- else ()
- message(STATUS "Building Flang-RT in-tree")
- endif ()
-else ()
- if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
- message(STATUS "Building Flang-RT using LLVM_ENABLE_RUNTIMES")
- else ()
- message(STATUS "Not building Flang-RT. For a usable Fortran toolchain, either add LLVM_ENABLE_RUNTIMES=flang-rt, or compile a standalone Flang-RT.")
- endif ()
+if (NOT "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
+ message(STATUS "Not building Flang-RT. For a usable Fortran toolchain, either add LLVM_ENABLE_RUNTIMES=flang-rt, or compile a standalone Flang-RT.")
endif ()
set(FLANG_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
@@ -485,12 +468,6 @@ if (FLANG_INCLUDE_TESTS)
add_compile_definitions(FLANG_INCLUDE_TESTS=1)
endif()
-option(FLANG_CUF_RUNTIME
- "Compile CUDA Fortran runtime sources" OFF)
-if (FLANG_CUF_RUNTIME)
- find_package(CUDAToolkit REQUIRED)
-endif()
-
add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(cmake/modules)
@@ -501,10 +478,6 @@ if (FLANG_BUILD_TOOLS)
add_subdirectory(tools)
endif()
-if (FLANG_INCLUDE_RUNTIME)
- add_subdirectory(runtime)
-endif ()
-
if (LLVM_INCLUDE_EXAMPLES)
add_subdirectory(examples)
endif()
diff --git a/flang/cmake/modules/AddFlangOffloadRuntime.cmake b/flang/cmake/modules/AddFlangOffloadRuntime.cmake
deleted file mode 100644
index eb0e964559ed5..0000000000000
--- a/flang/cmake/modules/AddFlangOffloadRuntime.cmake
+++ /dev/null
@@ -1,146 +0,0 @@
-option(FLANG_EXPERIMENTAL_CUDA_RUNTIME
- "Compile Fortran runtime as CUDA sources (experimental)" OFF
- )
-
-option(FLANG_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS
- "Do not compile global variables' definitions when producing PTX library" OFF
- )
-
-set(FLANG_LIBCUDACXX_PATH "" CACHE PATH "Path to libcu++ package installation")
-
-set(FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD "off" CACHE STRING
- "Compile Fortran runtime as OpenMP target offload sources (experimental). Valid options are 'off', 'host_device', 'nohost'")
-
-set(FLANG_OMP_DEVICE_ARCHITECTURES "all" CACHE STRING
- "List of OpenMP device architectures to be used to compile the Fortran runtime (e.g. 'gfx1103;sm_90')")
-
-macro(enable_cuda_compilation name files)
- if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
- if (BUILD_SHARED_LIBS)
- message(FATAL_ERROR
- "BUILD_SHARED_LIBS is not supported for CUDA build of Fortran runtime"
- )
- endif()
-
- enable_language(CUDA)
-
- # TODO: figure out how to make target property CUDA_SEPARABLE_COMPILATION
- # work, and avoid setting CMAKE_CUDA_SEPARABLE_COMPILATION.
- set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
-
- # Treat all supported sources as CUDA files.
- set_source_files_properties(${files} PROPERTIES LANGUAGE CUDA)
- set(CUDA_COMPILE_OPTIONS)
- if ("${CMAKE_CUDA_COMPILER_ID}" MATCHES "Clang")
- # Allow varargs.
- set(CUDA_COMPILE_OPTIONS
- -Xclang -fcuda-allow-variadic-functions
- )
- endif()
- if ("${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA")
- set(CUDA_COMPILE_OPTIONS
- --expt-relaxed-constexpr
- # Disable these warnings:
- # 'long double' is treated as 'double' in device code
- -Xcudafe --diag_suppress=20208
- -Xcudafe --display_error_number
- )
- endif()
- set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS
- "${CUDA_COMPILE_OPTIONS}"
- )
-
- if (EXISTS "${FLANG_LIBCUDACXX_PATH}/include")
- # When using libcudacxx headers files, we have to use them
- # for all files of F18 runtime.
- include_directories(AFTER ${FLANG_LIBCUDACXX_PATH}/include)
- add_compile_definitions(RT_USE_LIBCUDACXX=1)
- endif()
-
- # Add an OBJECT library consisting of CUDA PTX.
- llvm_add_library(${name}PTX OBJECT PARTIAL_SOURCES_INTENDED ${files})
- set_property(TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON)
- if (FLANG_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS)
- target_compile_definitions(obj.${name}PTX
- PRIVATE FLANG_RUNTIME_NO_GLOBAL_VAR_DEFS
- )
- endif()
- endif()
-endmacro()
-
-macro(enable_omp_offload_compilation files)
- if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
- # 'host_device' build only works with Clang compiler currently.
- # The build is done with the CMAKE_C/CXX_COMPILER, i.e. it does not use
- # the in-tree built Clang. We may have a mode that would use the in-tree
- # built Clang.
- #
- # 'nohost' is supposed to produce an LLVM Bitcode library,
- # and it has to be done with a C/C++ compiler producing LLVM Bitcode
- # compatible with the LLVM toolchain version distributed with the Flang
- # compiler.
- # In general, the in-tree built Clang should be used for 'nohost' build.
- # Note that 'nohost' build does not produce the host version of Flang
- # runtime library, so there will be two separate distributable objects.
- # 'nohost' build is a TODO.
-
- if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "host_device")
- message(FATAL_ERROR "Unsupported OpenMP offload build of Flang runtime")
- endif()
- if (BUILD_SHARED_LIBS)
- message(FATAL_ERROR
- "BUILD_SHARED_LIBS is not supported for OpenMP offload build of Fortran runtime"
- )
- endif()
-
- if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND
- "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
-
- set(all_amdgpu_architectures
- "gfx700;gfx701;gfx801;gfx803;gfx900;gfx902;gfx906"
- "gfx908;gfx90a;gfx90c;gfx942;gfx950;gfx1010;gfx1030"
- "gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036"
- "gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151"
- "gfx1152;gfx1153;gfx1200;gfx1201"
- )
- set(all_nvptx_architectures
- "sm_35;sm_37;sm_50;sm_52;sm_53;sm_60;sm_61;sm_62"
- "sm_70;sm_72;sm_75;sm_80;sm_86;sm_89;sm_90"
- )
- set(all_gpu_architectures
- "${all_amdgpu_architectures};${all_nvptx_architectures}"
- )
- # TODO: support auto detection on the build system.
- if (FLANG_OMP_DEVICE_ARCHITECTURES STREQUAL "all")
- set(FLANG_OMP_DEVICE_ARCHITECTURES ${all_gpu_architectures})
- endif()
- list(REMOVE_DUPLICATES FLANG_OMP_DEVICE_ARCHITECTURES)
-
- string(REPLACE ";" "," compile_for_architectures
- "${FLANG_OMP_DEVICE_ARCHITECTURES}"
- )
-
- set(OMP_COMPILE_OPTIONS
- -fopenmp
- -fvisibility=hidden
- -fopenmp-cuda-mode
- --offload-arch=${compile_for_architectures}
- # Force LTO for the device part.
- -foffload-lto
- )
- set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS
- "${OMP_COMPILE_OPTIONS}"
- )
-
- # Enable "declare target" in the source code.
- set_source_files_properties(${files}
- PROPERTIES COMPILE_DEFINITIONS OMP_OFFLOAD_BUILD
- )
- else()
- message(FATAL_ERROR
- "Flang runtime build is not supported for these compilers:\n"
- "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}\n"
- "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
- endif()
- endif()
-endmacro()
diff --git a/flang/examples/CMakeLists.txt b/flang/examples/CMakeLists.txt
index 23c6e790791fb..746a6f23ae015 100644
--- a/flang/examples/CMakeLists.txt
+++ b/flang/examples/CMakeLists.txt
@@ -1,6 +1,3 @@
-if (FLANG_INCLUDE_RUNTIME)
- add_subdirectory(ExternalHelloWorld)
-endif ()
add_subdirectory(PrintFlangFunctionNames)
add_subdirectory(FlangOmpReport)
add_subdirectory(FeatureList)
diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
deleted file mode 100644
index dbb69475976dd..0000000000000
--- a/flang/examples/ExternalHelloWorld/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# This test is not run by default as it requires input.
-add_llvm_example(external-hello-world
- ${FLANG_RT_SOURCE_DIR}/examples/ExternalHelloWorld/external-hello.cpp
-)
-
-target_link_libraries(external-hello-world
- PRIVATE
- flang_rt.runtime
- )
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
deleted file mode 100644
index aac1f62661810..0000000000000
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-#===-- runtime/CUDA/CMakeLists.txt -----------------------------------------===#
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===------------------------------------------------------------------------===#
-
-include_directories(${CUDAToolkit_INCLUDE_DIRS})
-
-# libflang_rt.cuda depends on a certain version of CUDA. To be able to have
-# multiple build of this library with different CUDA version, the version is
-# added to the library name.
-set(CUFRT_LIBNAME flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
-
-set(sources
- allocator.cpp
- allocatable.cpp
- descriptor.cpp
- init.cpp
- kernel.cpp
- memmove-function.cpp
- memory.cpp
- pointer.cpp
- registration.cpp
-)
-runtime_source_files(sources SUBDIR "cuda")
-
-add_flang_library(${CUFRT_LIBNAME}
- ${sources}
-)
-
-if (BUILD_SHARED_LIBS)
- set(CUDA_RT_TARGET CUDA::cudart)
-else()
- set(CUDA_RT_TARGET CUDA::cudart_static)
-endif()
-
-target_link_libraries(${CUFRT_LIBNAME}
- PRIVATE
- flang_rt.runtime
- ${CUDA_RT_TARGET}
-)
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
deleted file mode 100644
index cdac5f893cf91..0000000000000
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ /dev/null
@@ -1,134 +0,0 @@
-#===-- runtime/Float128Math/CMakeLists.txt ---------------------------------===#
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===------------------------------------------------------------------------===#
-
-# FortranFloat128 implements IEEE-754 128-bit float math functions.
-# It is a thin wapper and it currently relies on third-party
-# libraries available for the target.
-# It is distributed as a static library only.
-# Fortran programs/libraries that end up linking any of the provided
-# will have a dependency on the third-party library that is being
-# used for building this flang_rt.quadmath library.
-
-include(CheckLibraryExists)
-
-set(sources
- acos.cpp
- acosh.cpp
- asin.cpp
- asinh.cpp
- atan.cpp
- atan2.cpp
- atanh.cpp
- ceil.cpp
- complex-math.c
- cos.cpp
- cosh.cpp
- erf.cpp
- erfc.cpp
- exp.cpp
- exponent.cpp
- floor.cpp
- fma.cpp
- fraction.cpp
- hypot.cpp
- j0.cpp
- j1.cpp
- jn.cpp
- lgamma.cpp
- llround.cpp
- log.cpp
- log10.cpp
- lround.cpp
- mod-real.cpp
- modulo-real.cpp
- nearest.cpp
- nearbyint.cpp
- norm2.cpp
- pow.cpp
- random.cpp
- remainder.cpp
- round.cpp
- rrspacing.cpp
- scale.cpp
- set-exponent.cpp
- sin.cpp
- sinh.cpp
- spacing.cpp
- sqrt.cpp
- tan.cpp
- tanh.cpp
- tgamma.cpp
- trunc.cpp
- y0.cpp
- y1.cpp
- yn.cpp
- )
-runtime_source_files(sources SUBDIR "quadmath")
-
-include_directories(AFTER "${CMAKE_CURRENT_SOURCE_DIR}/..")
-add_library(FortranFloat128MathILib INTERFACE)
-target_include_directories(FortranFloat128MathILib INTERFACE
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
- )
-
-if (FLANG_RUNTIME_F128_MATH_LIB)
- if (${FLANG_RUNTIME_F128_MATH_LIB} STREQUAL "libquadmath")
- check_include_file(quadmath.h FOUND_QUADMATH_HEADER)
- if(FOUND_QUADMATH_HEADER)
- add_compile_definitions(HAS_QUADMATHLIB)
- else()
- message(FATAL_ERROR
- "FLANG_RUNTIME_F128_MATH_LIB setting requires quadmath.h "
- "to be available: ${FLANG_RUNTIME_F128_MATH_LIB}"
- )
- endif()
- else()
- message(FATAL_ERROR
- "Unsupported third-party library for Fortran F128 math runtime: "
- "${FLANG_RUNTIME_F128_MATH_LIB}"
- )
- endif()
-
- add_flang_library(flang_rt.quadmath STATIC INSTALL_WITH_TOOLCHAIN
- ${sources})
-
- if (DEFINED MSVC)
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
- add_flang_library(flang_rt.quadmath.static STATIC INSTALL_WITH_TOOLCHAIN
- ${sources}
- )
- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
- add_flang_library(flang_rt.quadmath.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
- ${sources}
- )
- add_dependencies(flang_rt.quadmath flang_rt.quadmath.static
- flang_rt.quadmath.static_dbg
- )
- endif()
-elseif (HAVE_LDBL_MANT_DIG_113)
- # We can use 'long double' versions from libc.
- check_library_exists(m sinl "" FOUND_LIBM)
- if (FOUND_LIBM)
- target_compile_definitions(FortranFloat128MathILib INTERFACE
- HAS_LIBM
- )
- target_sources(FortranFloat128MathILib INTERFACE ${sources})
- else()
- message(FATAL_ERROR "flang_rt.quadmath cannot build without libm")
- endif()
-else()
- # We can use '__float128' version from libc, if it has them.
- check_library_exists(m sinf128 "" FOUND_LIBMF128)
- if (FOUND_LIBMF128)
- target_compile_definitions(FortranFloat128MathILib INTERFACE
- HAS_LIBMF128
- )
- # Enable this, when math-entries.h and complex-math.h is ready.
- # target_sources(FortranFloat128MathILib INTERFACE ${sources})
- endif()
-endif()
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index 777cf5fc5433b..6a39f098724cd 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -78,10 +78,6 @@ if (NOT FLANG_STANDALONE_BUILD)
)
endif ()
-if (FLANG_INCLUDE_RUNTIME)
- list(APPEND FLANG_TEST_DEPENDS flang_rt.runtime)
-endif ()
-
if (LLVM_ENABLE_PLUGINS AND NOT WIN32 AND NOT FLANG_STANDALONE_BUILD)
list(APPEND FLANG_TEST_DEPENDS Bye)
endif()
@@ -128,9 +124,3 @@ if (DEFINED FLANG_TEST_TARGET_TRIPLE)
"to use FLANG_TEST_TARGET_TRIPLE.")
endif()
endif()
-
-# Compatibility targets.
-if (FLANG_INCLUDE_RUNTIME)
- add_custom_target(check-flang-rt)
- add_dependencies(check-flang-rt check-flang)
-endif ()
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index 0ba80f9a03f2e..aa27fdc2fe412 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -163,9 +163,6 @@
ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
)
-if config.flang_include_runtime:
- config.available_features.add("flang-rt")
-
# Add all the tools and their substitutions (if applicable). Use the search paths provided for
# finding the tools.
if config.flang_standalone_build:
diff --git a/flang/test/lit.site.cfg.py.in b/flang/test/lit.site.cfg.py.in
index 5b66e592bcfee..ae5144010bc8b 100644
--- a/flang/test/lit.site.cfg.py.in
+++ b/flang/test/lit.site.cfg.py.in
@@ -30,7 +30,6 @@ else:
config.openmp_module_dir = None
config.flang_runtime_f128_math_lib = "@FLANG_RUNTIME_F128_MATH_LIB@"
config.have_ldbl_mant_dig_113 = "@HAVE_LDBL_MANT_DIG_113@"
-config.flang_include_runtime = lit.util.pythonize_bool("@FLANG_INCLUDE_RUNTIME@")
import lit.llvm
lit.llvm.initialize(lit_config, config)
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 5b5f23b5dc73c..44bddfd4caf99 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -4,16 +4,9 @@ set(LLVM_LINK_COMPONENTS
Support
)
-# Define the list of Fortran module files that need to be compiled
-# to produce an object file for inclusion into the flang_rt.runtime
-# library.
-set(MODULES_WITH_IMPLEMENTATION
- "iso_fortran_env_impl"
-)
-
# Define the list of Fortran module files for which it is
# sufficient to generate the module file via -fsyntax-only.
-set(MODULES_WITHOUT_IMPLEMENTATION
+set(MODULES
"__fortran_builtins"
"__fortran_ieee_exceptions"
"__fortran_type_info"
@@ -28,10 +21,9 @@ set(MODULES_WITHOUT_IMPLEMENTATION
"ieee_features"
"iso_c_binding"
"iso_fortran_env"
+ "iso_fortran_env_impl"
)
-set(MODULES ${MODULES_WITH_IMPLEMENTATION} ${MODULES_WITHOUT_IMPLEMENTATION})
-
# Check if 128-bit float computations can be done via long double.
check_cxx_source_compiles(
"#include <cfloat>
@@ -109,11 +101,6 @@ if (NOT CMAKE_CROSSCOMPILING)
set(compile_with "-fsyntax-only")
set(object_output "")
set(include_in_link FALSE)
- if(${filename} IN_LIST MODULES_WITH_IMPLEMENTATION AND FLANG_INCLUDE_RUNTIME)
- set(object_output "${CMAKE_CURRENT_BINARY_DIR}/${filename}${CMAKE_CXX_OUTPUT_EXTENSION}")
- set(compile_with -c -o ${object_output})
- set(include_in_link TRUE)
- endif()
set(base ${FLANG_INTRINSIC_MODULES_DIR}/${filename})
# TODO: We may need to flag this with conditional, in case Flang is built w/o OpenMP support
diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt
index a02f791135f1f..b4e969c9426ee 100644
--- a/flang/unittests/CMakeLists.txt
+++ b/flang/unittests/CMakeLists.txt
@@ -1,5 +1,3 @@
-include(AddFlangOffloadRuntime)
-
if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
# If Fortran runtime is built as CUDA library, the linking
# of targets that link flang_rt.runtime must be done
@@ -12,38 +10,8 @@ endif()
add_custom_target(FlangUnitTests)
set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang/Tests")
-include_directories("${FLANG_RT_SOURCE_DIR}/include")
-
-function(add_flang_unittest_offload_properties target)
- # Do not apply runtime properties if not even compiling the runtime.
- if (NOT FLANG_INCLUDE_RUNTIME)
- return ()
- endif ()
-
- # Set CUDA_RESOLVE_DEVICE_SYMBOLS.
- if (FLANG_EXPERIMENTAL_CUDA_RUNTIME)
- set_target_properties(${target}
- PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON
- )
- endif()
- # Enable OpenMP offload during linking. We may need to replace
- # LINK_OPTIONS with COMPILE_OPTIONS when there are OpenMP offload
- # unittests.
- #
- # FIXME: replace 'native' in --offload-arch option with the list
- # of targets that Fortran Runtime was built for.
- # Common code must be moved from flang/runtime/CMakeLists.txt.
- if (NOT FLANG_EXPERIMENTAL_OMP_OFFLOAD_BUILD STREQUAL "off")
- set_target_properties(${target}
- PROPERTIES LINK_OPTIONS
- "-fopenmp;--offload-arch=native"
- )
- endif()
-endfunction()
-
function(add_flang_unittest test_dirname)
add_unittest(FlangUnitTests ${test_dirname} ${ARGN})
- add_flang_unittest_offload_properties(${test_dir...
[truncated]
|
All the buildbots and the pre-merge CI have been updated. Ready for review. Pre-merge faire failure is unrelated (comes from BOLT) |
llvm/CMakeLists.txt
Outdated
message(STATUS "Enabling Flang-RT as a dependency of Flang" | ||
"Flang-RT is required for a fully working Flang toolchain." | ||
"If you intend to compile Flang-RT separately following the instructions at" | ||
"https://github.com/llvm/llvm-project/blob/main/flang-rt/README.md#standalone-runtimes-build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directly linking to a github readme is a little weird. Do we not have a documentation page for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no flang-rt.llvm.org . I do find several links to github.com in llvm/docs, such as
llvm-project/llvm/docs/TableGen/index.rst
Line 291 in 9387281
`README <https://github.com/llvm/llvm-project/blob/main/llvm/utils/TableGen/README.md>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's https://flang.llvm.org/docs/ right? it's not a blocking issue, I just feel like build configs are better shared through CMake config files or actual documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to update the docs in a follow-up? Consolidating this README.md and https://flang.llvm.org/docs/GettingStarted.html#building-flang itself would be a larger patch. Also think that advanced topics like FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT does not belong into a GettingStarted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the help message(...)
to flang/ so a message is also emitted in a flang-standalone build (which is does not process LLVM_ENABLE_RUNTIMES at all). I also shortened it without the README link, may update it after consolidation.
@@ -1,9 +0,0 @@ | |||
# This test is not run by default as it requires input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing this was already copied somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flang-rt version of this example is here: https://github.com/llvm/llvm-project/blob/main/flang-rt/examples/ExternalHelloWorld/CMakeLists.txt
This is an example that links to flang-rt from C++. No use of a Fortran compiler. The .cpp itself was moved in #110298
Everything is ready on my side. Thank you for waiting, Michael! LGTM |
Flang's runtime can now be built using LLVM's LLVM_ENABLE_RUNTIMES mechanism, with the intent to remove the old mechanism in llvm#124126. Update the pre-merge builders to use the new mechanism. In the current form, llvm#124126 actually will add LLVM_ENABLE_RUNTIMES=flang-rt implicitly, so no change is strictly needed. I still think it is a good idea to do it explicitly and in advance. On Windows, flang-rt also requires compiler-rt, but which is not building on Windows anyway.
After AMD gave their OK as well, I am going to land this. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/152/builds/1292 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/7/builds/12751 Here is the relevant piece of the build log for the reference
|
The production buildbot master apparently has not yet been restarted since llvm/llvm-zorg#393 landed. This reverts commit 96d1bae.
The two builders failing were supposed to be updated by llvm/llvm-zorg#393. Have to wait until https://lab.llvm.org/buildbot/ is restarted before relanding. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/9845 Here is the relevant piece of the build log for the reference
|
Remove the FLANG_INCLUDE_RUNTIME option which was replaced by LLVM_ENABLE_RUNTIMES=flang-rt.
The FLANG_INCLUDE_RUNTIME option was added in #122336 which disables the non-runtimes build instructions for the Flang runtime so they do not conflict with the LLVM_ENABLE_RUNTIMES=flang-rt option added in #110217. In order to not maintain multiple build instructions for the same thing, this PR completely removes the old build instructions (effectively forcing FLANG_INCLUDE_RUNTIME=OFF).
As per discussion in https://discourse.llvm.org/t/buildbot-changes-with-llvm-enable-runtimes-flang-rt/83571/2 we now implicitly add LLVM_ENABLE_RUNTIMES=flang-rt whenever Flang is compiled in a bootstrapping (non-standalone) build. Because it is possible to build Flang-RT separately, this behavior can be disabled using
-DFLANG_ENABLE_FLANG_RT=OFF
. Also see the discussion an implicitly adding runtimes/projects in #123964.This PR will remains in draft status until the buildbots' configurations have been updated. Due to LLVM_ENABLE_RUNTIMES=flang-rt being added automatically, most of them would probably continue to work, except the out-of-tree builders which require some adjustment.
Series of buildbot updates: