Skip to content

Conversation

@jrose-signal
Copy link
Contributor

@jrose-signal jrose-signal commented Dec 6, 2025

...at least when using GCC or Clang. (MSVC doesn't seem to have a -g1 equivalent from a cursory search, and I'm not an MSVC expert. This can always be improved later.)

I modeled this after the handling for optimization levels, making sure not to break the existing debug and get_debug functionality.

There are two cases where this will behave differently from before (besides the cases that now produce -g1):

  • "none" is now treated as "no debug info" in addition to "0" and "false" and "", for consistency with Cargo
  • If the DEBUG environment variable is set, but its contents are not valid UTF-8, we now produce "no debug info". Previously that would count as "include debug info" for being non-empty. I don't expect this to break anyone in practice; it certainly won't ever happen from a Cargo build script.

I could not figure out how to test the special case of -gline-directives-only, which is supported by Clang and not GCC; the test utility's gnu mode doesn't have a way to force one or the other. It seems unlikely to be a problem, but if someone can describe the right test incantation I can add it!

Fixes #1622.

Copy link
Contributor

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@NobodyXu NobodyXu merged commit fe05362 into rust-lang:main Dec 6, 2025
79 checks passed
@jrose-signal jrose-signal deleted the g1 branch December 6, 2025 01:21
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.

More nuanced debug info choice

2 participants