180 条记录
15 私有链接
15 私有链接
使用MSVC工具链!
在全局 config.toml 中设置默认 release 配置,位于:
~/.cargo/config.toml
修改 Cargo.toml,添加以下配置:
[profile.release]
opt-level = "z" # 优化级别设为 "z",专注于大小优化
lto = true # 启用链接时优化
codegen-units = 1 # 减少代码生成单元,提高优化效果
panic = "abort" # 恐慌时直接中止,减少错误处理代码
strip = true # 剥离符号信息
cargo build --release
Github项目:
https://github.com/johnthagen/min-sized-rust/tree/main