Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable rustc internal attribute to disable optimizations on a module/function basis #87801

Open
wesleywiser opened this issue Aug 5, 2021 · 3 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wesleywiser
Copy link
Member

Occasionally, it would be nice to use a debugger with rustc. However, currently the options generally available are to either compile with optimizations enabled which makes debugging difficult but the compiler performs reasonably or to disable optimizations which greatly increases the debugability but makes rustc unbearably slow in many situations.

It would be nice if we had the ability to to selectively disable optimizations at the function or module level via an attribute like #[rustc_optnone]. This would allow building most all of rustc with optimizations (thus retaining reasonable speed) while still allowing them to be disabled on a very small scale for the purpose of increased debugability.

Other compilers offer similar functionality:

  • clang: [[clang::optnone]]
  • gcc: __attribute__((optimize("O0")))
  • msvc: #pragma optimize( "", off )

For the LLVM backend, we would just need to adjust the functions' attributes to include optnone.

@wesleywiser wesleywiser added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. labels Aug 5, 2021
@jonas-schievink
Copy link
Contributor

cc #54882 (comment)

@Mark-Simulacrum
Copy link
Member

Is there a difference between this and #54882? Should we close this in favor of that?

@wesleywiser
Copy link
Member Author

I don't mind closing in favor of #54882 but the RFC for that tracking issue does explicitly say this functionality is out of scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants