Skip to content

Make all linker warnings errors in CI - #667

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
tgross35:linker-errors
Aug 17, 2026
Merged

Make all linker warnings errors in CI#667
tgross35 merged 1 commit into
rust-lang:mainfrom
tgross35:linker-errors

Conversation

@tgross35

@tgross35 tgross35 commented Aug 11, 2024

Copy link
Copy Markdown
Member

Give us a better chance of detecting any kind of link issues or user-visible warnings in advance.

Inspired by #665 (comment)

@tgross35 tgross35 changed the title Make all linker warnings errors [experiment] Make all linker warnings errors Aug 12, 2024
@tgross35

Copy link
Copy Markdown
Member Author

Failure notes:

@ChrisDenton

Copy link
Copy Markdown
Member

For MSVC it's /WX

@tgross35

Copy link
Copy Markdown
Member Author

Does it ignore unrecognized link args? fatal-warnings is still getting passed and it doesn't seem to complain https://github.com/rust-lang/compiler-builtins/actions/runs/10343839608/job/28628523945?pr=667#step:11:23

@ChrisDenton

Copy link
Copy Markdown
Member

I mean... /Wx isn't being passed yet?

> rustc hello.rs -C link-args='/WX --fatal-warnings'

error: linking with `link.exe` failed: exit code: 4044
[...]
  = note: LINK : warning LNK4044: unrecognized option '/-fatal-warnings'; ignored
          LINK : error LNK1218: warning treated as error; no output file generated

@tgross35

Copy link
Copy Markdown
Member Author

Oh, unrecognized linker args are warnings by default rather than errors? I was just expecting it to complain like the other targets that don't support -Wl,--fatal-warnings do.

@tgross35 tgross35 changed the title [experiment] Make all linker warnings errors Make all linker warnings errors in CI Sep 28, 2024
@tgross35

Copy link
Copy Markdown
Member Author

The wasm issue is rust-lang/rust#132802, I still haven't updated the Windows flags.

@rustbot

This comment has been minimized.

Since 1.97, linker warnings can be denied via rustc.
@tgross35
tgross35 marked this pull request as ready for review August 17, 2026 09:12
@tgross35

Copy link
Copy Markdown
Member Author

Since 1.97, -Dlinker_warnings should do most of what we're interested in https://blog.rust-lang.org/2026/07/09/Rust-1.97.0/.

Previous version, for reference:

# Make all linker warnings errors
if [[ "$target" == *"-apple-"* || "$target" == "thumb"* ]]; then
    extra_rustflags=""
else
    extra_rustflags=" -Clink-arg=-Wl,--fatal-warnings"
fi

export RUSTFLAGS="${RUSTFLAGS:-}$extra_rustflags"

@tgross35
tgross35 enabled auto-merge (rebase) August 17, 2026 09:12
@tgross35
tgross35 merged commit 431b2d9 into rust-lang:main Aug 17, 2026
44 checks passed
@tgross35
tgross35 deleted the linker-errors branch August 17, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants