Skip to content

Commit 9eb70d6

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 2e57d64 commit 9eb70d6

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
@@ -1146,11 +1146,10 @@ impl Build {
11461146
.filter(|s| !s.starts_with("-O") && !s.starts_with("/O"))
11471147
.collect::<Vec<String>>();
11481148

1149-
// If we're compiling on macOS then we add a few unconditional flags
1150-
// indicating that we want libc++ (more filled out than libstdc++) and
1151-
// we want to compile for 10.7. This way we can ensure that
1149+
// If we're compiling C++ on macOS then we add a flag indicating that
1150+
// we want libc++ (more filled out than libstdc++), ensuring that
11521151
// LLVM/etc are all properly compiled.
1153-
if target.contains("apple-darwin") {
1152+
if matches!(c, CLang::Cxx) && target.contains("apple-darwin") {
11541153
base.push("-stdlib=libc++".into());
11551154
}
11561155

0 commit comments

Comments
 (0)