Description
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
.