<p dir="auto">For example, given an empty lib.rs, this happens:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc --lib lib.rs &amp; rustc --rlib lib.rs
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib' '-o' 'liblib-9ed81b85-0.0.so' 'lib.o' 'lib.metadata.o' '-Wl,--as-needed' '-L/tmp/.rust' '-L/tmp' '-L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib' '-lstd-04ff901e-0.9-pre' '-lrt' '-ldl' '-lm' '-lpthread' '-lstdc++' '-shared' '-lmorestack' '-Wl,-rpath,$ORIGIN/../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib'
note: /usr/bin/ld: reopening lib.o: No such file or directory

/usr/bin/ld: final link failed: No such file or directory
collect2: error: ld returned 1 exit status

error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /home/siege/src/rust2/src/libsyntax/diagnostic.rs:102
task '&lt;main&gt;' failed at 'explicit failure', /home/siege/src/rust2/src/librustc/lib.rs:398"><pre class="notranslate"><code class="notranslate">rustc --lib lib.rs &amp; rustc --rlib lib.rs
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib' '-o' 'liblib-9ed81b85-0.0.so' 'lib.o' 'lib.metadata.o' '-Wl,--as-needed' '-L/tmp/.rust' '-L/tmp' '-L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib' '-lstd-04ff901e-0.9-pre' '-lrt' '-ldl' '-lm' '-lpthread' '-lstdc++' '-shared' '-lmorestack' '-Wl,-rpath,$ORIGIN/../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib'
note: /usr/bin/ld: reopening lib.o: No such file or directory

/usr/bin/ld: final link failed: No such file or directory
collect2: error: ld returned 1 exit status

error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /home/siege/src/rust2/src/libsyntax/diagnostic.rs:102
task '&lt;main&gt;' failed at 'explicit failure', /home/siege/src/rust2/src/librustc/lib.rs:398
</code></pre></div>
<p dir="auto">This could be fixed in two main ways.</p>
<ol dir="auto">
<li>Add an option (e.g. <code class="notranslate">--temps-path</code>) to store the intermediates in a specific location</li>
<li>Add some kind of hash to the names of the intermediates to stop them from colliding. Can't just be the pkgid hash, as it'd still fail the above test.</li>
</ol>
<p dir="auto">This change to using <code class="notranslate">#[pkgid]</code> is causing a serious problem. Library names are now completely different. And I don't mean the hash. I mean the actual name on-disk. Not only that, but libraries without a <code class="notranslate">#[pkgid]</code> will potentially be named completely incorrectly and collide on-disk.</p>
<p dir="auto">The library name on disk is <code class="notranslate">lib&lt;name&gt;-&lt;hash&gt;...</code>. Previously, <code class="notranslate">&lt;name&gt;</code> came from the link args, so <code class="notranslate">#[link(name="foo")];</code> produced <code class="notranslate">libfoo-&lt;hash&gt;...</code>. Now, it's apparently based off of the last path component of the <code class="notranslate">#[pkgid]</code>. So if my library doesn't have a <code class="notranslate">#[pkgid]</code>, and the root file is named <code class="notranslate">lib.rs</code>, then I'll end up with <code class="notranslate">liblib-&lt;hash&gt;...</code>. And since the hash is also based off of the <code class="notranslate">#[pkgid]</code>, then every single non-<code class="notranslate">#[pkgid]</code> library with the same root source file will result in the same full filename (as both the library name and the hash are identical). That's really bad.</p>
<p dir="auto">If I go ahead and add a <code class="notranslate">#[pkgid]</code>, and use the recommended approach of using my github path as the pkgid, then I end up with a library that's potentially named incorrectly. For example, my <a href="https://github.com/kballard/rust-lua">github.com/kballard/rust-lua</a> library wants to produce <code class="notranslate">liblua-&lt;hash&gt;...</code> but instead with the <code class="notranslate">#[pkgid]</code> it's now <code class="notranslate">librust-lua-&lt;hash&gt;...</code>.</p>