Skip to content

Commit a7c791a

Browse files
committed
Generalize the addFortranRuntimeLibs code to all Linux platform.
1 parent 12f75bb commit a7c791a

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3439,3 +3439,18 @@ void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs,
34393439
options::OPT_fno_use_init_array, true))
34403440
CC1Args.push_back("-fno-use-init-array");
34413441
}
3442+
3443+
void Generic_ELF::addFortranRuntimeLibs(
3444+
const ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const {
3445+
// Link static flang_rt.runtime.a or shared flang_rt.runtime.so
3446+
const char *Path;
3447+
if (getVFS().exists(Twine(Path = getCompilerRTArgString(
3448+
Args, "runtime", ToolChain::FT_Static, true))))
3449+
CmdArgs.push_back(Path);
3450+
else if (getVFS().exists(
3451+
Twine(Path = getCompilerRTArgString(
3452+
Args, "runtime", ToolChain::FT_Shared, true))))
3453+
CmdArgs.push_back(Path);
3454+
else
3455+
CmdArgs.push_back("-lflang_rt.runtime");
3456+
}

clang/lib/Driver/ToolChains/Gnu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
376376
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
377377
llvm::opt::ArgStringList &CC1Args,
378378
Action::OffloadKind DeviceOffloadKind) const override;
379+
void addFortranRuntimeLibs(const llvm::opt::ArgList &Args,
380+
llvm::opt::ArgStringList &CmdArgs) const override;
379381

380382
virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const {
381383
return {};

clang/lib/Driver/ToolChains/PPCLinux.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,3 @@ bool PPCLinuxToolChain::SupportIEEEFloat128(
102102
return GlibcSupportsFloat128((Twine(D.DyldPrefix) + Linker).str()) &&
103103
!(D.CCCIsCXX() && HasUnsupportedCXXLib);
104104
}
105-
106-
void PPCLinuxToolChain::addFortranRuntimeLibs(
107-
const ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const {
108-
// Link static flang_rt.runtime.a or shared flang_rt.runtime.so
109-
const char *Path;
110-
if (getVFS().exists(Twine(Path = getCompilerRTArgString(
111-
Args, "runtime", ToolChain::FT_Static, true))))
112-
CmdArgs.push_back(Path);
113-
else if (getVFS().exists(
114-
Twine(Path = getCompilerRTArgString(
115-
Args, "runtime", ToolChain::FT_Shared, true))))
116-
CmdArgs.push_back(Path);
117-
else
118-
CmdArgs.push_back("-lflang_rt.runtime");
119-
}

clang/lib/Driver/ToolChains/PPCLinux.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class LLVM_LIBRARY_VISIBILITY PPCLinuxToolChain : public Linux {
2424
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
2525
llvm::opt::ArgStringList &CC1Args) const override;
2626

27-
void addFortranRuntimeLibs(const llvm::opt::ArgList &Args,
28-
llvm::opt::ArgStringList &CmdArgs) const override;
29-
3027
private:
3128
bool SupportIEEEFloat128(const Driver &D, const llvm::Triple &Triple,
3229
const llvm::opt::ArgList &Args) const;

0 commit comments

Comments
 (0)