[clang] [Driver] Silence stdlib warning when linking C on FreeBSD (PR #68011)

via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 2 10:30:49 PDT 2023


https://github.com/dankm created https://github.com/llvm/llvm-project/pull/68011

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 to similarly.

>From 70d76223501e86607f1fddebb1b99484a3d7a749 Mon Sep 17 00:00:00 2001
From: Dan McGregor <dan.mcgregor at usask.ca>
Date: Tue, 25 Jul 2023 18:46:50 -0600
Subject: [PATCH] [Driver] Silence stdlib warning when linking C

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 to similarly.
---
 clang/lib/Driver/ToolChains/FreeBSD.cpp | 3 +++
 1 file changed, 3 insertions(+)

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(),



More information about the cfe-commits mailing list