File tree Expand file tree Collapse file tree 6 files changed +32
-10
lines changed
compiler/rustc_lint_defs/src
rust-lld-by-default-beta-stable
rust-lld-by-default-nightly Expand file tree Collapse file tree 6 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -4091,6 +4091,7 @@ declare_lint! {
40914091 /// ### Example
40924092 ///
40934093 /// ```rust,ignore (needs CLI args, platform-specific)
4094+ /// #[warn(linker_messages)]
40944095 /// extern "C" {
40954096 /// fn foo();
40964097 /// }
@@ -4104,17 +4105,24 @@ declare_lint! {
41044105 /// >>> referenced by rust_out.69edbd30df4ae57d-cgu.0
41054106 /// >>> rust_out.rust_out.69edbd30df4ae57d-cgu.0.rcgu.o:(rust_out::main::h3a90094b06757803)
41064107 /// |
4107- /// = note: `#[warn(linker_messages)]` on by default
4108- ///
4108+ /// note: the lint level is defined here
4109+ /// --> warn.rs:1:9
4110+ /// |
4111+ /// 1 | #![warn(linker_messages)]
4112+ /// | ^^^^^^^^^^^^^^^
41094113 /// warning: 1 warning emitted
41104114 /// ```
41114115 ///
41124116 /// ### Explanation
41134117 ///
4114- /// Linkers emit platform-specific and program-specific warnings that cannot be predicted in advance by the rust compiler.
4115- /// They are forwarded by default, but can be disabled by adding `#![allow(linker_messages)]` at the crate root.
4118+ /// Linkers emit platform-specific and program-specific warnings that cannot be predicted in
4119+ /// advance by the Rust compiler. Such messages are ignored by default for now. While linker
4120+ /// warnings could be very useful they have been ignored for many years by essentially all
4121+ /// users, so we need to do a bit more work than just surfacing their text to produce a clear
4122+ /// and actionable warning of similar quality to our other diagnostics. See this tracking
4123+ /// issue for more details: <https://github.com/rust-lang/rust/issues/136096>.
41164124 pub LINKER_MESSAGES ,
4117- Warn ,
4125+ Allow ,
41184126 "warnings emitted at runtime by the target-specific linker program"
41194127}
41204128
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ fn run_rustc() -> Rustc {
88 // Make sure we use a consistent value.
99 . arg ( "-Clink-self-contained=-linker" )
1010 . arg ( "-Zunstable-options" )
11+ . arg ( "-Wlinker-messages" )
1112 . output ( "main" )
1213 . linker ( "./fake-linker" ) ;
1314 if run_make_support:: target ( ) == "x86_64-unknown-linux-gnu" {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ use run_make_support::rustc;
1212fn main ( ) {
1313 // A regular compilation should not use rust-lld by default. We'll check that by asking the
1414 // linker to display its version number with a link-arg.
15- let output = rustc ( ) . link_arg ( "-Wl,-v" ) . input ( "main.rs" ) . run ( ) ;
15+ let output = rustc ( ) . arg ( "-Wlinker-messages" ) . link_arg ( "-Wl,-v" ) . input ( "main.rs" ) . run ( ) ;
1616 assert ! (
1717 !find_lld_version_in_logs( output. stderr_utf8( ) ) ,
1818 "the LLD version string should not be present in the output logs:\n {}" ,
Original file line number Diff line number Diff line change @@ -12,15 +12,20 @@ use run_make_support::rustc;
1212fn main ( ) {
1313 // A regular compilation should use rust-lld by default. We'll check that by asking the linker
1414 // to display its version number with a link-arg.
15- let output = rustc ( ) . link_arg ( "-Wl,-v" ) . input ( "main.rs" ) . run ( ) ;
15+ let output = rustc ( ) . arg ( "-Wlinker-messages" ) . link_arg ( "-Wl,-v" ) . input ( "main.rs" ) . run ( ) ;
1616 assert ! (
1717 find_lld_version_in_logs( output. stderr_utf8( ) ) ,
1818 "the LLD version string should be present in the output logs:\n {}" ,
1919 output. stderr_utf8( )
2020 ) ;
2121
2222 // But it can still be disabled by turning the linker feature off.
23- let output = rustc ( ) . link_arg ( "-Wl,-v" ) . arg ( "-Zlinker-features=-lld" ) . input ( "main.rs" ) . run ( ) ;
23+ let output = rustc ( )
24+ . arg ( "-Wlinker-messages" )
25+ . link_arg ( "-Wl,-v" )
26+ . arg ( "-Zlinker-features=-lld" )
27+ . input ( "main.rs" )
28+ . run ( ) ;
2429 assert ! (
2530 !find_lld_version_in_logs( output. stderr_utf8( ) ) ,
2631 "the LLD version string should not be present in the output logs:\n {}" ,
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ fn main() {
1616 // the linker to display its version number with a link-arg.
1717 let output = rustc ( )
1818 . crate_type ( "cdylib" )
19+ . arg ( "-Wlinker-messages" )
1920 . target ( "custom-target.json" )
2021 . link_arg ( "-Wl,-v" )
2122 . input ( "lib.rs" )
@@ -29,6 +30,7 @@ fn main() {
2930 // But it can also be disabled via linker features.
3031 let output = rustc ( )
3132 . crate_type ( "cdylib" )
33+ . arg ( "-Wlinker-messages" )
3234 . target ( "custom-target.json" )
3335 . arg ( "-Zlinker-features=-lld" )
3436 . link_arg ( "-Wl,-v" )
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ fn main() {
1717 . arg ( "-Zlinker-features=+lld" )
1818 . arg ( "-Clink-self-contained=+linker" )
1919 . arg ( "-Zunstable-options" )
20+ . arg ( "-Wlinker-messages" )
2021 . link_arg ( linker_version_flag)
2122 . input ( "main.rs" )
2223 . run ( ) ;
@@ -27,8 +28,12 @@ fn main() {
2728 ) ;
2829
2930 // It should not be used when we explicitly opt-out of lld.
30- let output =
31- rustc ( ) . link_arg ( linker_version_flag) . arg ( "-Zlinker-features=-lld" ) . input ( "main.rs" ) . run ( ) ;
31+ let output = rustc ( )
32+ . link_arg ( linker_version_flag)
33+ . arg ( "-Zlinker-features=-lld" )
34+ . arg ( "-Wlinker-messages" )
35+ . input ( "main.rs" )
36+ . run ( ) ;
3237 assert ! (
3338 !find_lld_version_in_logs( output. stderr_utf8( ) ) ,
3439 "the LLD version string should not be present in the output logs:\n {}" ,
@@ -44,6 +49,7 @@ fn main() {
4449 . arg ( "-Zlinker-features=-lld" )
4550 . arg ( "-Zlinker-features=+lld" )
4651 . arg ( "-Zlinker-features=-lld,+lld" )
52+ . arg ( "-Wlinker-messages" )
4753 . input ( "main.rs" )
4854 . run ( ) ;
4955 assert ! (
You can’t perform that action at this time.
0 commit comments