MSVC toolchain flags override windows_subsystem = "windows"

Aperta
#4,296 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
build-system

Direzione di ricerca

Start with rust/private/rustc.bzl at the subsystem flag forwarding point cited in the report, then compare it with rules_cc's windows_cc_toolchain_config.bzl linker_subsystem_flag. Run repro.ps1 on Windows x64 with MSVC to reproduce the direct rustc and Bazel outputs. Done means the Rust windows_subsystem attribute determines the Bazel-built executable's PE subsystem rather than the forwarded console flag.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

help wanted needs-triage platform: windows windows

Codex report: rust_binary builds a console executable from #![windows_subsystem = "windows"] on MSVC. Direct rustc produces a GUI executable from the same two-line source. The C++ toolchain supplies /SUBSYSTEM:CONSOLE, and rules_rust forwards it after rustc's subsystem selection.

On Windows x64 with MSVC, install Rust 1.98.0 and Bazelisk, then run:

git clone https://github.com/ashi009/rules-rust-windows-subsystem-repro
cd rules-rust-windows-subsystem-repro
./repro.ps1

Output excerpt from rules_rust 0.70.0:

$ rustc +1.98.0 -Vv
rustc 1.98.0 (88d9e12ae 2026-08-18)
...
$ bazel version
Build label: 8.7.0
...
out/direct.exe : PE subsystem 2 (2 = Windows GUI, 3 = Windows console)
...
bazel-bin/gui.exe : PE subsystem 3 (2 = Windows GUI, 3 = Windows console)

The Windows CI run reproduces this on both 0.70.0 and upstream main at 83d85cce0ab56b42a7466d8b34f4e52949d2d064.

The flag comes from rules_cc's linker_subsystem_flag and is forwarded by rules_rust. The Rust attribute should determine the resulting subsystem.

Lingua principale
Starlark
Stelle
857
Fork
701
Merge medio
4g 7h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bazelbuild/rules_rust

Tutte le issue di bazelbuild/rules_rust

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.