Call for Testing: Speeding up Rust compilation with `hint-mostly-unused`
10 months ago
- #Rust
- #Nightly Features
- #Compile Time Optimization
- 引入夜间版rustc专属选项`-Zhint-mostly-unused`及对应Cargo功能,通过避免不必要的代码生成来优化编译时间
- 背景:当前编译器会为整个crate生成代码,即使仅使用其中一小部分,导致编译时间浪费
- 性能提升:使用`-Zhint-mostly-unused`后观察到多项大型API crate的编译时间显著缩短
- 注意事项:若误用该选项可能拖慢编译,特别是对API使用率高的crate或多二进制项目
- Cargo集成:新增`hint-mostly-unused`配置项及`Cargo.toml`中的`hints.mostly-unused`实现选择性应用
- 未来计划:扩展Cargo的`hints`机制以支持其他优化(如`min-opt-level`)
- 行动号召:鼓励测试并提供反馈,附结果报告指南
- 致谢:鸣谢促成该功能开发的贡献者及相关活动