fabianVDW wrote: ↑Mon Apr 13, 2020 5:12 pm
Oh ok, thanks, I should try it without always aswell.
Maybe you'll already know, but for future posters I'll add this information.
If you want a function to inline when building for release and not inline when building for debugging, add these annotations:
Code: Select all
#[cfg_attr(debug_assertions, inline(never))]
#[cfg_attr(not(debug_assertions), inline(always))]
Note: it *has* to be the option "debug_assertions" which has to be either set or unset in Cargo.toml. There's also an option "debug" that adds debug symbols, but when you use it in the annotation, it's simply ignored; it looks like for an unknown/ignored option, the "not" version of the annotation is triggered, because when I use "debug", the function is always inlined. Don't know why "debug_assertions" works, and "debug" doesn't, because they're both profile settings in Cargo.toml.
The profiles I'm using are:
Code: Select all
[profile.dev]
opt-level = 1
lto = false
codegen-units = 1
panic = 'unwind'
debug = true
debug-assertions = true
rpath = false
incremental = false
overflow-checks = false
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
panic = 'abort'
debug = false
rpath = false
debug-assertions = false
incremental = false
overflow-checks = false
Use optimization level 1. If you don't and use 0, the profiler will show you every function in the history of ever from the underlying C++ runtime (at least VTune does, for which I need to compile with the MSVC toolchain, which compiles against MSVC140.dll).