<p dir="auto">There are many instances where one concretely needs a statically linked executable (e.g. to avoid having to distribute a pile of Rust dynamic libraries, making deployment much simpler).</p>
<p dir="auto">The compiler currently offers no way to request that a compiled artefact is always statically linked against Rust crates (the only option is <code class="notranslate">-C prefer-dynamic</code> which isn't really a guarantee either). Since there's no way to force these things, working out why the static linking defaulting failed is very hard, especially with a non-trivial number of dependencies (since the error is almost certainly one of those dependencies coming only in <code class="notranslate">.so</code> format).</p>
<p dir="auto">If the compiler provided say, <code class="notranslate">-C statically-linked</code>, then a user can request that something is only statically linked and receive errors about exactly what is stopping this from happening, e.g. <code class="notranslate">crate syntax can only be found as a dynamic library</code>. Without this, the user has to search through all dependencies to find out what is breaking things.</p>
<p dir="auto">(Case study: I was working through a problem like this with <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/emk/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/emk">@emk</a> on IRC. After much discussion and <code class="notranslate">ldd</code> wrangling, we eventually tracked it down to a library which defines a procedural macro internally along with the rest of the functionality, i.e. introducing a dependency on libsyntax. It would be much easier if we can get the compiler to tell us this straight away.)</p>
<p dir="auto">Now that <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="20333474" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/9658" data-hovercard-type="pull_request" data-hovercard-url="/rust-lang/rust/pull/9658/hovercard" href="https://github.com/rust-lang/rust/pull/9658">#9658</a> has landed, libstd is buildable with both <code class="notranslate">-Z debug-info</code> and <code class="notranslate">-Z extra-debug-info</code>. It might be time to graduate these flags out of the experimental <code class="notranslate">-Z</code> zone.</p>