[clang] [Clang][Driver] Revise Cygwin ToolChain to call linker directly (PR #147960)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 10:14:37 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/Cygwin.cpp clang/lib/Driver/ToolChains/Cygwin.h clang/test/Driver/cygwin.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp b/clang/lib/Driver/ToolChains/Cygwin.cpp
index 82a88065b..7b16e28fd 100644
--- a/clang/lib/Driver/ToolChains/Cygwin.cpp
+++ b/clang/lib/Driver/ToolChains/Cygwin.cpp
@@ -125,7 +125,7 @@ static bool getStaticPIE(const ArgList &Args, const ToolChain &TC) {
static bool getStatic(const ArgList &Args) {
return Args.hasArg(options::OPT_static) &&
- !Args.hasArg(options::OPT_static_pie);
+ !Args.hasArg(options::OPT_static_pie);
}
void cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -177,7 +177,8 @@ void cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("arm64pe");
break;
default:
- D.Diag(diag::err_target_unknown_triple) << ToolChain.getEffectiveTriple().str();
+ D.Diag(diag::err_target_unknown_triple)
+ << ToolChain.getEffectiveTriple().str();
}
CmdArgs.push_back("--wrap=_Znwm");
@@ -231,8 +232,8 @@ void cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!IsShared)
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
if (ToolChain.GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT) {
- std::string crtbegin = ToolChain.getCompilerRT(Args, "crtbegin",
- ToolChain::FT_Object);
+ std::string crtbegin =
+ ToolChain.getCompilerRT(Args, "crtbegin", ToolChain::FT_Object);
if (ToolChain.getVFS().exists(crtbegin)) {
std::string P;
P = crtbegin;
@@ -240,9 +241,11 @@ void cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}
if (IsShared)
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbeginS.o")));
+ CmdArgs.push_back(
+ Args.MakeArgString(ToolChain.GetFilePath("crtbeginS.o")));
else
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+ CmdArgs.push_back(
+ Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
// Add crtfastmath.o if available and fast math is enabled.
ToolChain.addFastMathRuntimeIfAvailable(Args, CmdArgs);
@@ -266,13 +269,14 @@ void cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Input = Inputs.begin();
tools::addLTOOptions(ToolChain, Args, CmdArgs, Output, *Input,
- D.getLTOMode() == LTOK_Thin);
+ D.getLTOMode() == LTOK_Thin);
}
if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
CmdArgs.push_back("--no-demangle");
- bool NeedsSanitizerDeps = tools::addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+ bool NeedsSanitizerDeps =
+ tools::addSanitizerRuntimes(ToolChain, Args, CmdArgs);
bool NeedsXRayDeps = tools::addXRayRuntime(ToolChain, Args, CmdArgs);
tools::addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
tools::AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
@@ -332,8 +336,8 @@ void cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
// FIXME: Only pass GompNeedsRT = true for platforms with libgomp that
// require librt. Most modern Linux platforms do, but some may not.
if (tools::addOpenMPRuntime(C, CmdArgs, ToolChain, Args, StaticOpenMP,
- JA.isHostOffloading(Action::OFK_OpenMP),
- /* GompNeedsRT= */ true))
+ JA.isHostOffloading(Action::OFK_OpenMP),
+ /* GompNeedsRT= */ true))
// OpenMP runtimes implies pthreads when using the GNU toolchain.
// FIXME: Does this really make sense for all GNU toolchains?
WantPthread = true;
@@ -375,8 +379,8 @@ void cygwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_nostartfiles) && !IsIAMCU) {
if (ToolChain.GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT) {
- std::string crtend = ToolChain.getCompilerRT(Args, "crtend",
- ToolChain::FT_Object);
+ std::string crtend =
+ ToolChain.getCompilerRT(Args, "crtend", ToolChain::FT_Object);
if (ToolChain.getVFS().exists(crtend)) {
std::string P;
P = crtend;
diff --git a/clang/lib/Driver/ToolChains/Cygwin.h b/clang/lib/Driver/ToolChains/Cygwin.h
index b76069fba..676db594d 100644
--- a/clang/lib/Driver/ToolChains/Cygwin.h
+++ b/clang/lib/Driver/ToolChains/Cygwin.h
@@ -28,8 +28,9 @@ public:
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
- const GCCInstallationDetector &
- getGCCInstallation() const { return GCCInstallation; };
+ const GCCInstallationDetector &getGCCInstallation() const {
+ return GCCInstallation;
+ };
protected:
Tool *buildLinker() const override;
``````````
</details>
https://github.com/llvm/llvm-project/pull/147960
More information about the cfe-commits
mailing list