Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Compiler optimizations are different for crate itself vs dependency?
I've been using no-panic
crate/hack to get higher assurances about code behavior.
Here is the command:
RUSTFLAGS="-Cllvm-args=--inline-threshold=5000 -C embed-bitcode -C lto -Z dylib-lto -C target-cpu=native" cargo build --all-targets --release --features no-panic
It works pretty well for crates individually (by individual I mean its tests and benchmarks), but I'm having issues with the same crate that was built successfully if it is used as a dependency in another crate (by that I mean another crate's tests and benchmarks).
All of a sudden, compiler is unable to eliminate some parts of the code and no longer able to prove that panics can't happen, which is concerning for performance reasons too.
--inline-threshold=5000
is already quite high and getting it higher and higher isn't really practical.
I know this is not a very popular thing to do in Rust ecosystem, at least not yet, but I find it quite fascinating.
Any pointers as to why that might be the case in case I'm missing something?
2 posts - 2 participants
🏷️ rust_feed