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

Migrate code from cargo-xbuild to -Zbuild-std #835

Merged
merged 12 commits into from
Jul 17, 2020
Merged

Conversation

phil-opp
Copy link
Owner

@phil-opp phil-opp commented Jul 16, 2020

This pull request implements building using cargo's new build-std instead of using the cargo-xbuild crate.

To enable the build-std functionality, we set the unstable.build-std configuration key in the .cargo/config.toml file. This flag was introduced very recently in rust-lang/cargo#8393, so it only works on the latest nightlies. Unfortunately, rustfmt doesn't build on these nightlies yet, so you have to use rustup update nightly --force to install them (results in skipping the rustfmt component).

Functionality-wise, the build-std feature behaves almost identical to cargo-xbuild. The only difference is that it doesn't enable the mem feature of the compiler_builtins crate, which defines the memcpy, memset, etc operations. This is a known issue, which is hopefully fixed soon. Until then, we can work around it by adding a dependency on the rlibc crate. To ensure that this crate is linked even though it is not directly used, we need to add an extern crate rlibc statement to our main.rs.

After these changes, our kernel is buildable through a normal cargo build. The cargo run and cargo test commands will also work as expected, provided the latest bootimage version is used.

This PR additionally rewrites our CI script based on the GitHub Actions provided by the actions-rs organization. This makes Rust's error messages compatible with GitHubs annotations, so that any build errors and warnings are shown inline at the correct line.

The required changes to the blog post will be done in a separate follow-up PR.

phil-opp added 3 commits July 16, 2020 15:37
This gives use support for github's scoped annotations when there are errors or warnings.
@phil-opp phil-opp force-pushed the post-02-Zbuild-std branch from 9c500f9 to ffe1b6a Compare July 16, 2020 14:21
@phil-opp phil-opp force-pushed the post-02-Zbuild-std branch from e53020c to 263e852 Compare July 16, 2020 15:04
@phil-opp phil-opp added the relnotes "Release notes" – Notable changes that are rendered on the blog. label Jul 16, 2020
@phil-opp phil-opp merged commit 4bbaae2 into post-02 Jul 17, 2020
@phil-opp phil-opp deleted the post-02-Zbuild-std branch July 17, 2020 09:13
@phil-opp
Copy link
Owner Author

The additional changes required to the other post-x branches after merging this PR were minimal, so I pushed them directly.

@phil-opp phil-opp changed the title Migrate post-02 code from cargo-xbuild to -Zbuild-std Migrate code from cargo-xbuild to -Zbuild-std Jul 17, 2020
@phil-opp
Copy link
Owner Author

I submitted #836 to update the blog posts for these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes "Release notes" – Notable changes that are rendered on the blog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant