TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Minimizing Rust Binary Size

149 点作者 xanthine将近 5 年前

7 条评论

tiborsaas将近 5 年前
Another post for size constraint coding in Rust:<p><a href="https:&#x2F;&#x2F;www.codeslow.com&#x2F;2020&#x2F;01&#x2F;writing-4k-intro-in-rust.html" rel="nofollow">https:&#x2F;&#x2F;www.codeslow.com&#x2F;2020&#x2F;01&#x2F;writing-4k-intro-in-rust.ht...</a>
ahartmetz将近 5 年前
I am surprised that dynamically linking to Rust libstd and other common libraries is not mentioned. Rust produces (as far as Rust code is concerned, not sure about libc if used) fully static binaries by default, right?
评论 #23498254 未加载
评论 #23498189 未加载
评论 #23499750 未加载
Hamuko将近 5 年前
&gt;<i>Cargo defaults its optimization level to 3 for release builds, which optimizes the binary for speed. To instruct Cargo to optimize for minimal binary size, use the z optimization level in Cargo.toml</i><p>In what scenarios is optimizing for binary size preferred over optimizing for speed?
评论 #23498052 未加载
评论 #23498143 未加载
评论 #23497850 未加载
评论 #23497957 未加载
评论 #23499697 未加载
评论 #23497894 未加载
评论 #23497853 未加载
评论 #23501804 未加载
评论 #23501827 未加载
wyldfire将近 5 年前
What about `RUSTC_FLAGS=-Z opt=-Os` (this won&#x27;t work, I&#x27;m sure -- it is a total mishmash of things I&#x27;ve seen before but -Os is the relevant part). building your executable, your dependencies and&#x2F;or libstd w&#x2F;-Os could really pay off -- especially if you already have LTO enabled.
mkesper将近 5 年前
Not all of these should be used except when striving for absolute minimal sizes.
评论 #23497704 未加载
gutino将近 5 年前
Sadly there is not before after result example.
评论 #23501055 未加载
naetius将近 5 年前
I haven&#x27;t been following Rust&#x27;s development much lately, but I&#x27;m interested in understanding what&#x27;s the state of ABI stability...
评论 #23501371 未加载