Skip to content
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

Rust update to 1.83 #4935

Merged
merged 16 commits into from
Dec 11, 2024
Merged

Conversation

ShadowCurse
Copy link
Contributor

@ShadowCurse ShadowCurse commented Nov 29, 2024

Also includes devctr updates for the following PRs:

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.98%. Comparing base (f90cc5c) to head (e4f6e5a).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/devices/virtio/queue.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4935      +/-   ##
==========================================
- Coverage   84.07%   83.98%   -0.10%     
==========================================
  Files         251      251              
  Lines       28059    27889     -170     
==========================================
- Hits        23592    23422     -170     
  Misses       4467     4467              
Flag Coverage Δ
5.10-c5n.metal 84.55% <97.05%> (-0.10%) ⬇️
5.10-m5n.metal 84.53% <97.05%> (-0.10%) ⬇️
5.10-m6a.metal 83.82% <97.05%> (-0.12%) ⬇️
5.10-m6g.metal 80.68% <97.05%> (-0.07%) ⬇️
5.10-m6i.metal 84.52% <97.05%> (-0.10%) ⬇️
5.10-m7g.metal 80.68% <97.05%> (-0.07%) ⬇️
6.1-c5n.metal 84.54% <97.05%> (-0.10%) ⬇️
6.1-m5n.metal 84.53% <97.05%> (-0.10%) ⬇️
6.1-m6a.metal 83.82% <97.05%> (-0.12%) ⬇️
6.1-m6g.metal 80.67% <97.05%> (-0.08%) ⬇️
6.1-m6i.metal 84.52% <97.05%> (-0.11%) ⬇️
6.1-m7g.metal 80.68% <97.05%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@roypat roypat changed the title Rust update to 1.82 Rust update to 1.83 Dec 9, 2024
@roypat roypat force-pushed the rust_update branch 6 times, most recently from dc26fbe to bb0e700 Compare December 10, 2024 14:25
Cargo.lock Show resolved Hide resolved
@roypat roypat force-pushed the rust_update branch 5 times, most recently from 66c8c8b to 0f1da0d Compare December 10, 2024 15:54
@roypat roypat marked this pull request as ready for review December 10, 2024 16:14
@roypat roypat added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Dec 10, 2024
roypat
roypat previously approved these changes Dec 10, 2024
Copy link
Contributor

@roypat roypat left a comment

Choose a reason for hiding this comment

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

egor says i can approve

tools/devctr/Dockerfile Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
ShadowCurse and others added 6 commits December 10, 2024 17:28
Update Rust to 1.83 version

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
From: Egor Lazarchuk <yegorlz@amazon.co.uk>

With a new Rust version, new Clippy entered our repository.
This commit aligns our codebase with guidance provided by
new lints.

Also remove a `deny(clippy::pedantic)`, because I'm not fixing those.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Co-authored-by: Patrick Roy <roypat@amazon.co.uk>
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
This is needed for CI to install previous version of the
toolchain used on the main branch. This change will need
to be reverted after this PR is merged.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Add the rust-src component and the $(uname -m)-unknown-linux-musl
targets for the nightly toolchain, and install python3-seccomp and
rustfilt. Since the python bindings for libseccomp are not published to
pip, we have to install it into the global python installation via
apt-get, and then copy into our venv.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Build static version of libseccomp with `musl-gcc`. This is needed for
our musl builds as the version shipped in the ubuntu package is not
compiled with `musl-gcc` and produces linker errors.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
From: Jonathan Woollett-Light <jcawl@amazon.co.uk>

Adds `cargo-udeps` and the Rust `nightly` toolchain to support it, to
dev container.

Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
Co-authored-by: Patrick Roy <roypat@amazon.co.uk>
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
These python dependencies are used for an upcoming PR about reusing SSH
connection in our SSH tests.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
accumulate all the dockerfile changes into a new devctr version

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
This is needed to work around a bug in `VmFd::create_device`, where
undefined behavior caused a miscompilation on newer rust toolchains.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
With the devctr's python dependencies update, we pulled in a new pylint
version, which has a new `too-many-positional-arguments` lint. Fixing
this would be a significant refactor, so just suppress it, as it seems
low-value.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
With newer rust toolchains, rust will SIGABRT if an already closed file
descriptor is closed in the the `Drop` implementation for `File`. This
also applies to creating `File`s with invalid file descriptors. Thus fix
tests that accidentally double-close fds, and remove those that
explicitly construct `File`s with invalid file descriptors (they are
redundant now anyway, because Rust would abort if this ever happened).

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
It seemingly finally got intelligent enough to realize we don't need all
these backslashes on the brackets.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
The unittests here rely on the cfg(not(test)) antipattern for mocking,
which new rust compiler interprets as the production version of the
structs being dead-code when running unittests.

Refactoring this to eliminate mocking is difficult, because fdt unit
tests rely on the mocks removing all host-specific information from the
cpu FDT nodes (particularly cache information, which in prod is read
from the host sysfs, but in test mode is some dummy mock values).

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
with new mdformat we no longer need to wrap level 2 headings in escaped
brackets, just normal brackets.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
Thanks to mdformat no longer escaping brackets everywhere, we can
simplify a regex.

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
@ShadowCurse ShadowCurse merged commit c8fa501 into firecracker-microvm:main Dec 11, 2024
5 of 7 checks passed
@ShadowCurse ShadowCurse deleted the rust_update branch December 11, 2024 12:12
@@ -98,8 +99,13 @@ RUN cd /tmp/poetry \
ENV VIRTUAL_ENV=$VENV
ENV PATH=$VENV/bin:$PATH

# apt-get installs it globally, to manually copy it into the venv
Copy link
Contributor

Choose a reason for hiding this comment

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

"to manually copy" -> "manually copy it so we can use it in the venv"

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yeah, I meant "so manually copy", not "to"

Comment on lines +150 to +152
# Install static version of libseccomp
#
Copy link
Contributor

@pb8o pb8o Dec 10, 2024

Choose a reason for hiding this comment

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

We should have a comment explaining why we need to compile it. The short answer I guess is a static library compiled with glibc is not usable by a musl toolchain, and needs to be compiled with musl.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ShadowCurse context on this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I'll add a comment about this in the #4910

Cargo.toml Show resolved Hide resolved
Comment on lines +519 to +522
# Running as root would have created some root-owned files under the build
# dir. Let's fix that.
cmd_fix_perms

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of scope but maybe we should run this always as part of run_devctr?

@@ -110,6 +116,10 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-too
&& cargo install --locked cargo-audit cargo-deny@0.16.1 grcov cargo-sort cargo-afl \
&& cargo install --locked kani-verifier && cargo kani setup \
\
&& NIGHTLY_TOOLCHAIN=$(rustup toolchain list | grep nightly | tr -d '\n') \
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think you don't need the tr -d

Copy link
Contributor

Choose a reason for hiding this comment

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

I do, otherwise the interpolation of $NIGHTLY_TOOLCHAIN into the cargo +(bla) install fails because of a newline in the middle

Copy link
Contributor

Choose a reason for hiding this comment

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

now that I'm thinking about it, maybe that was in python...

@@ -110,6 +116,10 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-too
&& cargo install --locked cargo-audit cargo-deny@0.16.1 grcov cargo-sort cargo-afl \
&& cargo install --locked kani-verifier && cargo kani setup \
\
&& NIGHTLY_TOOLCHAIN=$(rustup toolchain list | grep nightly | tr -d '\n') \
&& rustup component add rust-src --toolchain "$NIGHTLY_TOOLCHAIN" \
Copy link
Contributor

Choose a reason for hiding this comment

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

why is it needed? any rough estimate how much space it takes?

Copy link
Contributor

Choose a reason for hiding this comment

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

the static analysis thingy uses -Zbuild_std, to compile the standard library as non-PIE, and for that we need to have the source of the standard library around. Its 28.8MB

@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## \[Unreleased\]
## [Unreleased]
Copy link
Contributor

Choose a reason for hiding this comment

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

\o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants