Skip to content

Fix linking issues when using multiple codegen units #53

Description

@japaric

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

Activity

  1. thejpster commented on Feb 26, 2018

    @thejpster
    Contributor

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

  2. japaric commented on Feb 26, 2018

    @japaric
    MemberAuthor

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

  3. thejpster commented on Feb 26, 2018

    @thejpster
    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?

  4. nunolucas commented on Feb 26, 2018

    @nunolucas

    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/

  5. japaric commented on Feb 26, 2018

    @japaric
    MemberAuthor

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

  6. thejpster commented on Feb 26, 2018

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

  7. japaric commented on Mar 27, 2018

    @japaric
    MemberAuthor

    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)

  8. japaric commented on Apr 3, 2018

    @japaric
    MemberAuthor

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

  9. added this to the 2018 edition milestone on Apr 3, 2018
  10. japaric commented on Apr 6, 2018

    @japaric
    MemberAuthor

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

  11. japaric commented on Apr 8, 2018

    @japaric
    MemberAuthor

    Fixed in rust-lang/rust#49672. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions