Skip to content

Commit

Permalink
FortranRuntime -> flang-rt
Browse files Browse the repository at this point in the history
  • Loading branch information
Meinersbur committed Oct 16, 2024
1 parent 011568a commit 83910a4
Show file tree
Hide file tree
Showing 255 changed files with 815 additions and 838 deletions.
13 changes: 0 additions & 13 deletions FortranRuntime/test/NonGtestUnit/lit.site.cfg.py.in

This file was deleted.

14 changes: 0 additions & 14 deletions FortranRuntime/test/Unit/lit.site.cfg.py.in

This file was deleted.

18 changes: 0 additions & 18 deletions FortranRuntime/test/lit.site.cfg.py.in

This file was deleted.

4 changes: 2 additions & 2 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
/// Add Fortran runtime libs
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) {
// Link FortranRuntime
// Link flang_rt
// These are handled earlier on Windows by telling the frontend driver to
// add the correct libraries to link against as dependents in the object
// file.
Expand All @@ -1307,7 +1307,7 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
}
CmdArgs.push_back("-lFortranRuntime");
CmdArgs.push_back("-lflang_rt");
}
}

Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,26 +304,26 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
case options::OPT__SLASH_MT:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("--dependent-lib=libcmt");
CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib");
CmdArgs.push_back("--dependent-lib=flang_rt.static.lib");
break;
case options::OPT__SLASH_MTd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("--dependent-lib=libcmtd");
CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib");
CmdArgs.push_back("--dependent-lib=flang_rt.static_dbg.lib");
break;
case options::OPT__SLASH_MD:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrt");
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib");
CmdArgs.push_back("--dependent-lib=flang_rt.dynamic.lib");
break;
case options::OPT__SLASH_MDd:
CmdArgs.push_back("-D_MT");
CmdArgs.push_back("-D_DEBUG");
CmdArgs.push_back("-D_DLL");
CmdArgs.push_back("--dependent-lib=msvcrtd");
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib");
CmdArgs.push_back("--dependent-lib=flang_rt.dynamic_dbg.lib");
break;
}
}
Expand Down
File renamed without changes.
File renamed without changes.
82 changes: 43 additions & 39 deletions FortranRuntime/CMakeLists.txt → flang-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
#
#===------------------------------------------------------------------------===#
#
# Build instructions for the FortranRuntime library and Fortran modules required
# by programs compiled by Flang. This is file is intended to be included using
# the LLVM_ENABLE_RUNTIMES mechanism.
# Build instructions for the flang-rt library. This is file is intended to be
# included using the LLVM_ENABLE_RUNTIMES mechanism.
#
#===------------------------------------------------------------------------===#

set(LLVM_SUBPROJECT_TITLE "Fortran Runtime")
set(FORTRANRUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(FORTRANRUNTIME_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(FLANGRT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(FLANGRT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang")

enable_language(Fortran)

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
"${FLANGRT_SOURCE_DIR}/cmake/modules"
"${FLANG_SOURCE_DIR}/cmake/modules"
)
include(AddFortranRuntime)
include(AddFlangRT)
include(FlangCommon)


############################
# Build Mode Introspection #
############################

# Setting these variables from an LLVM build is sufficient that FortranRuntime can
# Setting these variables from an LLVM build is sufficient that flang-rt can
# construct the output paths, so it can behave as if it were in-tree here.
set(LLVM_TREE_AVAILABLE OFF)
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
Expand All @@ -42,46 +42,50 @@ if (LLVM_TREE_AVAILABLE)
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang being added to the build
# flang-new uses the same resource dir as clang.
include(GetClangResourceDir)
get_clang_resource_dir(FORTRANRUNTIME_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
get_clang_resource_dir(FORTRANRUNTIME_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
get_clang_resource_dir(FLANGRT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
get_clang_resource_dir(FLANGRT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command find the install prefix itself
else ()
set(FORTRANRUNTIME_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
set(FORTRANRUNTIME_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
set(FLANGRT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
set(FLANGRT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
endif ()

if (DEFINED WIN32)
set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/windows")
set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/windows")
set(FLANGRT_BUILD_LIB_DIR "${FLANGRT_BUILD_LIB_DIR}/windows")
set(FLANGRT_INSTALL_LIB_DIR "${FLANGRT_INSTALL_LIB_DIR}/windows")
elseif (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
set(FORTRANRUNTIME_BUILD_LIB_DIR "${FORTRANRUNTIME_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
set(FORTRANRUNTIME_INSTALL_LIB_DIR "${FORTRANRUNTIME_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
set(FLANGRT_BUILD_LIB_DIR "${FLANGRT_BUILD_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
set(FLANGRT_INSTALL_LIB_DIR "${FLANGRT_INSTALL_LIB_DIR}/${LLVM_TARGET_TRIPLE}")
endif ()


#################
# Build Options #
#################

option(FORTRANRUNTIME_INCLUDE_TESTS "Generate build targets for the FortranRuntime unit and regression-tests." "${LLVM_INCLUDE_TESTS}")

set(FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile FortranRuntime with GPU support (CUDA or OpenMP)")
set_property(CACHE FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS
""
CUDA
OpenMP)
if (NOT FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT)
elseif (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
set(FORTRANRUNTIME_LIBCUDACXX_PATH "" CACHE PATH "Path to libcu++ package installation")
option(FORTRANRUNTIME_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS "Do not compile global variables' definitions when producing PTX library" OFF)
elseif (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
set(FORTRANRUNTIME_DEVICE_ARCHITECTURES "all" CACHE STRING
# Important: flang-rt user options must be prefixed with "FLANG_RT_". Variables
# with this prefix will be forwarded in bootstrap builds.

option(FLANG_RT_INCLUDE_TESTS "Generate build targets for the flang-rt unit and regression-tests." "${LLVM_INCLUDE_TESTS}")

set(FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT "" CACHE STRING "Compile flang-rt with GPU support (CUDA or OpenMP)")
set_property(CACHE FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT PROPERTY STRINGS
""
CUDA
OpenMP
)
if (NOT FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT)
elseif (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
set(FLANG_RT_LIBCUDACXX_PATH "" CACHE PATH "Path to libcu++ package installation")
option(FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS "Do not compile global variables' definitions when producing PTX library" OFF)
elseif (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "OpenMP")
set(FLANG_RT_DEVICE_ARCHITECTURES "all" CACHE STRING
"List of OpenMP device architectures to be used to compile the Fortran runtime (e.g. 'gfx1103;sm_90')")
else ()
message(FATAL_ERROR "Invalid value '${FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
message(FATAL_ERROR "Invalid value '${FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
endif ()

option(FORTRANRUNTIME_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
if (FORTRANRUNTIME_ENABLE_CUF)
option(FLANG_RT_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
if (FLANG_RT_ENABLE_CUF)
find_package(CUDAToolkit REQUIRED)
endif()

Expand Down Expand Up @@ -113,9 +117,9 @@ if (WIN32)
ERROR_QUIET
)
if (NOT CXX_COMPILER_PRINT_LIBGCC_PATH_FAILURE AND CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT)
string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FORTRANRUNTIME_LIBCALL)
string(STRIP "${CXX_COMPILER_PRINT_LIBGCC_PATH_RESULT}" FLANGRT_LIBCALL)
else ()
set(FORTRANRUNTIME_LIBCALL "")
set(FLANGRT_LIBCALL "")
endif ()
endif ()

Expand All @@ -124,17 +128,17 @@ endif ()
# Build Preparation #
#####################

if (FORTRANRUNTIME_EXPERIMENTAL_OFFLOAD_SUPPORT AND FORTRANRUNTIME_INCLUDE_TESTS)
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT AND FLANG_RT_INCLUDE_TESTS)
# If Fortran runtime is built as CUDA library, the linking
# of targets that link FortranRuntime must be done
# of targets that link flang-rt must be done
# with CUDA_RESOLVE_DEVICE_SYMBOLS.
# CUDA language must be enabled for CUDA_RESOLVE_DEVICE_SYMBOLS
# to take effect.
enable_language(CUDA)
endif()


# C++17 required for FortranRuntime, user or other runtimes may override this.
# C++17 is required for flang-rt; user or other runtimes may override this.
# GTest included later also requires C++17.
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
Expand All @@ -153,9 +157,9 @@ configure_file(cmake/config.h.cmake.in config.h)

add_subdirectory(lib)

if (FORTRANRUNTIME_INCLUDE_TESTS)
if (FLANG_RT_INCLUDE_TESTS)
add_subdirectory(unittests)
add_subdirectory(test)
else ()
add_custom_target(check-FortranRuntime)
add_custom_target(check-flang-rt)
endif()
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 83910a4

Please sign in to comment.