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

Conversation

Meinersbur
Copy link
Member

@Meinersbur Meinersbur commented Jan 9, 2025

Following the conclusion of the RFC, 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.

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Straightforward renaming and more consistent with the clang runtimes.

@Meinersbur Meinersbur force-pushed the users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME branch from b68700b to 4c676f4 Compare January 24, 2025 18:42
@Meinersbur Meinersbur force-pushed the users/meinersbur/flang_runtime_flang_rt branch from d0a4459 to 875607f Compare January 24, 2025 18:43
@llvmbot llvmbot added clang Clang issues not falling into any other category lld clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' lld:COFF flang:driver flang:runtime platform:windows flang Flang issues not falling into any other category flang:fir-hlfir flang:semantics labels Jan 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 24, 2025

@llvm/pr-subscribers-flang-runtime
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-flang-driver

Author: Michael Kruse (Meinersbur)

Changes

The future name of Flang's runtime component is flang_rt, as already used in PR #110217 (Flang-RT). Since the flang driver has to select the runtime to link, both build instructions must agree on the name.

Extracted out of #110217


Patch is 23.32 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122341.diff

26 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2-2)
  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+4-4)
  • (modified) flang/CMakeLists.txt (+1-1)
  • (modified) flang/docs/FlangDriver.md (+3-3)
  • (modified) flang/docs/GettingStarted.md (+3-3)
  • (modified) flang/docs/OpenACC-descriptor-management.md (+1-1)
  • (modified) flang/docs/ReleaseNotes.md (+2)
  • (modified) flang/examples/ExternalHelloWorld/CMakeLists.txt (+1-1)
  • (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+1-1)
  • (modified) flang/runtime/CMakeLists.txt (+23-17)
  • (modified) flang/runtime/CUDA/CMakeLists.txt (+1-1)
  • (modified) flang/runtime/Float128Math/CMakeLists.txt (+1-1)
  • (modified) flang/runtime/time-intrinsic.cpp (+1-1)
  • (modified) flang/test/CMakeLists.txt (+7-1)
  • (modified) flang/test/Driver/gcc-toolchain-install-dir.f90 (+1-1)
  • (modified) flang/test/Driver/linker-flags.f90 (+4-4)
  • (modified) flang/test/Driver/msvc-dependent-lib-flags.f90 (+4-4)
  • (modified) flang/test/Driver/nostdlib.f90 (+1-1)
  • (modified) flang/test/Runtime/no-cpp-dep.c (+1-1)
  • (modified) flang/test/lit.cfg.py (+1-1)
  • (modified) flang/tools/f18/CMakeLists.txt (+4-4)
  • (modified) flang/unittests/CMakeLists.txt (+1-1)
  • (modified) flang/unittests/Evaluate/CMakeLists.txt (+2-2)
  • (modified) flang/unittests/Runtime/CMakeLists.txt (+1-1)
  • (modified) flang/unittests/Runtime/CUDA/CMakeLists.txt (+1-1)
  • (modified) lld/COFF/MinGW.cpp (+1-1)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b5273dd8cf1e3a..c7b0a660ee021f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -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
   // 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.
@@ -1337,7 +1337,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");
     addArchSpecificRPath(TC, Args, CmdArgs);
   }
 
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index f1bf32b3238270..68a17edf8ca341 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -360,26 +360,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;
   }
 }
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 7d6dcb5c184a52..8a8b8bfa73b007 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -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\"), leave empty for platform default.")
 
 if (NOT(FLANG_DEFAULT_RTLIB STREQUAL ""))
   message(WARNING "Resetting Flang's default runtime library to use platform default.")
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index be5633529f50cd..f3a732b0398900 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -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" [...]
 ```
 
 The automatically added libraries are:
 
-* `FortranRuntime`: Provides most of the Flang runtime library.
+* `flang_rt`: 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`.  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)
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 1c85a6754b155b..ffde50b6f481e8 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -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)
@@ -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
@@ -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
diff --git a/flang/docs/OpenACC-descriptor-management.md b/flang/docs/OpenACC-descriptor-management.md
index 52d00ae4daef88..6c147a56894c8f 100644
--- a/flang/docs/OpenACC-descriptor-management.md
+++ b/flang/docs/OpenACC-descriptor-management.md
@@ -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` and `liboffload`.  The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
 
 ## TODOs:
 
diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index f0c956281915f4..a163b4f4ed67de 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,6 +36,8 @@ page](https://llvm.org/releases/).
 
 ## Build System Changes
 
+ * FortranRuntime has been renamed to `flang_rt`.
+
 ## New Issues Found
 
 
diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
index 042d4b6238ba45..213fc462ac2b1a 100644
--- a/flang/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang/examples/ExternalHelloWorld/CMakeLists.txt
@@ -5,5 +5,5 @@ add_llvm_example(external-hello-world
 
 target_link_libraries(external-hello-world
   PRIVATE
-  FortranRuntime
+  flang_rt
   )
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 77256a51fa7f71..29ab0ab9a75f3f 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -784,7 +784,7 @@ 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
+// is provided by flang_rt, otherwise, it is done via
 // FortranFloat128Math 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.
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 6343c4276f0e3e..3e32daba52a818 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -236,13 +236,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.
+  # the relevant sources into flang_rt itself.
   # The information is provided via FortranFloat128MathILib
   # interface library.
   get_target_property(f128_sources
@@ -270,37 +270,37 @@ if (NOT TARGET FortranFloat128Math)
 endif()
 
 if (NOT DEFINED MSVC)
-  add_flang_library(FortranRuntime
+  add_flang_library(flang_rt
     ${sources}
 
     INSTALL_WITH_TOOLCHAIN
   )
 else()
-  add_flang_library(FortranRuntime
+  add_flang_library(flang_rt
     ${sources}
   )
   set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
-  add_flang_library(FortranRuntime.static ${sources}
+  add_flang_library(flang_rt.static ${sources}
     INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
+  set_target_properties(flang_rt.static PROPERTIES FOLDER "Flang/Runtime Libraries")
   set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
-  add_flang_library(FortranRuntime.dynamic ${sources}
+  add_flang_library(flang_rt.dynamic ${sources}
     INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
+  set_target_properties(flang_rt.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
   set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
-  add_flang_library(FortranRuntime.static_dbg ${sources}
+  add_flang_library(flang_rt.static_dbg ${sources}
     INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+  set_target_properties(flang_rt.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.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.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+  add_dependencies(flang_rt flang_rt.static flang_rt.dynamic
+    flang_rt.static_dbg flang_rt.dynamic_dbg)
 endif()
-set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries")
+set_target_properties(flang_rt 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.
@@ -308,9 +308,15 @@ set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries"
 # 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 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)
+add_custom_target(FortranRuntime)
+add_dependencies(FortranRuntime flang_rt)
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index 3a88824826de31..744df95267e6fc 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -31,6 +31,6 @@ endif()
 
 target_link_libraries(${CUFRT_LIBNAME}
   PRIVATE
-  FortranRuntime
+  flang_rt
   ${CUDA_RT_TARGET}
 )
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
index 703f85fcaf8dac..d65193be05ab5c 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/flang/runtime/Float128Math/CMakeLists.txt
@@ -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 cannot build without libm")
   endif()
 else()
   # We can use '__float128' version from libc, if it has them.
diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp
index e6f6e81c7b50cc..942604a92aaad7 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang/runtime/time-intrinsic.cpp
@@ -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
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index e398e0786147aa..e8e8099d4eaf7b 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -75,7 +75,7 @@ set(FLANG_TEST_DEPENDS
 )
 
 if (FLANG_INCLUDE_RUNTIME)
-  list(APPEND FLANG_TEST_DEPENDS FortranRuntime)
+  list(APPEND FLANG_TEST_DEPENDS flang_rt)
 endif ()
 
 if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
@@ -124,3 +124,9 @@ if (DEFINED FLANG_TEST_TARGET_TRIPLE)
                         "to use FLANG_TEST_TARGET_TRIPLE.")
   endif()
 endif()
+
+# Compatibility targets.
+if (FLANG_INCLUDE_RUNTIME)
+  add_custom_target(check-flang-rt)
+  add_dependencies(check-flang-rt check-flang)
+endif ()
diff --git a/flang/test/Driver/gcc-toolchain-install-dir.f90 b/flang/test/Driver/gcc-toolchain-install-dir.f90
index 5a073b0c517122..d9160e1971250f 100644
--- a/flang/test/Driver/gcc-toolchain-install-dir.f90
+++ b/flang/test/Driver/gcc-toolchain-install-dir.f90
@@ -1,5 +1,5 @@
 !! Test that --gcc-toolchain and --gcc-install-dir options are working as expected.
-!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libFortranRuntime, etc. are not supposed to be affected.
+!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt, etc. are not supposed to be affected.
 !! PREFIX is captured twice because the driver escapes backslashes (occuring in Windows paths) in the -### output, but not on the "Selected GCC installation:" line.
 
 ! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-I386
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index fdeb95e4dd97c6..5dc89fe45c8cc0 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -33,26 +33,26 @@
 ! SOLARIS-F128NONE-NOT: FortranFloat128Math
 ! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
 ! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
-! UNIX-SAME: "-lFortranRuntime" "-lm"
+! UNIX-SAME: "-lflang_rt" "-lm"
 ! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"
 ! DARWIN-F128NONE-NOT: FortranFloat128Math
 ! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! DARWIN-SAME: -lFortranRuntime
+! DARWIN-SAME: -lflang_rt
 
 ! HAIKU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! HAIKU-SAME: "[[object_file]]"
 ! HAIKU-F128NONE-NOT: FortranFloat128Math
 ! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! HAIKU-SAME: "-lFortranRuntime"
+! HAIKU-SAME: "-lflang_rt"
 
 ! MINGW-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! MINGW-SAME: "[[object_file]]"
 ! MINGW-F128NONE-NOT: FortranFloat128Math
 ! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! MINGW-SAME: -lFortranRuntime
+! MINGW-SAME: -lflang_rt
 
 ! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
 !       any .exe suffix that is added when resolving to the full path of
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index befe61fdadcd14..dabac56d602d1e 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -7,21 +7,21 @@
 ! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib
 ! MSVC-SAME: -D_MT
 ! MSVC-SAME: --dependent-lib=libcmt
-! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
+! MSVC-SAME: --dependent-lib=flang_rt.static.lib
 
 ! MSVC-DEBUG: -fc1
 ! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
 ! MSVC-DEBUG-SAME: -D_MT
 ! MSVC-DEBUG-SAME: -D_DEBUG
 ! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
-! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
+! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.static_dbg.lib
 
 ! MSVC-DLL: -fc1
 ! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
 ! MSVC-DLL-SAME: -D_MT
 ! MSVC-DLL-SAME: -D_DLL
 ! MSVC-DLL-SAME: --dependent-lib=msvcrt
-! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
+! MSVC-DLL-SAME: --dependent-lib=flang_rt.dynamic.lib
 
 ! MSVC-DLL-DEBUG: -fc1
 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -29,4 +29,4 @@
 ! MSVC-DLL-DEBUG-SAME: -D_DEBUG
 ! MSVC-DLL-DEBUG-SAME: -D_DLL
 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
+! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.dynamic_dbg.lib
diff --git a/flang/test/Driver/nostdlib.f90 b/flang/test/Driver/nostdlib.f90
index ab7c675fe7b77d..17ed10fa0615d5 100644
--- a/flang/test/Driver/nostdlib.f90
+++ b/flang/test/Driver/nostdlib.f90
@@ -24,5 +24,5 @@
 ! in certain cases. But it is not clear that it is worth checking for each
 ! platform individually.
 
-! CHECK-NOT: "-lFortranRuntime"
+! CHECK-NOT: "-lflang_rt"
 ! CHECK-NOT: "-lgcc"
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index 7303ce63fdec41..c03029f0f3c26d 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -1,6 +1,6 @@
 /*
 This test makes sure that flang's runtime does not depend on the C++ runtime
-library. It tries to link this simple file against libFortranRuntime.a with
+library. It tries to link this simple file against libflang_rt.a with
 a C compiler.
 
 REQUIRES: c-compiler, flang-rt
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index f4580afc8c47b1..08ba586e1226d3 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -170,7 +170,7 @@
 # the C++ runtime libraries. For this we need a C compiler. If for some reason
 # we don't have one, we can just disable the test.
 if config.flang_include_runtime and config.cc:
-    libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
+    libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.a")
     include = os.path.join(config.flang_src_dir, "include")
 
     if (
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 85ba2c74cdeb5c..a849e95df31c17 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 # Define the list of Fortran module files that need to be compiled
-# to produce an object file for inclusion into the FortranRuntime
+# to produce an object file for inclusion into the flang_rt
 # library.
 set(MODULES_WITH_IMPLEMENTATION
   "iso_fortran_env_impl"
@@ -105,7 +105,7 @@ if (NOT CMAKE_CROSSCOMPILING)
     endif()
 
     # Some modules have an implementation part that n...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jan 24, 2025

@llvm/pr-subscribers-flang-semantics

Author: Michael Kruse (Meinersbur)

Changes

The future name of Flang's runtime component is flang_rt, as already used in PR #110217 (Flang-RT). Since the flang driver has to select the runtime to link, both build instructions must agree on the name.

Extracted out of #110217


Patch is 23.32 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122341.diff

26 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2-2)
  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+4-4)
  • (modified) flang/CMakeLists.txt (+1-1)
  • (modified) flang/docs/FlangDriver.md (+3-3)
  • (modified) flang/docs/GettingStarted.md (+3-3)
  • (modified) flang/docs/OpenACC-descriptor-management.md (+1-1)
  • (modified) flang/docs/ReleaseNotes.md (+2)
  • (modified) flang/examples/ExternalHelloWorld/CMakeLists.txt (+1-1)
  • (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+1-1)
  • (modified) flang/runtime/CMakeLists.txt (+23-17)
  • (modified) flang/runtime/CUDA/CMakeLists.txt (+1-1)
  • (modified) flang/runtime/Float128Math/CMakeLists.txt (+1-1)
  • (modified) flang/runtime/time-intrinsic.cpp (+1-1)
  • (modified) flang/test/CMakeLists.txt (+7-1)
  • (modified) flang/test/Driver/gcc-toolchain-install-dir.f90 (+1-1)
  • (modified) flang/test/Driver/linker-flags.f90 (+4-4)
  • (modified) flang/test/Driver/msvc-dependent-lib-flags.f90 (+4-4)
  • (modified) flang/test/Driver/nostdlib.f90 (+1-1)
  • (modified) flang/test/Runtime/no-cpp-dep.c (+1-1)
  • (modified) flang/test/lit.cfg.py (+1-1)
  • (modified) flang/tools/f18/CMakeLists.txt (+4-4)
  • (modified) flang/unittests/CMakeLists.txt (+1-1)
  • (modified) flang/unittests/Evaluate/CMakeLists.txt (+2-2)
  • (modified) flang/unittests/Runtime/CMakeLists.txt (+1-1)
  • (modified) flang/unittests/Runtime/CUDA/CMakeLists.txt (+1-1)
  • (modified) lld/COFF/MinGW.cpp (+1-1)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b5273dd8cf1e3a..c7b0a660ee021f 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -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
   // 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.
@@ -1337,7 +1337,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");
     addArchSpecificRPath(TC, Args, CmdArgs);
   }
 
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index f1bf32b3238270..68a17edf8ca341 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -360,26 +360,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;
   }
 }
diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 7d6dcb5c184a52..8a8b8bfa73b007 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -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\"), leave empty for platform default.")
 
 if (NOT(FLANG_DEFAULT_RTLIB STREQUAL ""))
   message(WARNING "Resetting Flang's default runtime library to use platform default.")
diff --git a/flang/docs/FlangDriver.md b/flang/docs/FlangDriver.md
index be5633529f50cd..f3a732b0398900 100644
--- a/flang/docs/FlangDriver.md
+++ b/flang/docs/FlangDriver.md
@@ -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" [...]
 ```
 
 The automatically added libraries are:
 
-* `FortranRuntime`: Provides most of the Flang runtime library.
+* `flang_rt`: 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`.  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)
diff --git a/flang/docs/GettingStarted.md b/flang/docs/GettingStarted.md
index 1c85a6754b155b..ffde50b6f481e8 100644
--- a/flang/docs/GettingStarted.md
+++ b/flang/docs/GettingStarted.md
@@ -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)
@@ -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
@@ -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
diff --git a/flang/docs/OpenACC-descriptor-management.md b/flang/docs/OpenACC-descriptor-management.md
index 52d00ae4daef88..6c147a56894c8f 100644
--- a/flang/docs/OpenACC-descriptor-management.md
+++ b/flang/docs/OpenACC-descriptor-management.md
@@ -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` and `liboffload`.  The F18 driver adds `FortranOffloadRuntime` for linking under `-fopenacc`/`-fopenmp` (and maybe additional switches like `-fopenmp-targets`).
 
 ## TODOs:
 
diff --git a/flang/docs/ReleaseNotes.md b/flang/docs/ReleaseNotes.md
index f0c956281915f4..a163b4f4ed67de 100644
--- a/flang/docs/ReleaseNotes.md
+++ b/flang/docs/ReleaseNotes.md
@@ -36,6 +36,8 @@ page](https://llvm.org/releases/).
 
 ## Build System Changes
 
+ * FortranRuntime has been renamed to `flang_rt`.
+
 ## New Issues Found
 
 
diff --git a/flang/examples/ExternalHelloWorld/CMakeLists.txt b/flang/examples/ExternalHelloWorld/CMakeLists.txt
index 042d4b6238ba45..213fc462ac2b1a 100644
--- a/flang/examples/ExternalHelloWorld/CMakeLists.txt
+++ b/flang/examples/ExternalHelloWorld/CMakeLists.txt
@@ -5,5 +5,5 @@ add_llvm_example(external-hello-world
 
 target_link_libraries(external-hello-world
   PRIVATE
-  FortranRuntime
+  flang_rt
   )
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 77256a51fa7f71..29ab0ab9a75f3f 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -784,7 +784,7 @@ 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
+// is provided by flang_rt, otherwise, it is done via
 // FortranFloat128Math 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.
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index 6343c4276f0e3e..3e32daba52a818 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flang/runtime/CMakeLists.txt
@@ -236,13 +236,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.
+  # the relevant sources into flang_rt itself.
   # The information is provided via FortranFloat128MathILib
   # interface library.
   get_target_property(f128_sources
@@ -270,37 +270,37 @@ if (NOT TARGET FortranFloat128Math)
 endif()
 
 if (NOT DEFINED MSVC)
-  add_flang_library(FortranRuntime
+  add_flang_library(flang_rt
     ${sources}
 
     INSTALL_WITH_TOOLCHAIN
   )
 else()
-  add_flang_library(FortranRuntime
+  add_flang_library(flang_rt
     ${sources}
   )
   set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
-  add_flang_library(FortranRuntime.static ${sources}
+  add_flang_library(flang_rt.static ${sources}
     INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
+  set_target_properties(flang_rt.static PROPERTIES FOLDER "Flang/Runtime Libraries")
   set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
-  add_flang_library(FortranRuntime.dynamic ${sources}
+  add_flang_library(flang_rt.dynamic ${sources}
     INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
+  set_target_properties(flang_rt.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
   set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
-  add_flang_library(FortranRuntime.static_dbg ${sources}
+  add_flang_library(flang_rt.static_dbg ${sources}
     INSTALL_WITH_TOOLCHAIN)
-  set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+  set_target_properties(flang_rt.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.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.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
+  add_dependencies(flang_rt flang_rt.static flang_rt.dynamic
+    flang_rt.static_dbg flang_rt.dynamic_dbg)
 endif()
-set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries")
+set_target_properties(flang_rt 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.
@@ -308,9 +308,15 @@ set_target_properties(FortranRuntime PROPERTIES FOLDER "Flang/Runtime Libraries"
 # 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 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)
+add_custom_target(FortranRuntime)
+add_dependencies(FortranRuntime flang_rt)
diff --git a/flang/runtime/CUDA/CMakeLists.txt b/flang/runtime/CUDA/CMakeLists.txt
index 3a88824826de31..744df95267e6fc 100644
--- a/flang/runtime/CUDA/CMakeLists.txt
+++ b/flang/runtime/CUDA/CMakeLists.txt
@@ -31,6 +31,6 @@ endif()
 
 target_link_libraries(${CUFRT_LIBNAME}
   PRIVATE
-  FortranRuntime
+  flang_rt
   ${CUDA_RT_TARGET}
 )
diff --git a/flang/runtime/Float128Math/CMakeLists.txt b/flang/runtime/Float128Math/CMakeLists.txt
index 703f85fcaf8dac..d65193be05ab5c 100644
--- a/flang/runtime/Float128Math/CMakeLists.txt
+++ b/flang/runtime/Float128Math/CMakeLists.txt
@@ -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 cannot build without libm")
   endif()
 else()
   # We can use '__float128' version from libc, if it has them.
diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp
index e6f6e81c7b50cc..942604a92aaad7 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang/runtime/time-intrinsic.cpp
@@ -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
diff --git a/flang/test/CMakeLists.txt b/flang/test/CMakeLists.txt
index e398e0786147aa..e8e8099d4eaf7b 100644
--- a/flang/test/CMakeLists.txt
+++ b/flang/test/CMakeLists.txt
@@ -75,7 +75,7 @@ set(FLANG_TEST_DEPENDS
 )
 
 if (FLANG_INCLUDE_RUNTIME)
-  list(APPEND FLANG_TEST_DEPENDS FortranRuntime)
+  list(APPEND FLANG_TEST_DEPENDS flang_rt)
 endif ()
 
 if (LLVM_ENABLE_PLUGINS AND NOT WIN32)
@@ -124,3 +124,9 @@ if (DEFINED FLANG_TEST_TARGET_TRIPLE)
                         "to use FLANG_TEST_TARGET_TRIPLE.")
   endif()
 endif()
+
+# Compatibility targets.
+if (FLANG_INCLUDE_RUNTIME)
+  add_custom_target(check-flang-rt)
+  add_dependencies(check-flang-rt check-flang)
+endif ()
diff --git a/flang/test/Driver/gcc-toolchain-install-dir.f90 b/flang/test/Driver/gcc-toolchain-install-dir.f90
index 5a073b0c517122..d9160e1971250f 100644
--- a/flang/test/Driver/gcc-toolchain-install-dir.f90
+++ b/flang/test/Driver/gcc-toolchain-install-dir.f90
@@ -1,5 +1,5 @@
 !! Test that --gcc-toolchain and --gcc-install-dir options are working as expected.
-!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libFortranRuntime, etc. are not supposed to be affected.
+!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libflang_rt, etc. are not supposed to be affected.
 !! PREFIX is captured twice because the driver escapes backslashes (occuring in Windows paths) in the -### output, but not on the "Selected GCC installation:" line.
 
 ! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-I386
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index fdeb95e4dd97c6..5dc89fe45c8cc0 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -33,26 +33,26 @@
 ! SOLARIS-F128NONE-NOT: FortranFloat128Math
 ! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
 ! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
-! UNIX-SAME: "-lFortranRuntime" "-lm"
+! UNIX-SAME: "-lflang_rt" "-lm"
 ! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
 
 ! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"
 ! DARWIN-F128NONE-NOT: FortranFloat128Math
 ! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! DARWIN-SAME: -lFortranRuntime
+! DARWIN-SAME: -lflang_rt
 
 ! HAIKU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! HAIKU-SAME: "[[object_file]]"
 ! HAIKU-F128NONE-NOT: FortranFloat128Math
 ! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! HAIKU-SAME: "-lFortranRuntime"
+! HAIKU-SAME: "-lflang_rt"
 
 ! MINGW-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! MINGW-SAME: "[[object_file]]"
 ! MINGW-F128NONE-NOT: FortranFloat128Math
 ! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
-! MINGW-SAME: -lFortranRuntime
+! MINGW-SAME: -lflang_rt
 
 ! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
 !       any .exe suffix that is added when resolving to the full path of
diff --git a/flang/test/Driver/msvc-dependent-lib-flags.f90 b/flang/test/Driver/msvc-dependent-lib-flags.f90
index befe61fdadcd14..dabac56d602d1e 100644
--- a/flang/test/Driver/msvc-dependent-lib-flags.f90
+++ b/flang/test/Driver/msvc-dependent-lib-flags.f90
@@ -7,21 +7,21 @@
 ! MSVC-SAME: --dependent-lib=clang_rt.builtins.lib
 ! MSVC-SAME: -D_MT
 ! MSVC-SAME: --dependent-lib=libcmt
-! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
+! MSVC-SAME: --dependent-lib=flang_rt.static.lib
 
 ! MSVC-DEBUG: -fc1
 ! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
 ! MSVC-DEBUG-SAME: -D_MT
 ! MSVC-DEBUG-SAME: -D_DEBUG
 ! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
-! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
+! MSVC-DEBUG-SAME: --dependent-lib=flang_rt.static_dbg.lib
 
 ! MSVC-DLL: -fc1
 ! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
 ! MSVC-DLL-SAME: -D_MT
 ! MSVC-DLL-SAME: -D_DLL
 ! MSVC-DLL-SAME: --dependent-lib=msvcrt
-! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
+! MSVC-DLL-SAME: --dependent-lib=flang_rt.dynamic.lib
 
 ! MSVC-DLL-DEBUG: -fc1
 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -29,4 +29,4 @@
 ! MSVC-DLL-DEBUG-SAME: -D_DEBUG
 ! MSVC-DLL-DEBUG-SAME: -D_DLL
 ! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
-! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
+! MSVC-DLL-DEBUG-SAME: --dependent-lib=flang_rt.dynamic_dbg.lib
diff --git a/flang/test/Driver/nostdlib.f90 b/flang/test/Driver/nostdlib.f90
index ab7c675fe7b77d..17ed10fa0615d5 100644
--- a/flang/test/Driver/nostdlib.f90
+++ b/flang/test/Driver/nostdlib.f90
@@ -24,5 +24,5 @@
 ! in certain cases. But it is not clear that it is worth checking for each
 ! platform individually.
 
-! CHECK-NOT: "-lFortranRuntime"
+! CHECK-NOT: "-lflang_rt"
 ! CHECK-NOT: "-lgcc"
diff --git a/flang/test/Runtime/no-cpp-dep.c b/flang/test/Runtime/no-cpp-dep.c
index 7303ce63fdec41..c03029f0f3c26d 100644
--- a/flang/test/Runtime/no-cpp-dep.c
+++ b/flang/test/Runtime/no-cpp-dep.c
@@ -1,6 +1,6 @@
 /*
 This test makes sure that flang's runtime does not depend on the C++ runtime
-library. It tries to link this simple file against libFortranRuntime.a with
+library. It tries to link this simple file against libflang_rt.a with
 a C compiler.
 
 REQUIRES: c-compiler, flang-rt
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index f4580afc8c47b1..08ba586e1226d3 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -170,7 +170,7 @@
 # the C++ runtime libraries. For this we need a C compiler. If for some reason
 # we don't have one, we can just disable the test.
 if config.flang_include_runtime and config.cc:
-    libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
+    libruntime = os.path.join(config.flang_lib_dir, "libflang_rt.a")
     include = os.path.join(config.flang_src_dir, "include")
 
     if (
diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt
index 85ba2c74cdeb5c..a849e95df31c17 100644
--- a/flang/tools/f18/CMakeLists.txt
+++ b/flang/tools/f18/CMakeLists.txt
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
   )
 
 # Define the list of Fortran module files that need to be compiled
-# to produce an object file for inclusion into the FortranRuntime
+# to produce an object file for inclusion into the flang_rt
 # library.
 set(MODULES_WITH_IMPLEMENTATION
   "iso_fortran_env_impl"
@@ -105,7 +105,7 @@ if (NOT CMAKE_CROSSCOMPILING)
     endif()
 
     # Some modules have an implementation part that n...
[truncated]

…rs/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME
…rs/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME
…rs/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME
Base automatically changed from users/meinersbur/flang_runtime_FLANG_INCLUDE_RUNTIME to main February 8, 2025 00:06
@Meinersbur Meinersbur changed the title [Flang] Rename libFortranRuntime.a to libflang_rt.a [Flang] Rename libFortranRuntime.a to libflang_rt.runtime.a Feb 8, 2025
@Meinersbur Meinersbur merged commit 5c8c2b3 into main Feb 8, 2025
9 checks passed
@Meinersbur Meinersbur deleted the users/meinersbur/flang_runtime_flang_rt branch February 8, 2025 17:02
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 8, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building clang,flang,lld at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/22347

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/div-zero.cpp (94194 of 98230)
UNSUPPORTED: UBSan-Standalone-lld-x86_64 :: TestCases/Misc/Posix/print_stack_trace.cpp (94195 of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/sub-overflow.cpp (94196 of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/no-recover.cpp (94197 of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/negate-overflow.cpp (94198 of 98230)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/local_bounds.cpp (94199 of 98230)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/coverage-levels.cpp (94200 of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/incdec-overflow.cpp (94201 of 98230)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/suppressions.cpp (94202 of 98230)
TIMEOUT: MLIR :: Examples/standalone/test.toy (94203 of 98230)
******************** TEST 'MLIR :: Examples/standalone/test.toy' FAILED ********************
Exit Code: 1
Timeout: Reached timeout of 60 seconds

Command Output (stdout):
--
# RUN: at line 1
"/etc/cmake/bin/cmake" "/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone" -G "Ninja"  -DCMAKE_CXX_COMPILER=/usr/bin/clang++  -DCMAKE_C_COMPILER=/usr/bin/clang   -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir  -DLLVM_USE_LINKER=lld  -DPython3_EXECUTABLE="/usr/bin/python3.10"
# executed command: /etc/cmake/bin/cmake /build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld -DPython3_EXECUTABLE=/usr/bin/python3.10
# .---command stdout------------
# | -- The CXX compiler identification is Clang 16.0.6
# | -- The C compiler identification is Clang 16.0.6
# | -- Detecting CXX compiler ABI info
# | -- Detecting CXX compiler ABI info - done
# | -- Check for working CXX compiler: /usr/bin/clang++ - skipped
# | -- Detecting CXX compile features
# | -- Detecting CXX compile features - done
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - done
# | -- Check for working C compiler: /usr/bin/clang - skipped
# | -- Detecting C compile features
# | -- Detecting C compile features - done
# | -- Looking for histedit.h
# | -- Looking for histedit.h - found
# | -- Found LibEdit: /usr/include (found version "2.11") 
# | -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
# | -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.13") 
# | -- Using MLIRConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir
# | -- Using LLVMConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/llvm
# | -- Linker detection: unknown
# | -- Performing Test LLVM_LIBSTDCXX_MIN
# | -- Performing Test LLVM_LIBSTDCXX_MIN - Success
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
# | -- Performing Test C_SUPPORTS_FPIC
# | -- Performing Test C_SUPPORTS_FPIC - Success
# | -- Performing Test CXX_SUPPORTS_FPIC

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 9, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building clang,flang,lld at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2255

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/38/87' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-16244-38-87.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=38 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


@DavidTruby
Copy link
Member

DavidTruby commented Feb 10, 2025

This has broken Windows builds but I'm not fully sure why and I can't investigate as I'm on holiday until next week. Can we revert until we can work out why Windows builds are broken?

@DavidTruby
Copy link
Member

At a quick glance it looks like we're still trying to link FortranDecimal somewhere so this might be #121997 instead..

@DavidTruby
Copy link
Member

Sorry, I managed to have a better look at our CI and this seems to be a downstream build system issue. I assumed because the upstream CI was also broken that it was an issue in both but that seems to be unrelated.

No need to revert, sorry for the noise!

Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category flang:driver flang:fir-hlfir flang:runtime flang:semantics flang Flang issues not falling into any other category lld:COFF lld platform:windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants