llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-flang-fir-hlfir Author: Jan Patrick Lehr (jplehr) <details> <summary>Changes</summary> Reverts llvm/llvm-project#<!-- -->137828 Buildbot error in https://lab.llvm.org/staging/#/builders/105/builds/37275 --- Patch is 88.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/169489.diff 64 Files Affected: - (modified) clang/include/clang/Driver/ToolChain.h (-4) - (modified) clang/include/clang/Options/Options.td (+1-1) - (modified) clang/lib/Driver/Driver.cpp (-11) - (modified) clang/lib/Driver/ToolChain.cpp (-6) - (modified) clang/lib/Driver/ToolChains/Flang.cpp (-8) - (modified) flang-rt/CMakeLists.txt (+86-11) - (modified) flang-rt/cmake/modules/AddFlangRT.cmake (+4-25) - (modified) flang-rt/cmake/modules/AddFlangRTOffload.cmake (+4-10) - (removed) flang-rt/cmake/modules/FlangRTIntrospection.cmake (-37) - (renamed) flang-rt/cmake/modules/GetToolchainDirs.cmake (-11) - (modified) flang-rt/lib/runtime/CMakeLists.txt (+13-102) - (modified) flang-rt/test/lit.site.cfg.py.in (+1-1) - (modified) flang-rt/unittests/CMakeLists.txt (+3-2) - (modified) flang/CMakeLists.txt (+1) - (modified) flang/include/flang/Frontend/CompilerInvocation.h (-7) - (modified) flang/lib/Frontend/CompilerInvocation.cpp (+13-13) - (modified) flang/lib/Semantics/semantics.cpp (+5-8) - (added) flang/module/.clang-format (+1) - (renamed) flang/module/__cuda_builtins.f90 () - (renamed) flang/module/__cuda_device.f90 () - (renamed) flang/module/__fortran_builtins.f90 (+1-1) - (renamed) flang/module/__fortran_ieee_exceptions.f90 () - (renamed) flang/module/__fortran_type_info.f90 () - (renamed) flang/module/__ppc_intrinsics.f90 () - (renamed) flang/module/__ppc_types.f90 () - (renamed) flang/module/cooperative_groups.f90 (-1) - (renamed) flang/module/cudadevice.f90 () - (renamed) flang/module/ieee_arithmetic.f90 (+1-1) - (renamed) flang/module/ieee_exceptions.f90 () - (renamed) flang/module/ieee_features.f90 () - (renamed) flang/module/iso_c_binding.f90 () - (renamed) flang/module/iso_fortran_env.f90 () - (renamed) flang/module/iso_fortran_env_impl.f90 () - (renamed) flang/module/mma.f90 () - (modified) flang/test/CMakeLists.txt (+3-28) - (modified) flang/test/Driver/Inputs/ieee_arithmetic.mod (-1) - (modified) flang/test/Driver/Inputs/iso_fortran_env.mod (-1) - (removed) flang/test/Driver/intrinsic-module-path.F90 (-55) - (added) flang/test/Driver/intrinsic-module-path.f90 (+23) - (modified) flang/test/Driver/lto-fatlto.f90 (+2-2) - (modified) flang/test/Driver/pp-fixed-form.f90 (+2-2) - (modified) flang/test/Lower/HLFIR/type-bound-call-mismatch.f90 (+1-1) - (modified) flang/test/Lower/OpenMP/simd_aarch64.f90 (+1-6) - (modified) flang/test/Lower/OpenMP/target-enter-data-default-openmp52.f90 (+2-2) - (modified) flang/test/Preprocessing/fixed-free.f (+1-1) - (modified) flang/test/Preprocessing/no-pp-if.f90 (+1-1) - (modified) flang/test/Semantics/bug163242.f90 (+1-1) - (modified) flang/test/Semantics/bug164303.f90 (+1-1) - (modified) flang/test/lit.cfg.py (+13-81) - (modified) flang/test/lit.site.cfg.py.in (+6-3) - (modified) flang/tools/CMakeLists.txt (+1) - (modified) flang/tools/bbc/bbc.cpp (+8-5) - (added) flang/tools/f18/CMakeLists.txt (+170) - (added) flang/tools/f18/dump.cpp (+42) - (modified) llvm/runtimes/CMakeLists.txt (+11-13) - (modified) openmp/CMakeLists.txt (-6) - (modified) openmp/runtime/CMakeLists.txt (+7-1) - (added) openmp/runtime/cmake/LibompCheckFortranFlag.cmake (+29) - (modified) openmp/runtime/cmake/LibompHandleFlags.cmake (+11) - (modified) openmp/runtime/cmake/config-ix.cmake (+4) - (modified) openmp/runtime/src/CMakeLists.txt (+43-20) - (modified) openmp/runtime/test/lit.cfg (-1) - (modified) openmp/runtime/test/lit.site.cfg.in (-1) - (modified) runtimes/CMakeLists.txt (+11-212) ``````````diff diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 26af88242eb3e..1425714d34110 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -538,10 +538,6 @@ class ToolChain { // Returns Triple without the OSs version. llvm::Triple getTripleWithoutOSVersion() const; - /// Returns the target-specific path for Flang's intrinsic modules in the - /// resource directory if it exists. - std::optional<std::string> getDefaultIntrinsicModuleDir() const; - // Returns the target specific runtime path if it exists. std::optional<std::string> getRuntimePath() const; diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index 0e88656c5e1bc..a8fc1c4326cc5 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -6082,7 +6082,7 @@ def prebind : Flag<["-"], "prebind">; def preload : Flag<["-"], "preload">; def print_file_name_EQ : Joined<["-", "--"], "print-file-name=">, HelpText<"Print the full library path of <file>">, MetaVarName<"<file>">, - Visibility<[ClangOption, FlangOption, CLOption]>; + Visibility<[ClangOption, CLOption]>; def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Visibility<[ClangOption, CC1Option]>, HelpText<"Enable Objective-C Ivar layout bitmap print trace">, diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 781bc74466da1..de8d4601210ae 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6602,17 +6602,6 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const { if (llvm::sys::fs::exists(Twine(P))) return std::string(P); - // With Flang, also look for instrinsic modules - if (IsFlangMode()) { - if (std::optional<std::string> IntrPath = - TC.getDefaultIntrinsicModuleDir()) { - SmallString<128> P(*IntrPath); - llvm::sys::path::append(P, Name); - if (llvm::sys::fs::exists(Twine(P))) - return std::string(P); - } - } - SmallString<128> D(Dir); llvm::sys::path::append(D, "..", Name); if (llvm::sys::fs::exists(Twine(D))) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index f8520725b9b03..77a2c73f0d446 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1020,12 +1020,6 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const { return {}; } -std::optional<std::string> ToolChain::getDefaultIntrinsicModuleDir() const { - SmallString<128> P(D.ResourceDir); - llvm::sys::path::append(P, "finclude", "flang"); - return getTargetSubDirPath(P); -} - std::optional<std::string> ToolChain::getRuntimePath() const { SmallString<128> P(D.ResourceDir); llvm::sys::path::append(P, "lib"); diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index bac421bb86f49..cc4755cd6a9b0 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -1060,14 +1060,6 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-resource-dir"); CmdArgs.push_back(D.ResourceDir.c_str()); - // Default intrinsic module dirs must be added after any user-provided - // -fintrinsic-modules-path to have lower precedence - if (std::optional<std::string> IntrModPath = - TC.getDefaultIntrinsicModuleDir()) { - CmdArgs.push_back("-fintrinsic-modules-path"); - CmdArgs.push_back(Args.MakeArgString(*IntrModPath)); - } - // Offloading related options addOffloadOptions(C, Inputs, JA, Args, CmdArgs); diff --git a/flang-rt/CMakeLists.txt b/flang-rt/CMakeLists.txt index db0d87d91ea83..50b8e834776fb 100644 --- a/flang-rt/CMakeLists.txt +++ b/flang-rt/CMakeLists.txt @@ -23,6 +23,40 @@ set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(FLANG_RT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang") +# CMake 3.24 is the first version of CMake that directly recognizes Flang. +# LLVM's requirement is only CMake 3.20, teach CMake 3.20-3.23 how to use Flang. +if (CMAKE_VERSION VERSION_LESS "3.24") + cmake_path(GET CMAKE_Fortran_COMPILER STEM _Fortran_COMPILER_STEM) + if (_Fortran_COMPILER_STEM STREQUAL "flang-new" OR _Fortran_COMPILER_STEM STREQUAL "flang") + include(CMakeForceCompiler) + CMAKE_FORCE_Fortran_COMPILER("${CMAKE_Fortran_COMPILER}" "LLVMFlang") + + set(CMAKE_Fortran_COMPILER_ID "LLVMFlang") + set(CMAKE_Fortran_COMPILER_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") + + set(CMAKE_Fortran_SUBMODULE_SEP "-") + set(CMAKE_Fortran_SUBMODULE_EXT ".mod") + + set(CMAKE_Fortran_PREPROCESS_SOURCE + "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") + + set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") + set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + + set(CMAKE_Fortran_MODDIR_FLAG "-module-dir") + + set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp") + set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp") + set(CMAKE_Fortran_POSTPROCESS_FLAG "-ffixed-line-length-72") + + set(CMAKE_Fortran_COMPILE_OPTIONS_TARGET "--target=") + + set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",") + endif () +endif () +enable_language(Fortran) + list(APPEND CMAKE_MODULE_PATH "${FLANG_RT_SOURCE_DIR}/cmake/modules" @@ -31,24 +65,69 @@ list(APPEND CMAKE_MODULE_PATH include(AddFlangRT) include(GetToolchainDirs) include(FlangCommon) -include(FlangRTIntrospection) include(HandleCompilerRT) include(ExtendPath) -include(CheckFortranSourceCompiles) -include(CMakePushCheckState) ############################ # Build Mode Introspection # ############################ +# Determine whether we are in the runtimes/runtimes-bins directory of a +# bootstrap build. +set(LLVM_TREE_AVAILABLE OFF) +if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION) + set(LLVM_TREE_AVAILABLE ON) +endif() + # Path to LLVM development tools (FileCheck, llvm-lit, not, ...) set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin") -# Fortran compiler not optional for building Flang-RT -enable_language(Fortran) - -flang_module_fortran_enable() +# Determine build and install paths. +# The build path is absolute, but the install dir is relative, CMake's install +# command has to apply CMAKE_INSTALL_PREFIX itself. +get_toolchain_library_subdir(toolchain_lib_subdir) +if (LLVM_TREE_AVAILABLE) + # In a bootstrap build emit the libraries into a default search path in the + # build directory of the just-built compiler. This allows using the + # just-built compiler without specifying paths to runtime libraries. + # + # Despite Clang in the name, get_clang_resource_dir does not depend on Clang + # being added to the build. Flang uses the same resource dir as clang. + include(GetClangResourceDir) + get_clang_resource_dir(FLANG_RT_OUTPUT_RESOURCE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/..") + get_clang_resource_dir(FLANG_RT_INSTALL_RESOURCE_PATH_DEFAULT) + + extend_path(FLANG_RT_OUTPUT_RESOURCE_LIB_DIR "${FLANG_RT_OUTPUT_RESOURCE_DIR}" "${toolchain_lib_subdir}") +else () + # In a standalone runtimes build, do not write into LLVM_BINARY_DIR. It may be + # read-only and/or shared by multiple runtimes with different build + # configurations (e.g. Debug/Release). Use the runtime's own lib dir like any + # non-toolchain library. + # For the install prefix, still use the resource dir assuming that Flang will + # be installed there using the same prefix. This is to not have a difference + # between bootstrap and standalone runtimes builds. + set(FLANG_RT_OUTPUT_RESOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}") + set(FLANG_RT_INSTALL_RESOURCE_PATH_DEFAULT "lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}") + + extend_path(FLANG_RT_OUTPUT_RESOURCE_LIB_DIR "${FLANG_RT_OUTPUT_RESOURCE_DIR}" "lib${LLVM_LIBDIR_SUFFIX}") +endif () +set(FLANG_RT_INSTALL_RESOURCE_PATH "${FLANG_RT_INSTALL_RESOURCE_PATH_DEFAULT}" + CACHE PATH "Path to install runtime libraries to (default: clang resource dir)") +extend_path(FLANG_RT_INSTALL_RESOURCE_LIB_PATH "${FLANG_RT_INSTALL_RESOURCE_PATH}" "${toolchain_lib_subdir}") +cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_DIR) +cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_PATH) +# FIXME: For the libflang_rt.so, the toolchain resource lib dir is not a good +# destination because it is not a ld.so default search path. +# The machine where the executable is eventually executed may not be the +# machine where the Flang compiler and its resource dir is installed, so +# setting RPath by the driver is not an solution. It should belong into +# /usr/lib/<triple>/libflang_rt.so, like e.g. libgcc_s.so. +# But the linker as invoked by the Flang driver also requires +# libflang_rt.so to be found when linking and the resource lib dir is +# the only reliable location. +cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_LIB_DIR) +cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH) ################# @@ -155,10 +234,6 @@ check_cxx_source_compiles( " HAVE_DECL_STRERROR_S) -# Look for support of REAL(16), if not already defined via command -# line via -DFORTRAN_SUPPORTS_REAL16=YES/NO -check_fortran_quadmath_support() - # Search for clang_rt.builtins library. Need in addition to msvcrt. if (WIN32) find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY) diff --git a/flang-rt/cmake/modules/AddFlangRT.cmake b/flang-rt/cmake/modules/AddFlangRT.cmake index b3f2cd07c0aed..923507764d691 100644 --- a/flang-rt/cmake/modules/AddFlangRT.cmake +++ b/flang-rt/cmake/modules/AddFlangRT.cmake @@ -190,12 +190,6 @@ function (add_flangrt_library name) endif () endif () - if (build_object) - add_library(${name}.compile ALIAS "${name_object}") - else () - add_library(${name}.compile ALIAS "${default_target}") - endif () - foreach (tgtname IN LISTS libtargets) if (NOT WIN32) # Use same stem name for .a and .so. Common in UNIX environments. @@ -225,17 +219,6 @@ function (add_flangrt_library name) # Minimum required C++ version for Flang-RT, even if CMAKE_CXX_STANDARD is defined to something else. target_compile_features(${tgtname} PRIVATE cxx_std_17) - target_compile_options(${tgtname} PRIVATE - # Always enable preprocessor regardless of file extention - "$<$<COMPILE_LANGUAGE:Fortran>:-cpp>" - - # Missing type descriptors are expected for intrinsic modules - "$<$<COMPILE_LANGUAGE:Fortran>:SHELL:-mmlir;SHELL:-ignore-missing-type-desc>" - - # Flang bug workaround: Reformating of cooked token buffer causes identifier to be split between lines - "$<$<COMPILE_LANGUAGE:Fortran>:SHELL:-Xflang;SHELL:-fno-reformat>" - ) - # When building the flang runtime if LTO is enabled the archive file # contains LLVM IR rather than object code. Currently flang is not # LTO aware so cannot link this file to compiled Fortran code. @@ -243,10 +226,6 @@ function (add_flangrt_library name) target_compile_options(${tgtname} PRIVATE -fno-lto) endif () - if (FORTRAN_SUPPORTS_REAL16) - target_compile_definitions(${tgtname} PRIVATE FLANG_SUPPORT_R16=1) - endif () - # Use compiler-specific options to disable exceptions and RTTI. if (LLVM_COMPILER_IS_GCC_COMPATIBLE) target_compile_options(${tgtname} PRIVATE @@ -365,13 +344,13 @@ function (add_flangrt_library name) if (ARG_INSTALL_WITH_TOOLCHAIN) set_target_properties(${tgtname} PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${RUNTIMES_OUTPUT_RESOURCE_LIB_DIR}" - LIBRARY_OUTPUT_DIRECTORY "${RUNTIMES_OUTPUT_RESOURCE_LIB_DIR}" + ARCHIVE_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${FLANG_RT_OUTPUT_RESOURCE_LIB_DIR}" ) install(TARGETS ${tgtname} - ARCHIVE DESTINATION "${RUNTIMES_INSTALL_RESOURCE_LIB_PATH}" - LIBRARY DESTINATION "${RUNTIMES_INSTALL_RESOURCE_LIB_PATH}" + ARCHIVE DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}" + LIBRARY DESTINATION "${FLANG_RT_INSTALL_RESOURCE_LIB_PATH}" ) endif () diff --git a/flang-rt/cmake/modules/AddFlangRTOffload.cmake b/flang-rt/cmake/modules/AddFlangRTOffload.cmake index 4a6f047a86af2..cbc69f3a9656a 100644 --- a/flang-rt/cmake/modules/AddFlangRTOffload.cmake +++ b/flang-rt/cmake/modules/AddFlangRTOffload.cmake @@ -88,16 +88,16 @@ macro(enable_omp_offload_compilation name files) "${FLANG_RT_DEVICE_ARCHITECTURES}" ) - set(OMP_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:C,CXX>: + set(OMP_COMPILE_OPTIONS -fopenmp -fvisibility=hidden -fopenmp-cuda-mode --offload-arch=${compile_for_architectures} # Force LTO for the device part. -foffload-lto - >) - set_property(SOURCE ${files} APPEND - PROPERTY COMPILE_DEFINITIONS ${OMP_COMPILE_OPTIONS} + ) + set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS + "${OMP_COMPILE_OPTIONS}" ) target_link_options(${name}.static PUBLIC ${OMP_COMPILE_OPTIONS}) @@ -105,12 +105,6 @@ macro(enable_omp_offload_compilation name files) set_source_files_properties(${files} PROPERTIES COMPILE_DEFINITIONS OMP_OFFLOAD_BUILD ) - - # If building flang-rt together with libomp, ensure that libomp is built first and found because -fopenmp will try to link it. - if (TARGET omp) - add_dependencies(${name} omp) - target_link_options(${name}.static PUBLIC "-L$<TARGET_FILE_DIR:omp>") - endif () else() message(FATAL_ERROR "Flang-rt build with OpenMP offload is not supported for these compilers:\n" diff --git a/flang-rt/cmake/modules/FlangRTIntrospection.cmake b/flang-rt/cmake/modules/FlangRTIntrospection.cmake deleted file mode 100644 index ddec624e320e7..0000000000000 --- a/flang-rt/cmake/modules/FlangRTIntrospection.cmake +++ /dev/null @@ -1,37 +0,0 @@ -#===-- cmake/modules/FlangRTIntrospection.cmake ----------------------------===# -# -# 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 -# -#===------------------------------------------------------------------------===# - - -# Check whether the Fortran compiler supports real(16)/quadmath types -# -# Implementation notes: -# * FORTRAN_SUPPORTS_REAL16 can be set externally in a bootstrapping-runtimes -# build to ensure consistency of real(16) support between compiler and -# runtime. -# -# * Does not work with Flang and CMake < 3.24 -# -# * This is intentionally wrapped in a function to get its own namespace for -# CMAKE_REQUIRED_FLAGS and CMAKE_TRY_COMPILE_TARGET_TYPE. In particular, -# cmake_pop_check_state() does not reset CMAKE_TRY_COMPILE_TARGET_TYPE, -# causing later try_compile invocations to fail. If you see -# enable_language(CUDA) failing because CMAKE_RANLIB is empty, this is the -# reason. -function (check_fortran_quadmath_support) - cmake_push_check_state(RESET) - set(CMAKE_REQUIRED_FLAGS "-ffree-form") - set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") # Skip link step - check_fortran_source_compiles([[ - subroutine test_quadmath - real(16) :: var1 - end - ]] - FORTRAN_SUPPORTS_REAL16 - ) - cmake_pop_check_state() -endfunction () diff --git a/cmake/Modules/GetToolchainDirs.cmake b/flang-rt/cmake/modules/GetToolchainDirs.cmake similarity index 94% rename from cmake/Modules/GetToolchainDirs.cmake rename to flang-rt/cmake/modules/GetToolchainDirs.cmake index ce2f8c294b2bc..fba12502b5946 100644 --- a/cmake/Modules/GetToolchainDirs.cmake +++ b/flang-rt/cmake/modules/GetToolchainDirs.cmake @@ -47,17 +47,6 @@ function (get_toolchain_library_subdir outvar) endfunction () -# Corresponds to Flang's ToolChain::getDefaultIntrinsicModuleDir(). -function (get_toolchain_module_subdir outvar) - set(outval "finclude/flang") - - get_toolchain_arch_dirname(arch_dirname) - set(outval "${outval}/${arch_dirname}") - - set(${outvar} "${outval}" PARENT_SCOPE) -endfunction () - - # Corresponds to Clang's ToolChain::getOSLibName(). Adapted from Compiler-RT. function (get_toolchain_os_dirname outvar) if (ANDROID) diff --git a/flang-rt/lib/runtime/CMakeLists.txt b/flang-rt/lib/runtime/CMakeLists.txt index a678055430233..e8f70bd544e0b 100644 --- a/flang-rt/lib/runtime/CMakeLists.txt +++ b/flang-rt/lib/runtime/CMakeLists.txt @@ -12,13 +12,6 @@ find_package(Backtrace) set(HAVE_BACKTRACE ${Backtrace_FOUND}) set(BACKTRACE_HEADER ${Backtrace_HEADER}) -# Module sources that are required by other modules -set(intrinsics_sources - __fortran_builtins.f90 - __cuda_builtins.f90 -) - - # List of files that are buildable for all devices. set(supported_sources ${FLANG_SOURCE_DIR}/lib/Decimal/binary-to-decimal.cpp @@ -80,16 +73,7 @@ set(supported_sources # List of source not used for GPU offloading. set(host_sources - __fortran_ieee_exceptions.f90 - __fortran_type_info.f90 - iso_fortran_env.f90 - ieee_arithmetic.f90 - ieee_exceptions.f90 - ieee_features.f90 - iso_c_binding.f90 - iso_fortran_env_impl.f90 - iso_fortran_env.f90 - + ${FLANG_SOURCE_DIR}/module/iso_fortran_env_impl.f90 command.cpp complex-powi.cpp complex-reduction.c @@ -104,32 +88,8 @@ set(host_sources temporary-stack.cpp time-intrinsic.cpp unit-map.cpp - - __cuda_device.f90 - cooperative_groups.f90 - cudadevice.f90 ) -if (LLVM_TARGET_TRIPLE MATCHES "^ppc|^powerpc") - list(APPEND intrinsics_sources - __ppc_types.f90 - ) - list(APPEND host_sources - __ppc_intrinsics.f90 - mma.f90 - ) -endif () - -# Compile as CUDA-Fortran, not directly supported by CMake -set_property(SOURCE - __cuda_device.f90 - cooperative_groups.f90 - cudadevice.f90 - APPEND PROPERTY - COMPILE_OPTIONS --offload-host-only -xcuda -) - - # Sources that can be compiled directly for the GPU. set(gpu_sources ${FLANG_SOURCE_DIR}/lib/Decimal/binary-to-decimal.cpp @@ -215,42 +175,19 @@ else () set(f128_sources "") endif () -if (LLVM_RUNTIMES_TARGET MATCHES "^amdgcn|^nvptx") +if ("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn|^nvptx") set(sources ${gpu_sources}) +elseif(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA") + set(sources ${supported_sources}) else () set(sources ${supported_sources} ${host_sources} ${f128_sources}) endif () -# check-flang depends on this to build intrinsic modules -if (NOT TARGET flang-rt-mod) - add_custom_target(flang-rt-mod) -endif () - if (NOT WIN32) - # CMake ignores intrinsic USE dependencies - # CMake has an option Fortran_BUILDING_INSTRINSIC_MODULES/Fortran_BUILDING_INTRINSIC_MODULES - # to disable this behavior, unfortunately it does not work with Ninja - # (https://gitlab.kitware.com/cmake/cmake/-/issues/26803) - # As a workaround, we build those intrinsic modules first such that the main - # runtime can depend on it. - add_flangrt_library(flang_rt.intrinsics.obj OBJECT - ${intrinsics_sources} - ) - - # This barrier exists to force all of the intrinsic modules of - # flang_rt.intrinsics.obj to be built before anything that depends on it. - # Without it, CMake/Ninja seem to think that the modules of - # flang_rt.intrinsics.obj can be built concurrently to those in - # flang_rt.runtime. - add_custom_target(flang_rt.intrinsics - COMMENT "Intrinsic module dependency barrier" - ) - add_dependencies(flang_rt.intrinsics flang_rt.intrinsics.obj) - add_flangrt_library(flang_rt.runtime STATIC SHARED - ${sources} $<TARGET_OBJECTS:flang_rt.intrinsics.obj> - LINK_LIBRARIES flang_rt.intrinsics.obj ${Backtrace_LIBRARY} + ${sources} + LINK_LIBRARIES ${Backtrace_LIBRARY} INSTALL_WITH_TOOLCHAIN ADDITIONAL_HEADERS ${public_headers} ${private_headers} ) @@ -261,13 +198,6 @@ if (NOT WIN32) # Select a default runtime, which is used for unit and regression tests. get_target_property(default_target flang_rt.runtime.default ALIASED_TARGET) add_library(flang_rt.runtime.unittest ALIAS "${default_target}") - - # Select a target that compiles the s... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/169489 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
