-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Driver] Silence stdlib warning when linking C on FreeBSD #68011
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
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang ChangesSimilar to the Gnu toolchain, ignore uses of '-stdlib=libc++' when linking C code. CMake insists on adding it to the command line when linking C, and a bunch of other build systems to similarly. Full diff: https://github.com/llvm/llvm-project/pull/68011.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index ff4d94c56f0d0ff..4d998e884f8ad42 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -356,6 +356,9 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
ToolChain.addProfileRTLibs(Args, CmdArgs);
+ // Silence warnings when linking C code with a C++ '-stdlib' argument.
+ Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileCurCP(),
|
This fixes this inconsistency: Linux:
FreeBSD:
|
Similar to the Gnu toolchain, ignore uses of '-stdlib=libc++' when linking C code. CMake insists on adding it to the command line when linking C, and a bunch of other build systems do similarly.
70d7622
to
bde5fc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Darwin toolchain also does this. This change LGTM, although I'm not an expert in FreeBSD.
Thanks. I think I'd like some FreeBSD folks to take a look. I wonder if it's rude to @ mention a few... maybe I will. The ones I can think of immediately are @DimitryAndric, @emaste, and @jrtc27. |
Yeah, I don't see any reason there'd be a problem with this. It seems a bit silly for build systems to pass this in, but if they do there's no value in reporting it. |
Does this only affect cases where one passes |
It handles both cases. It simply claims all the |
You do bring up an interesting point, though. When linking C code with this change, for both Gnu and FreeBSD, Also for reference, the toolchains that ignore the stdlib argument for C are: baremetal, Darwin, Fuchsia, Gnu, Hexagon, MipsLinux, NaCL, OHOS, and WebAssembly. I was mistaken above about Darwin. |
If I understand correctly this means in effect |
That's correct. It was previously a Edit: shouldn't say harmless,
|
If this looks good to people, is anyone able to merge it? I cannot do it myself. |
Similar to the Gnu toolchain, ignore uses of '-stdlib=libc++' when linking C code. CMake insists on adding it to the command line when linking C, and a bunch of other build systems do similarly.