[flang-commits] [flang] [Flang] Remove FLANG_INCLUDE_RUNTIME (PR #124126)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Fri Feb 21 09:47:14 PST 2025


https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/124126

>From 698bcd08e2a0612bf8638f08c9ac93ec147a4a36 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 21 Feb 2025 18:46:17 +0100
Subject: [PATCH] Remove FLANG_INCLUDE_RUNTIME

---
 flang/CMakeLists.txt                          |  31 +---
 .../modules/AddFlangOffloadRuntime.cmake      | 146 ------------------
 flang/examples/CMakeLists.txt                 |   3 -
 .../ExternalHelloWorld/CMakeLists.txt         |   9 --
 flang/runtime/CUDA/CMakeLists.txt             |  43 ------
 flang/runtime/Float128Math/CMakeLists.txt     | 134 ----------------
 flang/test/CMakeLists.txt                     |  10 --
 flang/test/lit.cfg.py                         |   3 -
 flang/test/lit.site.cfg.py.in                 |   1 -
 flang/tools/f18/CMakeLists.txt                |  17 +-
 flang/unittests/CMakeLists.txt                |  43 +-----
 flang/unittests/Evaluate/CMakeLists.txt       |  16 --
 12 files changed, 5 insertions(+), 451 deletions(-)
 delete mode 100644 flang/cmake/modules/AddFlangOffloadRuntime.cmake
 delete mode 100644 flang/examples/ExternalHelloWorld/CMakeLists.txt
 delete mode 100644 flang/runtime/CUDA/CMakeLists.txt
 delete mode 100644 flang/runtime/Float128Math/CMakeLists.txt

diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index ac8f784fd811e..ca5e632e9e2e2 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
@@ -474,12 +457,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)
@@ -490,10 +467,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 8e4f47d18535d..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;gfx940;gfx1010;gfx1030"
-        "gfx1031;gfx1032;gfx1033;gfx1034;gfx1035;gfx1036"
-        "gfx1100;gfx1101;gfx1102;gfx1103;gfx1150;gfx1151"
-        "gfx1152;gfx1153"
-        )
-      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_dirname})
 endfunction()
 
 if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
@@ -63,11 +31,7 @@ function(add_flang_nongtest_unittest test_name)
       set(suffix .test)
   endif()
 
-  # Sources for runtime tests are in Flang-RT.
-  set(test_filepath "${FLANG_RT_SOURCE_DIR}/unittests/Evaluate/${test_name}.cpp")
-  if (NOT EXISTS "${test_filepath}")
-    set(test_filepath "${test_name}.cpp")
-  endif ()
+  set(test_filepath "${test_name}.cpp")
 
   add_executable(${test_name}${suffix} "${test_filepath}")
   set_target_properties(${test_name}${suffix} PROPERTIES FOLDER "Flang/Tests/Unit")
@@ -82,15 +46,10 @@ function(add_flang_nongtest_unittest test_name)
   if(NOT ARG_SLOW_TEST)
     add_dependencies(FlangUnitTests ${test_name}${suffix})
   endif()
-
-  add_flang_unittest_offload_properties(${test_name}${suffix})
 endfunction()
 
 add_subdirectory(Optimizer)
 add_subdirectory(Common)
 add_subdirectory(Decimal)
 add_subdirectory(Evaluate)
-if (FLANG_INCLUDE_RUNTIME)
-  add_subdirectory(Runtime)
-endif ()
 add_subdirectory(Frontend)
diff --git a/flang/unittests/Evaluate/CMakeLists.txt b/flang/unittests/Evaluate/CMakeLists.txt
index 2278d61febcb1..ed012828a7258 100644
--- a/flang/unittests/Evaluate/CMakeLists.txt
+++ b/flang/unittests/Evaluate/CMakeLists.txt
@@ -55,22 +55,6 @@ add_flang_nongtest_unittest(real
 )
 llvm_update_compile_flags(real.test)
 
-if (FLANG_INCLUDE_RUNTIME)
-  add_flang_nongtest_unittest(reshape
-    NonGTestTesting
-    FortranSemantics
-    FortranEvaluate
-    flang_rt.runtime
-  )
-
-  add_flang_nongtest_unittest(ISO-Fortran-binding
-    NonGTestTesting
-    FortranEvaluate
-    FortranSemantics
-    flang_rt.runtime
-  )
-endif ()
-
 add_flang_nongtest_unittest(folding
   FortranSupport
   NonGTestTesting



More information about the flang-commits mailing list