Repository navigation
Fix linking issues when using multiple codegen units #53
Description
Activity
I've also seen cargo/xargo emit entirely empty binaries unless this property is set.
@thejpster with the cortex-m-rt linker script or with some other custom linker script? I have patched the cortex-m-rt linker script a few times to make it work with multiple codegen units but I wouldn't be surprised if there are still issues out there ...
This was with stellaris-launchpad, which had its own linker script dating back to my original C implementation. Would it be useful if we wrote up requirements for linker scripts somewhere, rather than relying on some magic in one example?
The empty binaries, on Windows, may be related to this bug under heavy load:
https://randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/@thejpster all the magic is documented in cortex-m-rt's linker script. All the symbols in that linker script are documented as well.
That is beautifully done, but I still wonder if it's worth pulling out into something that's more generic and not Cortex-M specific, to help people with other platforms and improve discoverability.
- added a commit that references this issue
on Mar 6, 2018 Tasks
Tweak rustc linking process to properly support multiple codegen units. The problem and
solution is described in rust-lang/rust#47074 (comment)PR rust-lang/rust#49316 should fix this. (merged)
Update: rust-lang/rust#49316 didn't quite fix this. See rust-lang/rust#49316 (comment).
Update: rust-lang/rust#49672 should fix this for real
Fixed in rust-lang/rust#49672. 🎉
To improve build times rustc is now defaulting to building crates using multiple codegen units. The
problem is that using multiple codegen units can sometimes break linking of no-std applications
("undefined reference to
rust_begin_unwind").We are looking for someone who can help us fix the problem in the compiler
Tasks
solution is described in Multiple codegen units breaks linking: "undefined reference to rust_begin_unwind" rust-lang/rust#47074 (comment)
The current workaround for this issue is to force the compiler to use a single codegen unit in
Cargo.toml