Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linking issues when using multiple codegen units #53

Closed
1 task done
japaric opened this issue Feb 26, 2018 · 10 comments
Closed
1 task done

Fix linking issues when using multiple codegen units #53

japaric opened this issue Feb 26, 2018 · 10 comments

Comments

@japaric
Copy link
Member

japaric commented Feb 26, 2018

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

The current workaround for this issue is to force the compiler to use a single codegen unit in
Cargo.toml

# workaround rust-lang/rust#47074
[profile.dev]
codegen-units = 1
incremental = false
@thejpster
Copy link
Contributor

I've also seen cargo/xargo emit entirely empty binaries unless this property is set.

@japaric
Copy link
Member Author

japaric commented Feb 26, 2018

@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 ...

@thejpster
Copy link
Contributor

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?

@nunolucas
Copy link

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/

@japaric
Copy link
Member Author

japaric commented Feb 26, 2018

@thejpster all the magic is documented in cortex-m-rt's linker script. All the symbols in that linker script are documented as well.

@thejpster
Copy link
Contributor

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.

pierre-rouanet added a commit to pollen-robotics/stm32f0 that referenced this issue Mar 6, 2018
@japaric
Copy link
Member Author

japaric commented Mar 27, 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)

@japaric
Copy link
Member Author

japaric commented Apr 3, 2018

Update: rust-lang/rust#49316 didn't quite fix this. See rust-lang/rust#49316 (comment).

@japaric japaric added this to the 2018 edition milestone Apr 3, 2018
@japaric
Copy link
Member Author

japaric commented Apr 6, 2018

Update: rust-lang/rust#49672 should fix this for real

@japaric
Copy link
Member Author

japaric commented Apr 8, 2018

Fixed in rust-lang/rust#49672. 🎉

@japaric japaric closed this as completed Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants