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 a Cargo workspace to make builds reproducible and speed up CI. #1714
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.
I think this is something we have wanted for a while.
I'm trying to understand what's wrong with Netlify. The current build-all-docs.sh tool is expecting a I also hit the following warnings when running
|
this breaks the memory/flash reporting tool as well, I can try to push a fix for that by tomorrow |
I managed to find a workaround. However, the Travis-CI logs show the following "bad credentials" errors, and indeed I don't see any reports here.
|
…d cache across boards.
Another advantage of the Cargo workspace is that there can be a single build cache across boards, e.g. for common libraries such as the kernel, capsules, etc. This means that the kernel can be compiled just once (per CPU architecture) when running However, because Cargo looks at all the compilation flags (including those passed in I refactored (0c0f4df) the Makefile to use Following are some benchmarks showing the latency in running Before this pull request:
With a workspace, but before isolating per-board linker flags in
After:
|
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.
What happens if someone creates a new crate but doesn't update the root Cargo.toml? Will something tell them they forgot?
Yes :) For example, if I remove
|
I've solved the merge conflicts. A few notes for the last-call:
Regarding Clippy, I noticed that running the script as |
That sounds good to me. Hopefully we can remove the arty_e21 crates soon once more risc-v hardware is available.
Yeah, fixing clippy lints is a lot of work so I only tried on some crates. That is definitely a work in progress / experiment to see if it is useful. |
6f6911c
bors r+ |
Build succeeded |
The root cargo workspace was created in PR tock#1714. tock#1714's description asked the question "Should `tools/` also be part of the workspace? Have their own workspace?", which doesn't appear to have been answered. The PR ultimately excluded `tools/` from the root workspace. I think `tools/` would benefit from being in a cargo workspace. Because the root workspace specifies compilation profiles that are tuned for embedded code, I decided to make a second workspace for `tools/`. I am open to making `tools/` part of the root workspace if that's what you would prefer.
3341: Make `tools/` a cargo workspace. r=hudson-ayers a=jrvanwhy ### Pull Request Overview The root cargo workspace was created in PR #1714. #1714's description asked the question "Should `tools/` also be part of the workspace? Have their own workspace?", which doesn't appear to have been answered. This PR makes `tools/` its own cargo workspace. ### Testing Strategy Ran `cargo check --workspace --exclude litex-ci-runner` in `tools/` (I excluded `litex-ci-runner` as it requires a dependency I don't have installed). Ran `cargo check` in the root of the repository. Ran `make prepush`. ### Open Questions Do we want to make `tools/` part of the root workspace rather than making it its own workspace? I made it a separate workspace because the compilation profiles in the root workspace are intended for embedded code, whereas `tools/` is host-side code, but I'm open to making it all one workspace. Building host-side tools with embedded profiles will make things a bit slower but shouldn't break anything (unless something relies on panic unwinding). ### Documentation Updated - [X] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [X] Ran `make prepush`. Co-authored-by: Johnathan Van Why <jrvanwhy@google.com>
Pull Request Overview
This pull request adds a Cargo workspace at the top-level directory to make build reproducible (see the analysis in #1666 (comment)).
With a workspace, Cargo now only writes to a single
target/
directory in the root folder, instead of having a separatetarget/
in each board. This means that some changes have to be made in the Makefiles and tools.Another benefit of a single workspace is that shared dependencies can be built once (per CPU architecture) and cached across boards. For example, the kernel or the capsules only need to be compiled once per CPU architecture, instead of once per board, which can significantly speed up commands like
make allboards
.Testing Strategy
This pull request was tested by:
/path/to/tock
and/path/to/tock2
), and runningmake allboards
, checking that the SHA-256 checksum match.make flash
in the nRF52840-DK board's folder, and checking that flashing the kernel worked properly.TODO or Help Wanted
This pull request still needs:
target/
folder allows to greatly simplify thetools/build-all-docs.sh
script. I checked the output on a few files and it looks consistent, but some pages might break. On the other hand, some crates such as the arty_e21 board are currently not indexed on the navigation bar, and thearty_e21
chip was not even documented so far on https://docs.tockos.org/.For now I made just enough changes inboards/Makefile.common
formake ci-travis
to work, but other make rules should be checked.tools/
still work properly with a single target folder now at the top-level.build-all-docs.sh
Simplified, as mentioned above, now that all docs are built in the same folder.post_size_changes_to_github.sh
Updated, but it's currently broken for other reasons (see stop running size reporting script in travis #1722).I had to remove thetools/check_wildcard_imports.sh
inmake ci-travis
because otherwise it reported the following error. The tool would need some refactoring.[profile.dev]
and[profile.release]
rules must be in the top-level workspace. I put them there given that all boards had the same profiles, but it's something to keep in mind if we want to use custom workspace for specific boards. I'm also not sure what's the impact of these profiles on the other libraries in the workspace. This didn't seem to cause any issue though.tools/
also be part of the workspace? Have their own workspace?Documentation Updated
/docs
, or no updates are required. Now the arty-e21 chip and board appear in the generated docs :)Formatting
make formatall
.