Skip to content

[Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a #122341

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

Merged
merged 68 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 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
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
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
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
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
8fae565
forgotten change
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
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
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
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
8ce70e5
Adapt BSD test for rename
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
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
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
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
6b46210
Specifically refer to flang_rt.runtime in comments
Meinersbur Feb 8, 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
6 changes: 3 additions & 3 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,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.runtime
// 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 @@ -1330,14 +1330,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
F128LibName.consume_front_insensitive("lib");
if (!F128LibName.empty()) {
bool AsNeeded = !TC.getTriple().isOSAIX();
CmdArgs.push_back("-lFortranFloat128Math");
CmdArgs.push_back("-lflang_rt.quadmath");
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true);
CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName));
if (AsNeeded)
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
}
CmdArgs.push_back("-lFortranRuntime");
CmdArgs.push_back("-lflang_rt.runtime");
addArchSpecificRPath(TC, Args, CmdArgs);

// needs libexecinfo for backtrace functions
Expand Down
22 changes: 13 additions & 9 deletions clang/lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,15 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
assert(TC.getTriple().isKnownWindowsMSVCEnvironment() &&
"can only add VS runtime library on Windows!");
// if -fno-fortran-main has been passed, skip linking Fortran_main.a
if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
CmdArgs.push_back(Args.MakeArgString(
"--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
}

// Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
// should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt
// functions in some cases like 128-bit integer math (__udivti3, __modti3,
// __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a
// dependency to Compiler-RT's builtin library where these are implemented.
CmdArgs.push_back(Args.MakeArgString(
"--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));

unsigned RTOptionID = options::OPT__SLASH_MT;
if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
RTOptionID = llvm::StringSwitch<unsigned>(rtl->getValue())
Expand All @@ -364,26 +368,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.runtime.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.runtime.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.runtime.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.runtime.dynamic_dbg.lib");
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion flang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ set(FLANG_DEFAULT_LINKER "" CACHE STRING
"Default linker to use (linker name or absolute path, empty for platform default)")

set(FLANG_DEFAULT_RTLIB "" CACHE STRING
"Default Fortran runtime library to use (\"libFortranRuntime\"), leave empty for platform default.")
"Default Fortran runtime library to use (\"libflang_rt.runtime\"), leave empty for platform default.")

if (NOT(FLANG_DEFAULT_RTLIB STREQUAL ""))
message(WARNING "Resetting Flang's default runtime library to use platform default.")
Expand Down
2 changes: 1 addition & 1 deletion flang/cmake/modules/AddFlang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function(add_flang_library name)
set(LIBTYPE SHARED)
elseif(ARG_STATIC)
# If BUILD_SHARED_LIBS and ARG_STATIC are both set, llvm_add_library prioritizes STATIC.
# This is required behavior for libFortranFloat128Math.
# This is required behavior for libflang_rt.quadmath.
set(LIBTYPE STATIC)
else()
# Let llvm_add_library decide, taking BUILD_SHARED_LIBS into account.
Expand Down
6 changes: 3 additions & 3 deletions flang/docs/FlangDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ like this:

```
$ flang -v -o example example.o
"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" [...]
"/usr/bin/ld" [...] example.o [...] "-lflang_rt.runtime" [...]
```

The automatically added libraries are:

* `FortranRuntime`: Provides most of the Flang runtime library.
* `flang_rt.runtime`: Provides most of the Flang runtime library.

If the code is C/C++ based and invokes Fortran routines, one can either use Clang
or Flang as the linker driver. If Clang is used, it will automatically all
required runtime libraries needed by C++ (e.g., for STL) to the linker invocation.
In this case, one has to explicitly provide the Fortran runtime library
`FortranRuntime`. An alternative is to use Flang to link.
`flang_rt.runtime`. An alternative is to use Flang to link.
In this case, it may be required to explicitly supply C++ runtime libraries.

On Darwin, the logical root where the system libraries are located (sysroot)
Expand Down
8 changes: 4 additions & 4 deletions flang/docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ cmake \
-DCMAKE_CUDA_COMPILER=clang \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtime/
make -j FortranRuntime
make -j flang-rt
```

Note that the used version of `clang` must [support](https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#cuda-support)
Expand All @@ -239,7 +239,7 @@ cmake \
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
../runtime/

make -j FortranRuntime
make -j flang-rt
```

Note that `nvcc` might limit support to certain
Expand Down Expand Up @@ -294,7 +294,7 @@ cmake \
-DFLANG_OMP_DEVICE_ARCHITECTURES="all" \
../runtime/

make -j FortranRuntime
make -j flang-rt
```

The result of the build is a "device-only" library, i.e. the host
Expand All @@ -309,7 +309,7 @@ The same set of CMake variables works for Flang in-tree build.
One may provide optional CMake variables to customize the build. Available options:

* `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath`: enables build of
`FortranFloat128Math` library that provides `REAL(16)` math APIs
`flang_rt.quadmath` library that provides `REAL(16)` math APIs
for intrinsics such as `SIN`, `COS`, etc. GCC `libquadmath`'s header file
`quadmath.h` must be available to the build compiler.
[More details](Real16MathSupport.md).
Expand Down
2 changes: 1 addition & 1 deletion flang/docs/OpenACC-descriptor-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ The implementation's behavior may be described as (OpenACC 2.7.2):

All the "is-present" checks and the data actions for the auxiliary pointers must be performed atomically with regards to the present counters bookkeeping.

The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `FortranRuntime` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
The API relies on the primitives provided by `liboffload`, so it is provided by a new F18 runtime library, e.g. `FortranOffloadRuntime`, that depends on `flang_rt.runtime` and `liboffload`. The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).

## TODOs:

Expand Down
4 changes: 2 additions & 2 deletions flang/docs/Real16MathSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies
on third-party libraries providing the implementation.

`-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used
to build `FortranFloat128Math` library that has unresolved references
to build `libflang_rt.quadmath` library that has unresolved references
to GCC `libquadmath` library. A Flang driver built with this option
will automatically link `FortranFloat128Math` and `libquadmath` libraries
will automatically link `libflang_rt.quadmath` and `libquadmath` libraries
to any Fortran program. This implies that `libquadmath` library
has to be available in the standard library paths, so that linker
can find it. The `libquadmath` library installation into Flang project
Expand Down
7 changes: 7 additions & 0 deletions flang/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ page](https://llvm.org/releases/).

## Build System Changes

* The FortranRuntime library has been renamed to `flang_rt.runtime`.

* The FortranFloat128Math library has been renamed to `flang_rt.quadmath`.

* The CufRuntime_cuda_${version} library has been renamed to
`flang_rt.cuda_${version}`.

## New Issues Found


Expand Down
2 changes: 1 addition & 1 deletion flang/examples/ExternalHelloWorld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ add_llvm_example(external-hello-world

target_link_libraries(external-hello-world
PRIVATE
FortranRuntime
flang_rt.runtime
)
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/Builder/IntrinsicCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,8 @@ prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
// Generate a call to the Fortran runtime library providing
// support for 128-bit float math.
// On 'HAS_LDBL128' targets the implementation
// is provided by FortranRuntime, otherwise, it is done via
// FortranFloat128Math library. In the latter case the compiler
// is provided by flang_rt, otherwise, it is done via the
// libflang_rt.quadmath library. In the latter case the compiler
// has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
// proper linking actions in the driver.
static mlir::Value genLibF128Call(fir::FirOpBuilder &builder,
Expand Down
55 changes: 35 additions & 20 deletions flang/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ set(supported_files
utf.cpp
)

enable_cuda_compilation(FortranRuntime "${supported_files}")
enable_cuda_compilation(flang_rt "${supported_files}")
enable_omp_offload_compilation("${supported_files}")

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.
if (NOT TARGET flang_rt.quadmath)
# If flang_rt.quadmath is not defined, then we are not building
# standalone flang_rt.quadmath library. Instead, include
# the relevant sources into flang_rt.runtime itself.
# The information is provided via FortranFloat128MathILib
# interface library.
get_target_property(f128_sources
Expand Down Expand Up @@ -275,51 +275,66 @@ if (NOT TARGET FortranFloat128Math)
endif()

if (NOT DEFINED MSVC)
add_flang_library(FortranRuntime
add_flang_library(flang_rt.runtime
${sources}
LINK_LIBS
${linked_libraries}

INSTALL_WITH_TOOLCHAIN
)
else()
add_flang_library(FortranRuntime
add_flang_library(flang_rt.runtime
${sources}
LINK_LIBS
${linked_libraries}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_flang_library(FortranRuntime.static ${sources}
add_flang_library(flang_rt.runtime.static ${sources}
INSTALL_WITH_TOOLCHAIN)
set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
set_target_properties(flang_rt.runtime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
add_flang_library(FortranRuntime.dynamic ${sources}
add_flang_library(flang_rt.runtime.dynamic ${sources}
INSTALL_WITH_TOOLCHAIN)
set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
set_target_properties(flang_rt.runtime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
add_flang_library(FortranRuntime.static_dbg ${sources}
add_flang_library(flang_rt.runtime.static_dbg ${sources}
INSTALL_WITH_TOOLCHAIN)
set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
set_target_properties(flang_rt.runtime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
add_flang_library(FortranRuntime.dynamic_dbg ${sources}
add_flang_library(flang_rt.runtime.dynamic_dbg ${sources}
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)
set_target_properties(flang_rt.runtime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
add_dependencies(flang_rt.runtime
flang_rt.runtime.static
flang_rt.runtime.dynamic
flang_rt.runtime.static_dbg
flang_rt.runtime.dynamic_dbg)
endif()
set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries")
set_target_properties(flang_rt.runtime PROPERTIES FOLDER "Flang/Runtime Libraries")

# If FortranRuntime is part of a Flang build (and not a separate build) then
# If flang_rt 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' 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 AND TARGET module_files)
add_dependencies(FortranRuntime flang module_files)
add_dependencies(flang_rt.runtime flang module_files)
endif()

if (FLANG_CUF_RUNTIME)
add_subdirectory(CUDA)
endif()

# Compatibility targets.
add_custom_target(flang-rt)
add_dependencies(flang-rt flang_rt.runtime)
if (TARGET flang_rt.quadmath)
add_dependencies(flang-rt flang_rt.quadmath)
endif ()
if (TARGET flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
add_dependencies(flang-rt flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})
endif ()
add_custom_target(FortranRuntime)
add_dependencies(FortranRuntime flang_rt.runtime)
6 changes: 3 additions & 3 deletions flang/runtime/CUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

include_directories(${CUDAToolkit_INCLUDE_DIRS})

# libCufRuntime depends on a certain version of CUDA. To be able to have
# 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 CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR})
set(CUFRT_LIBNAME flang_rt.cuda_${CUDAToolkit_VERSION_MAJOR})

add_flang_library(${CUFRT_LIBNAME}
allocator.cpp
Expand All @@ -33,6 +33,6 @@ endif()

target_link_libraries(${CUFRT_LIBNAME}
PRIVATE
FortranRuntime
flang_rt.runtime
${CUDA_RT_TARGET}
)
14 changes: 7 additions & 7 deletions flang/runtime/Float128Math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# 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 FortranFloat128Math library.
# used for building this flang_rt.quadmath library.

include(CheckLibraryExists)

Expand Down Expand Up @@ -93,20 +93,20 @@ if (FLANG_RUNTIME_F128_MATH_LIB)
)
endif()

add_flang_library(FortranFloat128Math STATIC INSTALL_WITH_TOOLCHAIN
add_flang_library(flang_rt.quadmath STATIC INSTALL_WITH_TOOLCHAIN
${sources})

if (DEFINED MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_flang_library(FortranFloat128Math.static STATIC INSTALL_WITH_TOOLCHAIN
add_flang_library(flang_rt.quadmath.static STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
add_flang_library(FortranFloat128Math.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
add_flang_library(flang_rt.quadmath.static_dbg STATIC INSTALL_WITH_TOOLCHAIN
${sources}
)
add_dependencies(FortranFloat128Math FortranFloat128Math.static
FortranFloat128Math.static_dbg
add_dependencies(flang_rt.quadmath flang_rt.quadmath.static
flang_rt.quadmath.static_dbg
)
endif()
elseif (HAVE_LDBL_MANT_DIG_113)
Expand All @@ -118,7 +118,7 @@ elseif (HAVE_LDBL_MANT_DIG_113)
)
target_sources(FortranFloat128MathILib INTERFACE ${sources})
else()
message(FATAL_ERROR "FortranRuntime cannot build without libm")
message(FATAL_ERROR "flang_rt.quadmath cannot build without libm")
endif()
else()
# We can use '__float128' version from libc, if it has them.
Expand Down
2 changes: 1 addition & 1 deletion flang/runtime/time-intrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ template <typename Unused = void> double GetCpuTime(fallback_implementation) {

#if defined __MINGW32__
// clock_gettime is implemented in the pthread library for MinGW.
// Using it here would mean that all programs that link libFortranRuntime are
// Using it here would mean that all programs that link libflang_rt are
// required to also link to pthread. Instead, don't use the function.
#undef CLOCKID_CPU_TIME
#undef CLOCKID_ELAPSED_TIME
Expand Down
2 changes: 1 addition & 1 deletion flang/runtime/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ inline RT_API_ATTRS RESULT ApplyFloatingPointKind(
if constexpr (HasCppTypeFor<TypeCategory::Real, 16>) {
// If FUNC implemenation relies on FP math functions,
// then we should not be here. The compiler should have
// generated a call to an entry in FortranFloat128Math
// generated a call to an entry in flang_rt.quadmath
// library.
if constexpr (!NEEDSMATH) {
return FUNC<16>{}(std::forward<A>(x)...);
Expand Down
Loading