Skip to content

Commit 5c8c2b3

Browse files
authored
[Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a (llvm#122341)
Following the conclusion of the [RFC](https://discourse.llvm.org/t/rfc-names-for-flang-rt-libraries/84321), rename Flang's runtime libraries as follows: * libFortranRuntime.(a|so) to libflang_rt.runtime.(a|so) * libFortranFloat128Math.a to libflang_rt.quadmath.a * libCufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}.(a|so) to libflang_rt.cuda_${CUDAToolkit_VERSION_MAJOR}.(a|so) This follows the same naming scheme as Compiler-RT libraries (`libclang_rt.${component}.(a|so)`). It provides some consistency between Flang's runtime libraries for current and potential future library components.
1 parent 40ce8fd commit 5c8c2b3

29 files changed

+128
-96
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
13211321
/// Add Fortran runtime libs
13221322
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
13231323
llvm::opt::ArgStringList &CmdArgs) {
1324-
// Link FortranRuntime
1324+
// Link flang_rt.runtime
13251325
// These are handled earlier on Windows by telling the frontend driver to
13261326
// add the correct libraries to link against as dependents in the object
13271327
// file.
@@ -1330,14 +1330,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
13301330
F128LibName.consume_front_insensitive("lib");
13311331
if (!F128LibName.empty()) {
13321332
bool AsNeeded = !TC.getTriple().isOSAIX();
1333-
CmdArgs.push_back("-lFortranFloat128Math");
1333+
CmdArgs.push_back("-lflang_rt.quadmath");
13341334
if (AsNeeded)
13351335
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true);
13361336
CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName));
13371337
if (AsNeeded)
13381338
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
13391339
}
1340-
CmdArgs.push_back("-lFortranRuntime");
1340+
CmdArgs.push_back("-lflang_rt.runtime");
13411341
addArchSpecificRPath(TC, Args, CmdArgs);
13421342

13431343
// needs libexecinfo for backtrace functions

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,15 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
346346
ArgStringList &CmdArgs) {
347347
assert(TC.getTriple().isKnownWindowsMSVCEnvironment() &&
348348
"can only add VS runtime library on Windows!");
349-
// if -fno-fortran-main has been passed, skip linking Fortran_main.a
350-
if (TC.getTriple().isKnownWindowsMSVCEnvironment()) {
351-
CmdArgs.push_back(Args.MakeArgString(
352-
"--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
353-
}
349+
350+
// Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
351+
// should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt
352+
// functions in some cases like 128-bit integer math (__udivti3, __modti3,
353+
// __fixsfti, __floattidf, ...) that msvc does not support. We are injecting a
354+
// dependency to Compiler-RT's builtin library where these are implemented.
355+
CmdArgs.push_back(Args.MakeArgString(
356+
"--dependent-lib=" + TC.getCompilerRTBasename(Args, "builtins")));
357+
354358
unsigned RTOptionID = options::OPT__SLASH_MT;
355359
if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
356360
RTOptionID = llvm::StringSwitch<unsigned>(rtl->getValue())
@@ -364,26 +368,26 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
364368
case options::OPT__SLASH_MT:
365369
CmdArgs.push_back("-D_MT");
366370
CmdArgs.push_back("--dependent-lib=libcmt");
367-
CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib");
371+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static.lib");
368372
break;
369373
case options::OPT__SLASH_MTd:
370374
CmdArgs.push_back("-D_MT");
371375
CmdArgs.push_back("-D_DEBUG");
372376
CmdArgs.push_back("--dependent-lib=libcmtd");
373-
CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib");
377+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static_dbg.lib");
374378
break;
375379
case options::OPT__SLASH_MD:
376380
CmdArgs.push_back("-D_MT");
377381
CmdArgs.push_back("-D_DLL");
378382
CmdArgs.push_back("--dependent-lib=msvcrt");
379-
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib");
383+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic.lib");
380384
break;
381385
case options::OPT__SLASH_MDd:
382386
CmdArgs.push_back("-D_MT");
383387
CmdArgs.push_back("-D_DEBUG");
384388
CmdArgs.push_back("-D_DLL");
385389
CmdArgs.push_back("--dependent-lib=msvcrtd");
386-
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib");
390+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic_dbg.lib");
387391
break;
388392
}
389393
}

flang/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ set(FLANG_DEFAULT_LINKER "" CACHE STRING
301301
"Default linker to use (linker name or absolute path, empty for platform default)")
302302

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

306306
if (NOT(FLANG_DEFAULT_RTLIB STREQUAL ""))
307307
message(WARNING "Resetting Flang's default runtime library to use platform default.")

flang/cmake/modules/AddFlang.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function(add_flang_library name)
5757
set(LIBTYPE SHARED)
5858
elseif(ARG_STATIC)
5959
# If BUILD_SHARED_LIBS and ARG_STATIC are both set, llvm_add_library prioritizes STATIC.
60-
# This is required behavior for libFortranFloat128Math.
60+
# This is required behavior for libflang_rt.quadmath.
6161
set(LIBTYPE STATIC)
6262
else()
6363
# Let llvm_add_library decide, taking BUILD_SHARED_LIBS into account.

flang/docs/FlangDriver.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,18 @@ like this:
175175

176176
```
177177
$ flang -v -o example example.o
178-
"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" [...]
178+
"/usr/bin/ld" [...] example.o [...] "-lflang_rt.runtime" [...]
179179
```
180180

181181
The automatically added libraries are:
182182

183-
* `FortranRuntime`: Provides most of the Flang runtime library.
183+
* `flang_rt.runtime`: Provides most of the Flang runtime library.
184184

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

192192
On Darwin, the logical root where the system libraries are located (sysroot)

flang/docs/GettingStarted.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ cmake \
216216
-DCMAKE_CUDA_COMPILER=clang \
217217
-DCMAKE_CUDA_HOST_COMPILER=clang++ \
218218
../runtime/
219-
make -j FortranRuntime
219+
make -j flang-rt
220220
```
221221

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

242-
make -j FortranRuntime
242+
make -j flang-rt
243243
```
244244

245245
Note that `nvcc` might limit support to certain
@@ -294,7 +294,7 @@ cmake \
294294
-DFLANG_OMP_DEVICE_ARCHITECTURES="all" \
295295
../runtime/
296296

297-
make -j FortranRuntime
297+
make -j flang-rt
298298
```
299299

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

311311
* `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath`: enables build of
312-
`FortranFloat128Math` library that provides `REAL(16)` math APIs
312+
`flang_rt.quadmath` library that provides `REAL(16)` math APIs
313313
for intrinsics such as `SIN`, `COS`, etc. GCC `libquadmath`'s header file
314314
`quadmath.h` must be available to the build compiler.
315315
[More details](Real16MathSupport.md).

flang/docs/OpenACC-descriptor-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ The implementation's behavior may be described as (OpenACC 2.7.2):
427427
428428
All the "is-present" checks and the data actions for the auxiliary pointers must be performed atomically with regards to the present counters bookkeeping.
429429
430-
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`).
430+
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`).
431431
432432
## TODOs:
433433

flang/docs/Real16MathSupport.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies
1212
on third-party libraries providing the implementation.
1313

1414
`-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used
15-
to build `FortranFloat128Math` library that has unresolved references
15+
to build `libflang_rt.quadmath` library that has unresolved references
1616
to GCC `libquadmath` library. A Flang driver built with this option
17-
will automatically link `FortranFloat128Math` and `libquadmath` libraries
17+
will automatically link `libflang_rt.quadmath` and `libquadmath` libraries
1818
to any Fortran program. This implies that `libquadmath` library
1919
has to be available in the standard library paths, so that linker
2020
can find it. The `libquadmath` library installation into Flang project

flang/docs/ReleaseNotes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ page](https://llvm.org/releases/).
3636

3737
## Build System Changes
3838

39+
* The FortranRuntime library has been renamed to `flang_rt.runtime`.
40+
41+
* The FortranFloat128Math library has been renamed to `flang_rt.quadmath`.
42+
43+
* The CufRuntime_cuda_${version} library has been renamed to
44+
`flang_rt.cuda_${version}`.
45+
3946
## New Issues Found
4047

4148

flang/examples/ExternalHelloWorld/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ add_llvm_example(external-hello-world
55

66
target_link_libraries(external-hello-world
77
PRIVATE
8-
FortranRuntime
8+
flang_rt.runtime
99
)

0 commit comments

Comments
 (0)