-
Notifications
You must be signed in to change notification settings - Fork 703
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
Use LLVM LLD linker #993
Use LLVM LLD linker #993
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice notion to lessen toolchains required, but I don't think LLD is ready for primetime yet :/
@@ -226,7 +216,7 @@ SECTIONS | |||
|
|||
. = ALIGN(4); | |||
_erelocate = .; | |||
} > ram AT > rom | |||
} > ram |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a regression too, and a pretty serious one. This syntax ensures that this section is charged to both the ram
and rom
sections. The AT
syntax simply places it there without accounting for size. This silent failure was the root cause of a pretty awful to track down signpost bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AT > rom
doesn't seem to work with lld. Instead, I added an assert to the bottom of the linker script. Take a look and see if that would also catch the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested, but shouldn't that be < LENGTH(rom)
not > LENGTH(rom)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only compiles this way.
boards/hail/src/main.rs
Outdated
/// stack. | ||
#[no_mangle] | ||
#[link_section = ".stack_buffer"] | ||
pub static mut STACK_MEMORY: [u8; 0x1000] = [0; 0x1000]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm generally adverse to having the same information duplicated in two places. Is the STACK_SIZE
variable in the linker script still used with this approach or could it possible be dropped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
boards/hail/chip_layout.ld
Outdated
{ | ||
rom (rx) : ORIGIN = 0x00010000, LENGTH = 0x00020000 | ||
prog (rx) : ORIGIN = 0x00030000, LENGTH = 0x00040000 | ||
ccfg (rx) : ORIGIN = 0, LENGTH = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little wary of the copy/paste that this introduces here. i.e. the ccfg
section doesn't really make sense to be in the hail memory map at all? Granted it was there in the general case, but that's hidden away. Now that it's in the "hail-specific" file, it's odd to see it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that can be removed from boards that do not use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove the ccfg
definition here, does this part of the linker file cause problems?
.ccfg : {
KEEP(*(.ccfg))
} > ccfg
Or does it just silently ignore undefined, empty things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem to mind.
boards/hail/chip_layout.ld
Outdated
@@ -7,3 +8,11 @@ RAM_ORIGIN = 0x20000000; | |||
RAM_LENGTH = 0x00020000; | |||
|
|||
MPU_MIN_ALIGN = 8K; | |||
|
|||
MEMORY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we do this we can kill off all the variables above too. Doesn't look like they're used anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gone.
While I appreciate @ppannuto's concerns, I find it suspicious we wouldn't be able to link the kernel with LLD, given that the much more complicated libtock-rs userland is linked with LLD---it's just a fairly straight forward linking process that's only somewhat complicated due to our build system helping avoid duplication across boards. My question is how to best stress test this. One option is to merge, see if/how it starts breaking for people before the next release, and fix or revert before then. Another option, would be to somehow test rigorously before merging. I'm personally more sympathetic to merging and fixing, since I suspect this is probably pretty close. |
I would like to test this, especially the region size stuff.
I’m out of country till Friday. I’d like to leave a block till Monday
night, assuming I can look at it on Monday or I’ll get out of the way of
progress if I don’t get to it by Monday night and fix anything later
…On Tue, Jun 19, 2018 at 2:34 PM Amit Levy ***@***.***> wrote:
While I appreciate @ppannuto <https://github.com/ppannuto>'s concerns, I
find it suspicious we wouldn't be able to link the kernel with LLD, given
that the much more complicated libtock-rs userland is linked with
LLD---it's just a fairly straight forward linking process that's only
somewhat complicated due to our build system helping avoid duplication
across boards.
My question is how to best stress test this. One option is to merge, see
if/how it starts breaking for people before the next release, and fix or
revert before then. Another option, would be to somehow test rigorously
before merging. I'm personally more sympathetic to merging and fixing,
since I *suspect* this is probably pretty close.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#993 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAUt3sf5nlSaD3a9ca8TCWsUzhiEdo22ks5t-QvygaJpZM4UnCTQ>
.
|
This switches the build system to use the LLVM linker (lld) that ships with rust rather than arm-none-eabi-gcc.
Variables do not work the same as in gnu ld, so we have to include the `MEMORY` section directly in each board's linker file.
Testing is good. I just updated so that all boards now use this. Also I was totally wrong about the |
Pull Request Overview
This pull request changes the build system to use LLVM LLD rather than GNU LD as the linker.
In theory this is a very minor change. In practice, two things are different:
The
MEMORY
command in the linker file does not work with variables. Therefore, each platform will have to define its own memory section. I have done this for hail, and can apply it more broadly if everyone is cool with this PR.Simply doing
. = . + STACK_SIZE;
is no longer a valid way to set up the.stack
section so that it is the correct size. The resulting .elf has a .stack section which is the correct length, but the next section (.relocate) is placed on top of it (i.e. it is at the same address). I have found two workarounds for this, the first is to use 512QUAD(0x00)
statements in the linker file to fill the space. This kinda works, in that it makes the .stack section the correct size, but for some reason the resulting .bin file becomes 512MB so the kernel doesn't actually work. The other solution is the one in this PR: make a dummy array in rust and then assign it to the section.The faulty .elf:
The workaround is a little unfortunate, but maybe either I am missing something or LLD 7.0 will fix this.
Testing Strategy
This pull request was tested by running hail on hail.
TODO or Help Wanted
This pull request still needs to be updated for all other boards.
Also, I think this is worth it to get to fewer dependencies and better exist in the rust ecosystem, but others may have different thoughts.
Documentation Updated
/docs
, or no updates are required.Formatting
make formatall
.