Skip to content

Add option to prevent including metadata in target name #6899

Description

@wickerwaka

Problem
When cargo builds a target is passes -C extra-filename=-... to rustc which produces an output file with a metadata suffix in the name. For windows targets this will produce foo-metadata.exe and foo-metadata.pdb files. It then copies and renames these files so the final result is foo.exe and foo.pdb.

However the debug data in a PE executable files stores the original name of the PDB file and this name is used when debuggers (Visual Studio, WinDbg or anything using dbghelp.dll) are searching for PDB files on symbol servers. So when looking for the PDB file for foo.exe, it will actually search for foo-metadata.pdb which has likely not been uploaded.

Possible Solution(s)
Ideally it would be possible to specify in the Cargo.toml that extra-filename should not be used for certain profiles, e.g.:

[profile.release]
add-extra-filename = false

Notes
Output of cargo version: cargo 1.33.0 (f099fe9 2019-02-12)

Activity

  1. added
    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
    on May 2, 2019
  2. arve0 commented on Jun 21, 2019

    @arve0

    Adding: Specifying cargo rustc -- -o filename does not ignore -C extra-filename. Nor does -C extra-filename="". Also, rustc warns that -C extra-filename is ignored, but it is not:

    $ mkdir output-filename
    $ cd output-filename/
    $ cargo init
        Created binary (application) package
    $ cargo rustc -v --release -- -o filename
      Compiling output-filename v0.1.0 (/private/tmp/output-filename)
        Running `rustc --edition=2018 --crate-name output_filename src/main.rs --color always --crate-type bin --emit=dep-info,link -C opt-level=3 -o filename -C metadata=c961d75f8bcf3c48 -C extra-filename=-c961d75f8bcf3c48 --out-dir /private/tmp/output-filename/target/release/deps -L dependency=/private/tmp/output-filename/target/release/deps`
    warning: due to multiple output types requested, the explicitly specified output file name will be adapted for each output type
    
    warning: ignoring --out-dir flag due to -o flag
    
    warning: ignoring -C extra-filename flag due to -o flag
    
        Finished release [optimized] target(s) in 0.39s
    $ ls
    Cargo.lock          filename-c961d75f8bcf3c48   src
    Cargo.toml          filename-c961d75f8bcf3c48.d target
    

    This may be a rustc issue?

  3. ehuss commented on Jun 25, 2019

    @ehuss
    Contributor

    @arve0 I submitted a quick PR (rust-lang/rust#62128) for the extraneous warning.

  4. ehuss commented on Apr 6, 2020

    @ehuss
    Contributor

    I think the root issue here is fixed (windows executables no longer have a hash in the filename) via #7400.

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

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions