Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

v0.4.0: with LLD support #64

Merged
merged 9 commits into from
Apr 9, 2018
Merged

v0.4.0: with LLD support #64

merged 9 commits into from
Apr 9, 2018

Conversation

japaric
Copy link
Member

@japaric japaric commented Apr 6, 2018

See commit messages for details about why this is a breaking change.

I personally think no longer requiring GNU LD / arm-none-eabi-binutils to build a Rust program is worth the breaking change.

So far this seems to work fine but I'll continue to test this locally.

This depends on rust-lang/rust#49728

@whitequark
Copy link
Contributor

Dropping stack overflow protection is kind of unfortunate but given that it required the custom linking step maybe it's good that it's gone. I think that a proper solution can be much more easily developed for lld than binutils, especially given that rustc ships a fork of lld now.

} > RAM AT > FLASH
/* NOTE(AT > FLASH) without this LLD v6 produces a binary that crashes OpenOCD whereas LLD v7
emits a ".rodata and .bss sections overlap" error ... This hacky workaround doesn't increase
the binary size AFAICT */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One drawback is this will make firmwares with really full flashes uncompilable. Do I understand it right that lld v7 doesn't require the workaround?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand it right that lld v7 doesn't require the workaround?

No, this also needed for the v7 I tested. Without the workaround linking with LLD fails with the error message in the comment; GNU LD can link the same program without errors and produces a binary that doesn't crash OpenOCD.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you going to look at the underlying lld bug? I don't yet use lld for my embedded development so I'm afraid you're in the better position here. I can review though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will at least submit a bug report. I have zero experience hacking LLVM :-).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, with arm-none-eabi-ld at least, this doesn't cause problems even when bss is larger than the entire flash space, everything works as it should (surprisingly?). I haven't tried with lld.

@therealprof
Copy link
Contributor

I just tested this with my microbit crate. Works fine with both arm-none-eabi-binutils and lld. Flash image size is identical, disk size with debugging symbols went down a bit and surprisingly lld produces slightly larger files on disk than GNU ld but that's nothing to worry about.

@japaric
Copy link
Member Author

japaric commented Apr 8, 2018

@whitequark

I think that a proper solution can be much more easily developed for lld than binutils, especially given that rustc ships a fork of lld now.

I think it's very unlikely that the Rust team will add features to rust fork of lld. They try to keep as few patches (that are not backports) as possible on top of upstream LLVM / LLD. I do agree that a LLD (linker script?) solution would be the ideal solution here.

japaric added 3 commits April 9, 2018 00:51
this commit adds LLD support by removing all INFO sections. LLD kind of supports INFO in the form of
NOLOAD but when the linker script contains NOLOAD sections LLD emits a binary with false `size`
information: for example, it reported a fake increase of 20KB in .text and a fake increase of 1KB in
.bss when compiling a program that only allocates a single Box.

As the INFO sections are gone we can no longer support the stack overflow protection added in #43 so
all the other related changes, like making _stack_start overridable, have been removed as well.
If you want to continue using stack overflow protection you can stick to v0.3.x.

As the .debug_gdb_scripts output section has been removed from the linker script these changes will
only reliably support both LD and LLD if/when rust-lang/rust#49728 lands.

closes #53
Minor version has been bumped to v0.4.0 so we can stop supporting them

This also drop the chrono dependency, which some people have been running into problems with.

closes #60
japaric added 5 commits April 9, 2018 00:53
it wasn't mean to be removed -- it's not related to the stack overflow protection stuff
they were leftover from rebasing

closes #31
@japaric
Copy link
Member Author

japaric commented Apr 8, 2018

As we are making a new version release I'm also removing the panic_fmt lang item and the abort-on-panic feature. rust-lang/rust#47074 has been fixed and #[panic_implementation] is around the corner so it seems a good time to remove them. Without them the user is expected to specify the panic behavior; they can do so using #[panic_implementation] or by depending on a panic crate.

@whitequark
Copy link
Contributor

I think it's very unlikely that the Rust team will add features to rust fork of lld. They try to keep as few patches (that are not backports) as possible on top of upstream LLVM / LLD. I do agree that a LLD (linker script?) solution would be the ideal solution here.

I mean that the features can be added upstream and then pulled to the rust fork of lld to avoid waiting for an LLVM release cycle, of course.

@japaric
Copy link
Member Author

japaric commented Apr 9, 2018

Alright, let's land this to get more real world testing.

@japaric japaric merged commit 518dbf6 into master Apr 9, 2018
@japaric japaric deleted the v4 branch April 9, 2018 21:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants