Skip to content

Commit 4bab2bf

Browse files
committed
Filter out -nolibc warning with MingW Clang
1 parent f55f047 commit 4bab2bf

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,15 @@ fn is_windows_gnu_ld(sess: &Session) -> bool {
692692
sess.target.is_like_windows
693693
&& !sess.target.is_like_msvc
694694
&& matches!(flavor, LinkerFlavor::Gnu(_, Lld::No))
695+
&& sess.target.abi != Abi::Llvm
696+
}
697+
698+
fn is_windows_gnu_clang(sess: &Session) -> bool {
699+
let (_, flavor) = linker_and_flavor(sess);
700+
sess.target.is_like_windows
701+
&& !sess.target.is_like_msvc
702+
&& matches!(flavor, LinkerFlavor::Gnu(Cc::Yes, Lld::No))
703+
&& sess.target.abi == Abi::Llvm
695704
}
696705

697706
fn report_linker_output(sess: &Session, levels: CodegenLintLevels, stdout: &[u8], stderr: &[u8]) {
@@ -781,7 +790,18 @@ fn report_linker_output(sess: &Session, levels: CodegenLintLevels, stdout: &[u8]
781790
*output += "\n"
782791
}
783792
});
784-
}
793+
} else if is_windows_gnu_clang(sess) {
794+
info!("inferred Windows Clang (GNU ABI)");
795+
escaped_stderr = for_each(&stderr, |line, output| {
796+
if line.contains("argument unused during compilation: '-nolibc'") {
797+
linker_info += line;
798+
linker_info += "\n";
799+
} else {
800+
*output += line;
801+
*output += "\n"
802+
}
803+
});
804+
};
785805

786806
let lint_msg = |msg| {
787807
emit_lint_base(

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
142142
"ignore-x86_64",
143143
"ignore-x86_64-apple-darwin",
144144
"ignore-x86_64-pc-windows-gnu",
145+
"ignore-x86_64-pc-windows-gnullvm",
145146
"ignore-x86_64-unknown-linux-gnu",
146147
"incremental",
147148
"known-bug",
@@ -263,6 +264,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
263264
"only-x86_64-apple-darwin",
264265
"only-x86_64-fortanix-unknown-sgx",
265266
"only-x86_64-pc-windows-gnu",
267+
"only-x86_64-pc-windows-gnullvm",
266268
"only-x86_64-pc-windows-msvc",
267269
"only-x86_64-unknown-linux-gnu",
268270
"pp-exact",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ build-pass
2+
//@ only-x86_64-pc-windows-gnullvm
3+
#![allow(linker_messages)]
4+
#![warn(linker_info)]
5+
6+
//~? WARN argument unused
7+
8+
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: clang: warning: argument unused during compilation: '-nolibc' [-Wunused-command-line-argument]
2+
3+
|
4+
note: the lint level is defined here
5+
--> $DIR/no-libc-mingw-llvm.rs:7:9
6+
|
7+
LL | #![warn(linker_info)]
8+
| ^^^^^^^^^^^
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)