-
Notifications
You must be signed in to change notification settings - Fork 98
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
Build rust stdlib #1265
Build rust stdlib #1265
Conversation
08e70e9
to
f6c597b
Compare
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.
Tested and works nicely, saving 50424 bytes in the Multi firmware binary 🎉
src/rust/vendor-rust-std.sh
Outdated
# Copy the Cargo.lock for Rust to place the `cargo vendor` will see | ||
# cp "$RUST_DIR/lib/rustlib/src/rust/Cargo.lock" "$RUST_DIR/lib/rustlib/src/rust/library/test/" | ||
# chmod 777 $RUST_DIR/lib/rustlib/src/rust/library/test/Cargo.lock |
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 am not sure what this means. I just ran this script inside docker and it seemed to work.
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.
Ok I see now that these are needed, but:
Why not uncomment and run them automatically?
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 moved the commands to the dockerfile
src/rust/vendor-rust-std.sh
Outdated
@@ -0,0 +1,12 @@ | |||
RUST_DIR="$(rustc --print=sysroot)" |
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.
The name of the script sounds like it vendors only the stdlib, but it vendors all our normal deps too and should be used instead of cargo vendor
, right?
Maybe rename the script and add a section to src/rust/README.md about how to vendor.
👍
|
src/rust/vendor-rust-std.sh
Outdated
|
||
RUSTC_BOOTSTRAP=1 cargo vendor \ | ||
--manifest-path Cargo.toml \ | ||
--sync "$RUST_DIR/lib/rustlib/src/rust/library/test/Cargo.toml" \ |
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.
Could you add a comment why it's this Cargo.toml? /test/
sounds wrong, so it could help to add some sort of reference.
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 wrote a comment, for some reason Cargo needs to see the dependencies of test
. And since test
depends on all the other crates it is enough to bring in the dependencies of it.
8c200c1
to
02757c4
Compare
77def58
to
6864311
Compare
I found yet another flag to reduce the size of
|
6864311
to
13248c9
Compare
Compared to before this, firmware.bin is now 472 bytes smaller. One would expect more for such a promising-sounding flag 😂 |
Perhaps it has a bigger impact on |
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.
tACK, very nice 😍
src/rust/vendor.sh
Outdated
# | ||
# The invocation below depends on the fact that rust std libs "Cargo.lock" has | ||
# been manually copied to be next to the Cargo.toml file in the test | ||
# directory. |
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.
Maybe mention here that the Dockerfile is doing that.
7c8fe25
to
33c4a29
Compare
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.
Thanks! Please amend the commits in a way where each commit can build. Could just squash all into one.
ca1a0b1
to
684593a
Compare
This commit creates a script `vendor.sh` that can be used to vendor our dependencies from crates.io. In addition to vendoring the direct dependencies of our rust crates, it also vendors the dependencies of the rust standard libraries. This script requires a minor update to the Dockerfile because we need to install the sources of the rust standard libraries and copy a file when we are the "root" user.
684593a
to
b09c333
Compare
OK, now I'm pretty sure every commit passes |
No need I think, the commits look good! Thanks. |
Building the rust core and alloc libraries ourselves with abort as panic handler reduced the memory footprint from
to
To test this you need to rebuild the docker build container.