Skip to content

rustc -g file.rs does not work #12811

@pnkfelix

Description

@pnkfelix
Member

After PR #12714, the -g option to rustc stopped working robustly.

Basically, it seems to gobble up any succeeding token as the numeric argument setting the debuginfo level, so you cannot pass -g immediately before the input file name.

Here is an example of the breakage:

% rustc /tmp/hw.rs -g
% rustc -g /tmp/hw.rs
error: no input filename given
% rustc -g=2 /tmp/hw.rs
error: debug info level needs to be between 0-2
% rustc -g 2 /tmp/hw.rs
% rustc -g2 /tmp/hw.rs
% 

My recommended fix: split the options so that --debuginfo requires the level parameter, while -g does not accept a level parameter (and instead always has the same effect as --debuginfo 2).

Activity

michaelwoerister

michaelwoerister commented on Mar 10, 2014

@michaelwoerister
Member

There's already some discussion about this problem on reddit.
I'd prefer if libgetopts had a way of robustly handling optional arguments but implementing that with a nice, non-hacky interface would probably mean more work than I want to spend on this at the moment.
I think your proposed fix (also suggested on reddit by @SiegeLord) seems like a good solution for the time being.

added a commit that references this issue on Mar 12, 2014
1835667
added a commit that references this issue on Jul 22, 2022
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @pnkfelix@michaelwoerister

      Issue actions

        `rustc -g file.rs` does not work · Issue #12811 · rust-lang/rust