Skip to content

MSVC PDB is undeclared under -c opt #4419

Open

Description

@TrapsterDK

On *-windows-msvc targets, rustc_compile_action in rust/private/rustc.bzl declares the .pdb of bin and cdylib crates only when the strip level is none. rustc ignores -Cstrip on MSVC and always links with /DEBUG (rust-lang/rust#115120), so the PDB is written in every compilation mode.

Under -c opt (strip level debuginfo by default), the PDB is an undeclared output and the pdb_file output group is missing.

Repro on Windows:

bazel build -c opt //test/unit/debug_info:mybin.pdb

The filegroup is empty, while bazel-bin/test/unit/debug_info/myrustbin.pdb is on disk next to the .exe.

Proposed fix: declare the PDB for every MSVC bin/cdylib whatever the strip level. No public interface change. PR to follow with an analysis test that runs on Linux through a mock MSVC toolchain.

Assisted by Claude.

Activity

  1. added a commit that references this issue on Nov 12, 2026
    ee77250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThe ticket needs maintainer attention.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址