-
Notifications
You must be signed in to change notification settings - Fork 109
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
Make: add make tab
as an approach to build for multiple locations
#482
Conversation
Look, I can run multiple libtock-rs apps:
|
I like this design, in that it much more closely mirrors how we build apps in |
I think it would be to basically undo the changes to build.rs and allow for either the current version or this version. |
How does this not race if you try to build apps at different locations simultaneously? I.e. #366 |
I don't see anything happening simultaneously. My |
An external build system (i.e. that of a |
This might be a way to use different linker scripts for each flash/ram location: https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-argflag |
Hah—I can verify that flag works as-expected as I was just using it to debug linker issues over in the kernel :) Agree it's likely a better way to go. We have a standing TODO in the kernel makefile to move linker options out into carog/rust land once it becomes reasonable / sane — looks like that time has come. |
I added a new version in make. Maybe it is better? Seems easier to add new flash/ram addresses. I did try it with |
Same makefile, this time new build.rs. Turns out my previous change didn't actually work, and Then, we no longer need to be making new copies of layout.ld and can instead just point the linker to what script to use and where it is. So we do that. |
This breaks any app that depends on |
And wait... so if you build a library's examples If so, we should move the apps out of |
How do these apps get a linker file? They set
Yes. I'm pretty sure. If I understand correctly this is intended behavior the rust team voted on rust-lang/cargo#9554 (comment) |
In retrospect, Ti50 a poor choice of example, because they do specify However, the way an app would normally get a linker script is:
|
I deleted a comment of mine and GitHub closed the PR?! |
While I do like the elegance of this approach and how it works with cargo and build.rs, do you actually want apps to do this? The linker files are named based on platform names, which could be confusing if I just want the settings but am not, say, a microbit. But more importantly, changes to the kernel can mean the linker scripts upstream don't work, and then what to do? Can't send a PR because others may depend on that specific linker script. We ask all tock kernel boards to include a build.rs, why not libtock-rs apps? Ok, but you might ask: well, brad, if downstream apps want to build for all platforms, as this pr proposes, how are they going to do that?!? And that...is a good question. |
After looking through rust-lang/cargo#9554, I think the correct answer is:
I'm still trying to figure out whether we still have a race condition with this implementation -- possibly not? If so, this probably gives us a way to solve it, as we can change the name of the linker script per-location. |
Would the ld files move to that crate too? |
I think so. |
Ok, are we getting closer? Further away? Who knows! Anyway, there is now a build crate which provides a helper function that crates building libtock apps (such as the libtock crate itself) can use. Its lib.rs provides a helper function that chooses which linker script to use, or to create a new one and use that. Its build.rs file copies all of the linker scripts to its out dir, and then shares the out dir path via environment variables with the lib.rs file, which can then use it in the app's root main.rs. Is this ok? I'm not really sure. This means we no longer need any build.rs in the runtime crate. |
I did some make hacking and updated the makefile. Adding a new flash/ram target is now just adding one line like:
and it will automatically get built and included in the tab. I think this is something reasonable that external libtock rs apps could do. We may still want to split out the makefile to make it easier to include/copy, but that seems like something to do when we actually have an out-of-tree libtockrs to experiment with. |
I want to update the top level readme once we decide what we want to do. |
The switch to the new build crate also speeds up builds from where I started because we no longer have to re-build the runtime crate for each ram/flash/arch tuple. Only the libtock crate has to be built every time. |
Should we call the new build crate |
no need to specify target names manually
Instead of copying the linker script files into a directory that `no_auto_layout` can read, this includes `libtock_layout.ld` as a string in the `libtock_build_scripts` library and generates the per-platform linker script.
This updates all the Tock dependencies to latest `master`. There were some layout changes caused by tock/libtock-rs#482. Signed-off-by: Johnathan Van Why <[email protected]>
This updates all the Tock dependencies to latest `master`. There were some layout changes caused by tock/libtock-rs#482. Signed-off-by: Johnathan Van Why <[email protected]>
This updates all the Tock dependencies to latest `master`. There were some layout changes caused by tock/libtock-rs#482. Signed-off-by: Johnathan Van Why <[email protected]>
This updates all the Tock dependencies to latest `master`. There were some layout changes caused by tock/libtock-rs#482. Signed-off-by: Johnathan Van Why <[email protected]>
This updates all the Tock dependencies to latest `master` -- except for `elf2tab`, which was causing `tockloader` to crash. I'll debug that and send an updated PR in the future. `libtock_layout.ld` was relocated to a new crate in tock/libtock-rs#482. I removed the prompt-toolkit and wcwidth dependencies from `tockloader_requirements.txt` -- they seem to have been unnecessary all along. Signed-off-by: Johnathan Van Why <[email protected]>
This updates all the Tock dependencies to latest `master` -- except for `elf2tab`, which was causing `tockloader` to crash. I'll debug that and send an updated PR in the future. `libtock_layout.ld` was relocated to a new crate in tock/libtock-rs#482. I removed the prompt-toolkit and wcwidth dependencies from `tockloader_requirements.txt` -- they seem to have been unnecessary all along. Signed-off-by: Johnathan Van Why <[email protected]>
Rather than have build.rs use an existing linker file, this uses environment variables in the build.rs file to generate a linker script for building the app.
Building for a particular flash/ram address looks like:
Then I have a quick rule in
make tab
to generate an elf at a couple locations and then create a TAB with elf2tab.RFC
Thoughts?
This is useful for creating libtock-rs apps at multiple addresses so multiple apps can be loaded.