Skip to content

Commit 760658c

Browse files
authored
[Driver] Silence stdlib warning when linking C on *BSD / Solaris / Haiku (llvm#70434)
Same as 12b87f6 and the addition to Gnu.
1 parent e144ae5 commit 760658c

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

clang/lib/Driver/ToolChains/DragonFly.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const JobAction &JA,
144144
CmdArgs.push_back("-lm");
145145
}
146146

147+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
148+
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
149+
147150
// Additional linker set-up and flags for Fortran. This is required in order
148151
// to generate executables. As Fortran runtime depends on the C runtime,
149152
// these dependencies need to be listed before the C runtime below (i.e.

clang/lib/Driver/ToolChains/FreeBSD.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
291291
CmdArgs.push_back("-lm");
292292
}
293293

294+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
295+
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
296+
294297
// Additional linker set-up and flags for Fortran. This is required in order
295298
// to generate executables. As Fortran runtime depends on the C runtime,
296299
// these dependencies need to be listed before the C runtime below (i.e.
@@ -364,9 +367,6 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
364367

365368
ToolChain.addProfileRTLibs(Args, CmdArgs);
366369

367-
// Silence warnings when linking C code with a C++ '-stdlib' argument.
368-
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
369-
370370
const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
371371
C.addCommand(std::make_unique<Command>(JA, *this,
372372
ResponseFileSupport::AtFileCurCP(),

clang/lib/Driver/ToolChains/Haiku.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ void haiku::Linker::ConstructJob(Compilation &C, const JobAction &JA,
9595
if (D.CCCIsCXX() && ToolChain.ShouldLinkCXXStdlib(Args))
9696
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
9797

98+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
99+
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
100+
98101
// Additional linker set-up and flags for Fortran. This is required in order
99102
// to generate executables. As Fortran runtime depends on the C runtime,
100103
// these dependencies need to be listed before the C runtime below (i.e.

clang/lib/Driver/ToolChains/NetBSD.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
315315
CmdArgs.push_back("-lm");
316316
}
317317

318+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
319+
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
320+
318321
// Additional linker set-up and flags for Fortran. This is required in order
319322
// to generate executables. As Fortran runtime depends on the C runtime,
320323
// these dependencies need to be listed before the C runtime below (i.e.

clang/lib/Driver/ToolChains/OpenBSD.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
214214
CmdArgs.push_back("-lm");
215215
}
216216

217+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
218+
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
219+
217220
// Additional linker set-up and flags for Fortran. This is required in order
218221
// to generate executables. As Fortran runtime depends on the C runtime,
219222
// these dependencies need to be listed before the C runtime below (i.e.

clang/lib/Driver/ToolChains/Solaris.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
220220
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
221221
CmdArgs.push_back("-lm");
222222
}
223+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
224+
Args.ClaimAllArgs(options::OPT_stdlib_EQ);
223225
// Additional linker set-up and flags for Fortran. This is required in order
224226
// to generate executables. As Fortran runtime depends on the C runtime,
225227
// these dependencies need to be listed before the C runtime below.

0 commit comments

Comments
 (0)