Kor*_*nel 11 integer-overflow compiler-optimization rust
我正在编写一个计算量很大的程序,在调试模式下运行起来非常慢.
我的程序也受到整数溢出的困扰,因为我正在从u8数组中读取数据并u8通过类型推断将扩展类型扩展到意外的位置,而Rust更喜欢溢出而不是将整数提升为更大的类型.
在发布模式下构建会禁用溢出检查:
cargo run --release
Run Code Online (Sandbox Code Playgroud)
如何通过优化和运行时溢出检查来构建Rust可执行文件?
She*_*ter 13
您可以在启用溢出检查的发布模式下编译:
[profile.release]
overflow-checks = true
Run Code Online (Sandbox Code Playgroud)
这传递-C overflow-checks=true给编译器.在早期版本的Rust中,它overflow-checks是debug-assertions交换机的一部分,因此在某些情况下您可能需要使用它.
[profile.dev]
opt-level = 3
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5522 次 |
| 最近记录: |