https://github.com/DanielCChen created https://github.com/llvm/llvm-project/pull/134297
As suggested in PR #131041, this PR moves the code of `addFortranRuntimeLibs` from `PPCLinux.cpp` to `Gnu.cpp` to generalize it for all Linux platform. >From a7c791a7fe3a0606fc6b79368b32d599bdfbe2fb Mon Sep 17 00:00:00 2001 From: cdchen-ca <cdc...@ca.ibm.com> Date: Thu, 3 Apr 2025 15:43:41 -0400 Subject: [PATCH] Generalize the addFortranRuntimeLibs code to all Linux platform. --- clang/lib/Driver/ToolChains/Gnu.cpp | 15 +++++++++++++++ clang/lib/Driver/ToolChains/Gnu.h | 2 ++ clang/lib/Driver/ToolChains/PPCLinux.cpp | 15 --------------- clang/lib/Driver/ToolChains/PPCLinux.h | 3 --- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index d53039f6302d2..97872ac21cfb7 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -3439,3 +3439,18 @@ void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs, options::OPT_fno_use_init_array, true)) CC1Args.push_back("-fno-use-init-array"); } + +void Generic_ELF::addFortranRuntimeLibs( + const ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const { + // Link static flang_rt.runtime.a or shared flang_rt.runtime.so + const char *Path; + if (getVFS().exists(Twine(Path = getCompilerRTArgString( + Args, "runtime", ToolChain::FT_Static, true)))) + CmdArgs.push_back(Path); + else if (getVFS().exists( + Twine(Path = getCompilerRTArgString( + Args, "runtime", ToolChain::FT_Shared, true)))) + CmdArgs.push_back(Path); + else + CmdArgs.push_back("-lflang_rt.runtime"); +} diff --git a/clang/lib/Driver/ToolChains/Gnu.h b/clang/lib/Driver/ToolChains/Gnu.h index 3b8df71bbf9d3..bb8e9c884e10c 100644 --- a/clang/lib/Driver/ToolChains/Gnu.h +++ b/clang/lib/Driver/ToolChains/Gnu.h @@ -376,6 +376,8 @@ class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC { void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const override; + void addFortranRuntimeLibs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const override; virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const { return {}; diff --git a/clang/lib/Driver/ToolChains/PPCLinux.cpp b/clang/lib/Driver/ToolChains/PPCLinux.cpp index 575e88c6ab124..9305fcf2cfe49 100644 --- a/clang/lib/Driver/ToolChains/PPCLinux.cpp +++ b/clang/lib/Driver/ToolChains/PPCLinux.cpp @@ -102,18 +102,3 @@ bool PPCLinuxToolChain::SupportIEEEFloat128( return GlibcSupportsFloat128((Twine(D.DyldPrefix) + Linker).str()) && !(D.CCCIsCXX() && HasUnsupportedCXXLib); } - -void PPCLinuxToolChain::addFortranRuntimeLibs( - const ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const { - // Link static flang_rt.runtime.a or shared flang_rt.runtime.so - const char *Path; - if (getVFS().exists(Twine(Path = getCompilerRTArgString( - Args, "runtime", ToolChain::FT_Static, true)))) - CmdArgs.push_back(Path); - else if (getVFS().exists( - Twine(Path = getCompilerRTArgString( - Args, "runtime", ToolChain::FT_Shared, true)))) - CmdArgs.push_back(Path); - else - CmdArgs.push_back("-lflang_rt.runtime"); -} diff --git a/clang/lib/Driver/ToolChains/PPCLinux.h b/clang/lib/Driver/ToolChains/PPCLinux.h index 910df3d16e6a5..63adaff6be9c2 100644 --- a/clang/lib/Driver/ToolChains/PPCLinux.h +++ b/clang/lib/Driver/ToolChains/PPCLinux.h @@ -24,9 +24,6 @@ class LLVM_LIBRARY_VISIBILITY PPCLinuxToolChain : public Linux { AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - void addFortranRuntimeLibs(const llvm::opt::ArgList &Args, - llvm::opt::ArgStringList &CmdArgs) const override; - private: bool SupportIEEEFloat128(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args) const; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits