Skip to content

Commit d2f17f8

Browse files
committed
Merge branch 'users/meinersbur/flang_runtime_flang_rt' into users/meinersbur/flang_runtime_move-files
2 parents 9fce9ef + 4303d5a commit d2f17f8

File tree

25 files changed

+103
-83
lines changed

25 files changed

+103
-83
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 flang_rt
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("-lflang_rt");
1340+
CmdArgs.push_back("-lflang_rt.runtime");
13411341
addArchSpecificRPath(TC, Args, CmdArgs);
13421342
}
13431343

clang/lib/Driver/ToolChains/Flang.cpp

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

flang-rt/include/flang-rt/tools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ inline RT_API_ATTRS RESULT ApplyFloatingPointKind(
348348
if constexpr (HasCppTypeFor<TypeCategory::Real, 16>) {
349349
// If FUNC implemenation relies on FP math functions,
350350
// then we should not be here. The compiler should have
351-
// generated a call to an entry in FortranFloat128Math
351+
// generated a call to an entry in flang_rt.quadmath
352352
// library.
353353
if constexpr (!NEEDSMATH) {
354354
return FUNC<16>{}(std::forward<A>(x)...);

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 [...] "-lflang_rt" [...]
178+
"/usr/bin/ld" [...] example.o [...] "-lflang_rt.runtime" [...]
179179
```
180180

181181
The automatically added libraries are:
182182

183-
* `flang_rt`: 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-
`flang_rt`. 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 `flang_rt` 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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ page](https://llvm.org/releases/).
3636

3737
## Build System Changes
3838

39-
* FortranRuntime has been renamed to `flang_rt`.
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}`.
4045

4146
## New Issues Found
4247

flang/examples/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
add_subdirectory(ExternalHelloWorld)
1+
if (FLANG_INCLUDE_RUNTIME)
2+
add_subdirectory(ExternalHelloWorld)
3+
endif ()
24
add_subdirectory(PrintFlangFunctionNames)
35
add_subdirectory(FlangOmpReport)
46
add_subdirectory(FeatureList)

0 commit comments

Comments
 (0)