================
@@ -2846,11 +2846,49 @@ void AppleMachO::AddCXXStdlibLibArgs(const ArgList 
&Args,
   CXXStdlibType Type = GetCXXStdlibType(Args);
 
   switch (Type) {
-  case ToolChain::CST_Libcxx:
-    CmdArgs.push_back("-lc++");
+  case ToolChain::CST_Libcxx: {
+    // On Darwin, we prioritize a libc++ located in the toolchain to a libc++
+    // located in the sysroot. Unlike the driver for most other platforms, on
+    // Darwin we do that by explicitly passing the library path to the linker
+    // to avoid having to add the toolchain's `lib/` directory to the linker
+    // search path, which would make other libraries findable as well.
+    //
+    // Prefering the toolchain library over the sysroot library matches the
+    // behavior we have for headers, where we prefer headers in the toolchain
+    // over headers in the sysroot if there are any. Note that it's important
----------------
ian-twilightcoder wrote:

Is this strictly true? I don't think we ever add <toolchain>/usr/include/c++/v1 
or <toolchain>/usr/lib/clang/nn/include/c++/v1

https://github.com/llvm/llvm-project/pull/170303
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to