Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jwnrt
Copy link
Contributor

@jwnrt jwnrt commented Jan 10, 2024

Pull Request Overview

This pull request consolidates all board build.rs scripts into a common boards/build.rs.

Currently, all build scripts are used to print cargo:rerun-if-changed=... lines for the link scripts that they use. Some are missing these lines for scripts that are included in layout.ld.

One build script (imxrt1050-evkb) was also tracking a hdr.s file, but as far as I can tell this file is not used so I have removed it.

The motivation for this change is to simplify the repo and make build.rs scripts less error prone (e.g. fixing the ones that miss rerun-if-changed lines). I also hope that having only one build.rs script will open Tock up to moving some configuration out of Makefiles to Cargo such that cargo build works (but make would likely still be used).

Apologies for another PR that touches loads of files :)

Testing Strategy

  1. Run make boards to make sure they all compile.
  2. Re-run make for a board to ensure it does not recompile.
  3. Touch the board's layout.ld and run make to check that it does recompile / relink.
  4. Touch kernel_layout.ld and run make to check that included files trigger recompilation too.

TODO or Help Wanted

If, in the future, boards need something else in their build.rs script, they will not be able to use this shared script. I think in that case the track_link_script function could be put in a tiny build-utils crate or similar and used by individual build scripts as a [build-dependency] in their custom build.rs scripts to avoid duplicating the code. Does that sound acceptable?

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

I only found build.rs references in doc/Compilation.md and doc/Porting.md`.

Formatting

  • Ran make prepush.

This file is unused as far as I can tell.
@github-actions github-actions bot added the WG-OpenTitan In the purview of the OpenTitan working group. label Jan 10, 2024
@jwnrt jwnrt force-pushed the common-build-script branch from ca47b9b to 3f39958 Compare January 10, 2024 15:24
Copy link
Contributor

@bradjc bradjc left a comment

Choose a reason for hiding this comment

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

I like that this is more principled in actually finding included linker scripts and declaring the dependency on all of them.

One reason we haven't gone to a communal build.rs is doing so adds a little bit of customization to Tock which isn't "normal" (i.e. it's different than how an arbitrary rust crate on github would look). This adds a bit of friction for new developers and for building on Tock.

That being said, I think this PR is a reasonable balance. It doesn't use symlinks or anything custom to find the build.rs file, it uses a documented feature of Cargo.toml. In exchange, we get a much better build.rs and less duplicated code.

I do think we need to update https://github.com/tock/tock/blob/master/doc/OutOfTree.md to discuss this change and what we recommend. Should users copy the new build.rs file? Or somehow point to it? Or just make their own? We have examples of out-of-tree boards in the tock org, specifically for the bootloader (ex: https://github.com/tock/tock-bootloader/tree/master/boards/wm1110_dev-bootloader).

@jwnrt jwnrt force-pushed the common-build-script branch 2 times, most recently from 048e840 to 82cf287 Compare January 10, 2024 16:49
@jwnrt
Copy link
Contributor Author

jwnrt commented Jan 10, 2024

I have updated doc/OutOfTree.md to include a link to the Tock submodule's build.rs file in the example it gives.

I see that tock-bootloader does use a custom build script. I haven't mentioned what to do in that case but at least by describing the script in the documentation, out-of-tree boards will know what to reproduce in their own build scripts.

Does that sound okay to you?

@jwnrt jwnrt requested a review from bradjc January 10, 2024 16:52
@jwnrt jwnrt force-pushed the common-build-script branch from 82cf287 to 5c73c09 Compare January 10, 2024 16:55
Copy link
Member

@lschuermann lschuermann left a comment

Choose a reason for hiding this comment

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

This is great.

@bradjc bradjc added the P-Significant This is a substancial change that requires review from all core developers. label Jan 16, 2024
@lschuermann lschuermann added the last-call Final review period for a pull request. label Jan 22, 2024
@lschuermann
Copy link
Member

Marking last call given we talked about it last Friday.

@lschuermann lschuermann added this pull request to the merge queue Jan 24, 2024
Merged via the queue into tock:master with commit d13107c Jan 24, 2024
@bradjc bradjc changed the title Common build script Common build.rs script Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
last-call Final review period for a pull request. P-Significant This is a substancial change that requires review from all core developers. WG-OpenTitan In the purview of the OpenTitan working group.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants