Skip to content

build(cargo): silence the Windows linker_messages warning - #551

Merged
huichen merged 4 commits into
mainfrom
claude/win-linker-warn
Sep 10, 2026
Merged

huichen merged 4 commits into
mainfrom
claude/win-linker-warn

Conversation

@huichen

@huichen huichen commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

make install on Windows warns on every link step:

cargo build --release -p future-cli
warning: linker stdout: 正在创建库 D:\future-os\target\release\deps\future.lib 和对象 D:\future-os\target\release\deps\future.exp
  = note: `#[warn(linker_messages)]` on by default
warning: `future-cli` (bin "future") generated 1 warning

and again for the Tauri futureos lib inside tauri build. cargo test shows it on Windows too.

Cause

MSVC's link.exe prints its (localized) Creating library <x>.lib and object <x>.exp line to stdout whenever it creates an import library, and rustc 1.97+ reports any linker stdout as the warn-by-default linker_messages lint. It is benign — /NOLOGO does not suppress that line (checked locally) — so the lint is the only knob.

Change

Allow linker_messages in the existing [target.x86_64-pc-windows-msvc] rustflags of the repo-wide .cargo/config.toml, next to the existing /DEBUG:NONE. Cargo walks up from the CWD, so this also covers desktop/src-tauri and channels. Windows-only: Linux/macOS builds and CI are untouched.

Verification (Windows, pinned rustc 1.97.0)

  • With this config: cargo build -p future-cli (debug, full workspace dep graph) finishes with 0 warnings, while the same link still writes target/debug/deps/future.{lib,exp} — i.e. it did go through the import-library step that triggers the message.
  • Same command with RUSTFLAGS set (which bypasses config rustflags): the warning is back for the identical link, so the silence comes from this config and not from a skipped link.
  • A standalone cdylib cargo probe reproduced the warning without the rustflags and stayed silent with them.

Note

rustflags are part of Cargo's fingerprint, so Windows devs pay one full rebuild once this lands.

MSVC's link.exe prints its (localized) "Creating library <x>.lib and object
<x>.exp" line to stdout whenever it emits an import library, and rustc 1.97+
reports any linker stdout as a `linker_messages` warning. Every Windows link
of a bin or cdylib therefore warned: `make install` printed one for the
`future` CLI and one for the Tauri `futureos` lib, and `cargo test` did too.
`/NOLOGO` does not suppress that line, so allow the lint for the Windows
target instead of shipping benign linker noise.

Verified on Windows (rustc 1.97.0): `cargo build -p future-cli` is silent
with this config, while the same command with RUSTFLAGS set (which bypasses
config rustflags) still reproduces "warning: linker stdout: ..." for the
identical link that writes target/debug/deps/future.{lib,exp}.
@huichen
huichen enabled auto-merge (squash) September 10, 2026 14:38
@huichen
huichen merged commit 22a246e into main Sep 10, 2026
15 of 24 checks passed
@huichen
huichen deleted the claude/win-linker-warn branch September 10, 2026 15:02
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.

1 participant