Skip to content

Commit db66598

Browse files
authored
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)
2 parents 8acf40b + 9eb70d6 commit db66598

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/bootstrap/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1197,11 +1197,10 @@ impl Build {
11971197
.filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
11981198
.collect::<Vec<String>>();
11991199

1200-
// If we're compiling on macOS then we add a few unconditional flags
1201-
// indicating that we want libc++ (more filled out than libstdc++) and
1202-
// we want to compile for 10.7. This way we can ensure that
1200+
// If we're compiling C++ on macOS then we add a flag indicating that
1201+
// we want libc++ (more filled out than libstdc++), ensuring that
12031202
// LLVM/etc are all properly compiled.
1204-
if target.contains("apple-darwin") {
1203+
if matches!(c, CLang::Cxx) && target.contains("apple-darwin") {
12051204
base.push("-stdlib=libc++".into());
12061205
}
12071206

0 commit comments

Comments
 (0)