Skip to content

Commit 50c8309

Browse files
committed
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.
1 parent cbce15c commit 50c8309

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/bootstrap/lib.rs

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

1183-
// If we're compiling on macOS then we add a few unconditional flags
1184-
// indicating that we want libc++ (more filled out than libstdc++) and
1185-
// we want to compile for 10.7. This way we can ensure that
1183+
// If we're compiling C++ on macOS then we add a flag indicating that
1184+
// we want libc++ (more filled out than libstdc++), ensuring that
11861185
// LLVM/etc are all properly compiled.
1187-
if target.contains("apple-darwin") {
1186+
if target.contains("apple-darwin") && matches!(c, CLang::Cxx) {
11881187
base.push("-stdlib=libc++".into());
11891188
}
11901189

0 commit comments

Comments
 (0)