Skip to content
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] LLVM_ENABLE_RUNTIMES=flang-rt #110217

Merged
merged 136 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
72e3c5d
[Flang] Introduce FortranSupport
Meinersbur Jan 24, 2025
71015c8
[Flang] Promote FortranEvaluateTesting library
Meinersbur Jan 24, 2025
2e50a1f
[Flang] Don't use FortranDecimal for runtime
Meinersbur Jan 24, 2025
4c676f4
users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME
Meinersbur Jan 24, 2025
875607f
[Flang] Rename libFortranRuntime.a to libflang_rt.a
Meinersbur Jan 24, 2025
7e369b5
[Flang][NFC] Move runtime library files to flang-rt
Meinersbur Jan 24, 2025
f670816
[Flang] LLVM_ENABLE_RUNTIMES=flang-rt
Meinersbur Jan 24, 2025
24fb760
Sort files alphabetically
Meinersbur Jan 27, 2025
0810293
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Jan 27, 2025
a7cd5b2
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Jan 27, 2025
962958a
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Jan 27, 2025
70326fe
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Jan 27, 2025
a2a68ba
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Jan 27, 2025
c5e6acc
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Jan 27, 2025
f2e1535
Move new file pointer.cpp
Meinersbur Jan 27, 2025
4643eaf
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Jan 27, 2025
b02e9ad
Suggest both options to build Flang-RT
Meinersbur Jan 28, 2025
b9ab00d
Move files back to Common
Meinersbur Jan 29, 2025
f3e9c15
add missing includes
Meinersbur Jan 29, 2025
8349624
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Jan 29, 2025
e5f2532
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Jan 29, 2025
9e8a785
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Jan 29, 2025
c3924da
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Jan 29, 2025
b9bbae9
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Jan 29, 2025
e4286e5
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Jan 29, 2025
6a7bd03
Use C++style comments for header guards
Meinersbur Jan 29, 2025
db749b9
Use C++style comments for header guards II
Meinersbur Jan 29, 2025
d3c1b9a
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Jan 30, 2025
d9023dd
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Jan 30, 2025
eda88d9
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Jan 30, 2025
aa1770b
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Jan 30, 2025
1b988f0
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Jan 30, 2025
8d6bdf0
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Jan 30, 2025
4b93839
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Jan 30, 2025
b41db96
Post-merge fixes
Meinersbur Jan 30, 2025
3ce4b52
Post-merge fixes
Meinersbur Jan 30, 2025
9fce9ef
Post-merge fixes
Meinersbur Jan 30, 2025
c172e09
Merge branch 'users/meinersbur/flang_runtime_move-files' into HEAD
Meinersbur Jan 30, 2025
c86aa90
Rename to flang_rt.runtime, flang_rt.quadmath, flang_rt.cuda
Meinersbur Feb 3, 2025
f4729e6
Conditionalize runtime example
Meinersbur Feb 3, 2025
6bb9de2
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 3, 2025
4303d5a
Rename to libflang_rt.<component>.(a|so)
Meinersbur Feb 3, 2025
f97c774
build fixes
Meinersbur Feb 3, 2025
d2f17f8
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 3, 2025
8fae565
forgotten change
Meinersbur Feb 3, 2025
8e8b338
Rename to flang_rt.runtime, flang_rt.quadmath, flang_rt.cuda
Meinersbur Feb 3, 2025
0282bd6
Avoid change noise
Meinersbur Feb 3, 2025
be9a0a2
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 3, 2025
7dc5f20
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Feb 4, 2025
88ecb82
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 4, 2025
993564a
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 4, 2025
7875cff
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 4, 2025
4498646
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 4, 2025
3477620
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 4, 2025
fb125e0
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 4, 2025
d0cf509
Post-merge fixes
Meinersbur Feb 4, 2025
0a4dfcc
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Feb 4, 2025
0a9c5fd
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 4, 2025
d509bef
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 4, 2025
8e3ddbf
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 4, 2025
b2a6556
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 4, 2025
901be28
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 4, 2025
d175cac
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 4, 2025
7158e15
Merge remote-tracking branch 'official/main' into users/meinersbur/fl…
Meinersbur Feb 5, 2025
b286a88
clang-format includes
Meinersbur Feb 6, 2025
40b2f71
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 6, 2025
080f30c
Merge commit 'b815a3942a0b0a9e7aab6b269ffdb0e93abc4368' into users/me…
Meinersbur Feb 6, 2025
919919f
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 6, 2025
8096d45
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 6, 2025
d35bea0
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 6, 2025
a446bad
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 6, 2025
8ef26b6
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 6, 2025
77d821c
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 6, 2025
778f516
Adapt BSD test
Meinersbur Feb 6, 2025
4c9e378
Merge branch 'main' into users/meinersbur/flang_runtime_FortranSupport
Meinersbur Feb 6, 2025
08a7bbc
Merge branch 'users/meinersbur/flang_runtime_FortranSupport' into use…
Meinersbur Feb 6, 2025
3f99cd5
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 6, 2025
1fbd2c5
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 6, 2025
b45a08d
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 6, 2025
1bff4ab
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 6, 2025
4c21fb9
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 6, 2025
8ce70e5
Adapt BSD test for rename
Meinersbur Feb 6, 2025
fb7bc11
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 6, 2025
45795cd
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 6, 2025
f258e0e
Use C++ header guards III
Meinersbur Feb 6, 2025
d222eee
Merge commit '02fa340711d9b990b50a0daf65eb850404884137' into users/me…
Meinersbur Feb 6, 2025
06a81de
Merge branch 'users/meinersbur/flang_runtime_Testing' into users/mein…
Meinersbur Feb 6, 2025
0edd103
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 6, 2025
f9a1569
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 6, 2025
6708dc3
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 6, 2025
66292f0
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 6, 2025
2f30a9a
Merge commit '8fb1b3f4b23ecc2fc39f1a1c07244304565cfb21' into users/me…
Meinersbur Feb 7, 2025
ed4c3a6
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 7, 2025
3a996b3
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 7, 2025
7eef009
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 7, 2025
07fda1e
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 7, 2025
9262520
Merge commit '98e118ca435d280ff1c3540eb5e9b4140b44a1b4' into users/me…
Meinersbur Feb 7, 2025
d4909ad
Merge branch 'users/meinersbur/flang_runtime_FortranDecimal' into use…
Meinersbur Feb 7, 2025
51f424e
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 7, 2025
ddb8425
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 7, 2025
faf5ddc
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 7, 2025
e3098d3
[Flang] Optionally do not compile the runtime in-tree
Meinersbur Feb 7, 2025
2b8e70b
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 7, 2025
4205ce8
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 7, 2025
08f5e1f
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 7, 2025
8b7be99
Merge branch 'main' (early part) into users/meinersbur/flang_runtime_…
Meinersbur Feb 8, 2025
9c5e121
Merge branch 'main' into users/meinersbur/flang_runtime_FLANG_INCLUDE…
Meinersbur Feb 8, 2025
6f2d9c9
Merge branch 'users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME' i…
Meinersbur Feb 8, 2025
d512ee0
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 8, 2025
aae7258
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 8, 2025
6b46210
Specifically refer to flang_rt.runtime in comments
Meinersbur Feb 8, 2025
17d7e90
Merge commit '5c8c2b3db54395073e3183f89167156df29dff61' into users/me…
Meinersbur Feb 8, 2025
abe3d27
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 8, 2025
ab5e2b9
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 8, 2025
c7e786e
Merge branch 'main' (early part) into users/meinersbur/flang_runtime_…
Meinersbur Feb 8, 2025
61ae434
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 8, 2025
bbede04
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 8, 2025
d3cc786
Merge commit '5c8c2b3db54395073e3183f89167156df29dff61' into users/me…
Meinersbur Feb 8, 2025
74e7836
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/mei…
Meinersbur Feb 8, 2025
6391795
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 8, 2025
19fe1a3
Disable LTO
Meinersbur Feb 10, 2025
8b91f2f
Undo move of CUDA/allocator.h
Meinersbur Feb 10, 2025
c7f8098
Apply darker formatting
Meinersbur Feb 11, 2025
aa2a779
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 11, 2025
9a88083
Merge commit 'c6654806949f0498fdd2d009b66e62041c21de36' into users/me…
Meinersbur Feb 13, 2025
8bdea32
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 13, 2025
276020f
Fix setting option default
Meinersbur Feb 13, 2025
1796827
Undo llvm-test-suite workaround
Meinersbur Feb 13, 2025
b12d925
Merge commit '660cdace559a8dbe44ebf2222b854bf3f39a5f62' into users/me…
Meinersbur Feb 13, 2025
ff761f6
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 13, 2025
1ee1300
Post-merge fixes
Meinersbur Feb 13, 2025
c7d6b01
Re-apply llvm-test-suite workaround
Meinersbur Feb 13, 2025
2f21466
Post-merge fixes
Meinersbur Feb 13, 2025
c9a7900
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 14, 2025
c2c7bb2
Merge branch 'main' into users/meinersbur/flang_runtime_move-files
Meinersbur Feb 16, 2025
6fa8982
Merge branch 'users/meinersbur/flang_runtime_move-files' into users/m…
Meinersbur Feb 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flang-rt/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Checks: '-llvm-include-order,readability-braces-around-statements,-readability-identifier-naming,-clang-diagnostic-*'
InheritParentConfig: true
261 changes: 261 additions & 0 deletions flang-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
#===-- 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
#
#===------------------------------------------------------------------------===#
#
# Build instructions for the flang-rt library. This is file is intended to be
# included using the LLVM_ENABLE_RUNTIMES mechanism.
#
#===------------------------------------------------------------------------===#

if (NOT LLVM_RUNTIMES_BUILD)
message(FATAL_ERROR "Use this CMakeLists.txt from LLVM's runtimes build system.
Example:
cmake <llvm-project>/runtimes -DLLVM_ENABLE_RUNTIMES=flang-rt
")
endif ()

set(LLVM_SUBPROJECT_TITLE "Flang-RT")
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"
"${FLANG_SOURCE_DIR}/cmake/modules"
)
include(AddFlangRT)
include(GetToolchainDirs)
include(FlangCommon)
include(HandleCompilerRT)
include(ExtendPath)


############################
# 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")

# 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)

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 "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 ()
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)
cmake_path(NORMAL_PATH FLANG_RT_OUTPUT_RESOURCE_LIB_DIR)
cmake_path(NORMAL_PATH FLANG_RT_INSTALL_RESOURCE_LIB_PATH)


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

# 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)
# Support for GPUs disabled
elseif (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA")
# Support for 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")
# Support for OpenMP offloading
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')"
)

if (FLANG_RT_DEVICE_ARCHITECTURES STREQUAL "all")
# TODO: support auto detection on the build system.
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}")
set(FLANG_RT_DEVICE_ARCHITECTURES ${all_gpu_architectures})
endif()
list(REMOVE_DUPLICATES FLANG_RT_DEVICE_ARCHITECTURES)
else ()
message(FATAL_ERROR "Invalid value '${FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT}' for FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT; must be empty, 'CUDA', or 'OpenMP'")
endif ()


option(FLANG_RT_INCLUDE_CUF "Build the CUDA Fortran runtime (libflang_rt.cuda.a)" OFF)
if (FLANG_RT_INCLUDE_CUF)
find_package(CUDAToolkit REQUIRED)
endif()


########################
# System Introspection #
########################

include(CheckCXXSymbolExists)
include(CheckCXXSourceCompiles)
check_cxx_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
# Can't use symbol exists here as the function is overloaded in C++
check_cxx_source_compiles(
"#include <string.h>
int main() {
char buf[4096];
return strerror_s(buf, 4096, 0);
}
"
HAVE_DECL_STRERROR_S)


# Search for clang_rt.builtins library. Need in addition to msvcrt.
if (WIN32)
find_compiler_rt_library(builtins FLANG_RT_BUILTINS_LIBRARY)
endif ()


# Check whether the compiler can undefine a macro using the "-U" flag.
# Aternatively, we could use
# CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU"
# but some older versions of CMake don't define it for GCC itself.
check_cxx_compiler_flag("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG)

# Check whether -fno-lto is supported.
check_cxx_compiler_flag(-fno-lto FLANG_RT_HAS_FNO_LTO_FLAG)


# function checks
find_package(Backtrace)
set(HAVE_BACKTRACE ${Backtrace_FOUND})
set(BACKTRACE_HEADER ${Backtrace_HEADER})


#####################
# Build Preparation #
#####################

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 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 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)


configure_file(cmake/config.h.cmake.in config.h)


# The bootstrap build will create a phony target with the same as the top-level
# directory ("flang-rt") and delegate it to the runtimes build dir.
# AddFlangRT will add all non-EXCLUDE_FROM_ALL targets to it.
add_custom_target(flang-rt)


###################
# Build Artifacts #
###################

add_subdirectory(lib)

if (LLVM_INCLUDE_EXAMPLES)
add_subdirectory(examples)
endif ()

if (FLANG_RT_INCLUDE_TESTS)
add_subdirectory(unittests)
add_subdirectory(test)
else ()
add_custom_target(check-flang-rt)
endif()
14 changes: 14 additions & 0 deletions flang-rt/CODE_OWNERS.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This file is a list of the people responsible for ensuring that patches for a
particular part of Flang are reviewed, either by themself or by someone else.
They are also the gatekeepers for their part of Flang, with the final word on
what goes in or not.

The list is sorted by surname and formatted to allow easy grepping and
beautification by scripts. The fields are: name (N), email (E), web-address
(W), PGP key ID and fingerprint (P), description (D), snail-mail address
(S) and (I) IRC handle. Each entry should contain at least the (N), (E) and
(D) fields.

N: Steve Scalpone
E: [email protected]
D: Anything not covered by others
Loading
Loading