Rollup merge of #116017 - Zalathar:darwin-stdlib, r=albertlarsan68

Don't pass `-stdlib=libc++` when building C files on macOS

When using *Command Line Tools for Xcode* version 15.0, clang will warn about `argument unused during compilation: '-stdlib=libc++'` if this flag is present when compiling C files only (i.e. no C++ files).

To avoid this warning, we can add the flag only to CXXFLAGS and not to CFLAGS.

---

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/clang.20warning.3A.20argument.20unused.20during.20compilation.20.28libc.2B.2B.29)
This commit is contained in:
Matthias Krüger 2023-11-05 12:41:46 +01:00 committed by GitHub
commit db665980e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1197,11 +1197,10 @@ impl Build {
.filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
.collect::<Vec<String>>();
// If we're compiling on macOS then we add a few unconditional flags
// indicating that we want libc++ (more filled out than libstdc++) and
// we want to compile for 10.7. This way we can ensure that
// If we're compiling C++ on macOS then we add a flag indicating that
// we want libc++ (more filled out than libstdc++), ensuring that
// LLVM/etc are all properly compiled.
if target.contains("apple-darwin") {
if matches!(c, CLang::Cxx) && target.contains("apple-darwin") {
base.push("-stdlib=libc++".into());
}