================ @@ -155,162 +50,131 @@ set(sources product.cpp pseudo-unit.cpp ragged.cpp - random.cpp - reduce.cpp - reduction.cpp stat.cpp - stop.cpp sum.cpp support.cpp - temporary-stack.cpp terminator.cpp - time-intrinsic.cpp tools.cpp transformational.cpp type-code.cpp type-info.cpp - unit-map.cpp unit.cpp + unit-map.cpp utf.cpp - ${FORTRAN_MODULE_OBJECTS} ) -include(AddFlangOffloadRuntime) +# List of source not used for GPU offloading. +set(host_sources + ${FLANG_SOURCE_DIR}/lib/Common/binary-to-decimal.cpp + ${FLANG_SOURCE_DIR}/lib/Common/decimal-to-binary.cpp + command.cpp + complex-powi.cpp + complex-reduction.c + exceptions.cpp + execute.cpp + extensions.cpp + ${FLANG_SOURCE_DIR}/module/iso_fortran_env_impl.f90 + main.cpp + random.cpp + reduce.cpp + reduction.cpp + stop.cpp + temporary-stack.cpp + time-intrinsic.cpp +) -# List of files that are buildable for all devices. -set(supported_files - ISO_Fortran_binding.cpp - allocatable.cpp - allocator-registry.cpp - array-constructor.cpp - assign.cpp - buffer.cpp - character.cpp - connection.cpp - copy.cpp - derived-api.cpp - derived.cpp - descriptor.cpp - descriptor-io.cpp - dot-product.cpp - edit-input.cpp - edit-output.cpp - environment.cpp - extrema.cpp - external-unit.cpp - file.cpp - findloc.cpp - format.cpp - inquiry.cpp - internal-unit.cpp - io-api.cpp - io-api-minimal.cpp - io-error.cpp - io-stmt.cpp - iostat.cpp - matmul-transpose.cpp - matmul.cpp - memory.cpp - misc-intrinsic.cpp - namelist.cpp - non-tbp-dio.cpp - numeric.cpp - pointer.cpp - product.cpp - pseudo-unit.cpp - ragged.cpp - stat.cpp - sum.cpp - support.cpp - terminator.cpp - tools.cpp - transformational.cpp - type-code.cpp - type-info.cpp - unit.cpp - utf.cpp +file(GLOB_RECURSE public_headers + "${FLANG_RT_SOURCE_DIR}/include/flang/Runtime/*.h" + "${FLANG_RT_SOURCE_DIR}/include/flang/Common/*.h" ) -enable_cuda_compilation(FortranRuntime "${supported_files}") -enable_omp_offload_compilation("${supported_files}") +file(GLOB_RECURSE private_headers + "${FLANG_RT_SOURCE_DIR}/lib/Runtime/*.h" + "${FLANG_RT_SOURCE_DIR}/lib/Common/*.h" + ) -if (NOT TARGET FortranFloat128Math) - # If FortranFloat128Math is not defined, then we are not building - # standalone FortranFloat128Math library. Instead, include - # the relevant sources into FortranRuntime itself. - # The information is provided via FortranFloat128MathILib - # interface library. - get_target_property(f128_sources - FortranFloat128MathILib INTERFACE_SOURCES + +# Import changes from sibling FortranFloat128Math +get_target_property(f128_sources + FortranFloat128MathILib INTERFACE_SOURCES + ) +if (f128_sources) + # The interface may define special macros for Float128Math files, + # so we need to propagate them. + get_target_property(f128_defs + FortranFloat128MathILib INTERFACE_COMPILE_DEFINITIONS ) - if (f128_sources) - # The interface may define special macros for Float128Math files, - # so we need to propagate them. - get_target_property(f128_defs - FortranFloat128MathILib INTERFACE_COMPILE_DEFINITIONS - ) - set_property(SOURCE ${f128_sources} - APPEND PROPERTY COMPILE_DEFINITIONS - ${f128_defs} - ) - list(APPEND sources ${f128_sources}) - endif() -endif() + set_property(SOURCE ${f128_sources} + APPEND PROPERTY COMPILE_DEFINITIONS + ${f128_defs} + ) +else () + set(f128_sources "") +endif () -if (NOT DEFINED MSVC) - add_flang_library(FortranRuntime - ${sources} - LINK_LIBS - FortranDecimal +set(sources ${supported_sources} ${host_sources} ${f128_sources}) + +if (NOT WIN32) + add_flangrt_library(flang_rt STATIC + ${sources} INSTALL_WITH_TOOLCHAIN + ADDITIONAL_HEADERS ${public_headers} ${private_headers} ) + + enable_cuda_compilation(flang_rt "${supported_sources}") + enable_omp_offload_compilation(flang_rt "${supported_sources}") + + # For unittests that depend on flang_rt. Should link to the static version + # of the library. + add_library(flang_rt.static ALIAS flang_rt) + add_library(flang_rt.unittest ALIAS flang_rt) else() - add_flang_library(FortranRuntime - ${sources} - LINK_LIBS - FortranDecimal - ) - set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded) - add_flang_library(FortranRuntime.static ${sources} - LINK_LIBS - FortranDecimal.static - INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries") - set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) - add_flang_library(FortranRuntime.dynamic ${sources} - LINK_LIBS - FortranDecimal.dynamic - INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries") - set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug) - add_flang_library(FortranRuntime.static_dbg ${sources} - LINK_LIBS - FortranDecimal.static_dbg - INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries") - set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL) - add_flang_library(FortranRuntime.dynamic_dbg ${sources} - LINK_LIBS - FortranDecimal.dynamic_dbg - INSTALL_WITH_TOOLCHAIN) - set_target_properties(FortranRuntime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries") - add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic - FortranRuntime.static_dbg FortranRuntime.dynamic_dbg) -endif() -set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries") + # Target for building all versions of the runtime + add_custom_target(flang_rt) + set_target_properties(flang_rt PROPERTIES FOLDER "Fortran Runtime/Meta") + + function (add_win_flangrt_library libtype suffix msvc_lib) + set(name "flang_rt.${suffix}") + add_flangrt_library(${name} ${libtype} + ${sources} + ${ARGN} + INSTALL_WITH_TOOLCHAIN + ADDITIONAL_HEADERS ${public_headers} ${private_headers} + ) -# If FortranRuntime is part of a Flang build (and not a separate build) then -# add dependency to make sure that Fortran runtime library is being built after -# we have the Flang compiler available. This also includes the MODULE files -# that compile when the 'flang-new' target is built. -# -# TODO: This is a workaround and should be updated when runtime build procedure -# is changed to a regular runtime build. See discussion in PR #95388. -if (TARGET flang-new AND TARGET module_files) - add_dependencies(FortranRuntime flang-new module_files) -endif() + # Setting an unique Fortran_MODULE_DIRECTORY is required for each variant to + # write a different .mod file. + set_target_properties(${name} + PROPERTIES + MSVC_RUNTIME_LIBRARY ${msvc_lib} + Fortran_MODULE_DIRECTORY "module.${suffix}" + ) -if (FLANG_CUF_RUNTIME) - add_subdirectory(../CufRuntime CUDA) + enable_cuda_compilation(${name} "${supported_sources}") + enable_omp_offload_compilation(${name} "${supported_sources}") + add_dependencies(flang_rt ${name}) + endfunction () + + add_win_flangrt_library(STATIC static MultiThreaded) + add_win_flangrt_library(STATIC static_dbg MultiThreadedDebug) + + # unittests link against LLVMSupport which is compiled with /MD + add_win_flangrt_library(STATIC unittest MultiThreadedDLL EXCLUDE_FROM_ALL) + + # FIXME: Generating runtime DLLs is currently not possible. There are two + # roadblocks: + # + # * Flang emits /DEFAULTLIB:flang_rt.dynamic.lib into + # iso_fortran_env_impl.f90.obj. Since that file is itself part of + # flang_rt.dynamic, this results in a recursive dependency when invoking + # the linker. + # + # * The externally-visible functions must either by annotated with + # __declspec(dllexport), or listed in a exports file. A possible workaround + # is CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS which would also export the internal + # C++ symbols. + # + #add_win_flangrt_library(SHARED dynamic MultiThreadedDLL) + #add_win_flangrt_library(SHARED dynamic_dbg MultiThreadedDebugDLL) ---------------- Meinersbur wrote:
Thanks. Adding that info to the comment. https://github.com/llvm/llvm-project/pull/110217 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits