Remove the 'required-features' attribute from Cargo.toml to avoid potential issues with 'make vf2'#135
Open
PassingThroughStarDust wants to merge 4 commits intoStarry-OS:mainfrom
Open
Conversation
…ential issues when running 'make vf2'
Contributor
There was a problem hiding this comment.
Pull request overview
Removes the required-features gate from the starryos binary target so make vf2 (and other non-qemu builds) reliably produces a fresh starryos executable instead of failing to copy it or reusing a previously built artifact.
Changes:
- Remove
required-features = ["qemu"]from the[[bin]]target inCargo.toml.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Hi, we're moving our workflow to https://github.com/rcore-os/tgoskits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A slightly small change for Cargo.toml to avoid potential issues
There's a little bug with current Starry's Cargo.toml: if running
make buildand then runmake vf2, we will get a compiled binary but this binary cannot run on VisionFive2 board: board will stuck with no any output.I was trapped by this bug for a long time. I insisted that it was the problem with my own code. But in the end I discovered that it's a problem with the definition in Cargo.toml of recent commits. The following is my description of the problem:
Phenomenon 1: "make vf2" does not work for new cloned source code
According to the output, the
make vf2command failed because, although the Rust build completed successfully, the build system tried to copy an output file namedstarryosfrom the directorytarget/riscv64gc-unknown-none-elf/release/:but that file does not exist:
This caused the make process to stop with an error. The reason is that Rust build did not generate a binary named starryos in the expected location.
phenomenon 2: "make vf2" runs successfully if running "make build" beforehand but the generated binaries cannot run on VisionFive2
Although
make vf2executes successfully aftermake build, analyzing the headers ofStarryOS_visionfive2.elfreveals that it shares identical address metadata withStarryOS_riscv64-qemu-virt.elf.In fact,
StarryOS_riscv64-qemu-virt.elfis the same asStarryOS_visionfive2.elf. This indicating a bug: when runningmake vf2, Cargo used thestarryospreviously built to generateStarryOS_riscv64-qemu-virt.elfandStarryOS_riscv64-qemu-virt.bin. That's whyStarryOS_riscv64-qemu-virt.binon VisionFive2.Explanation to the above phenomenons
The issues mentioned above stem from this specific section of the Workspace's Cargo.toml file:
Line
required-features = ["qemu"]defines a restriction that binarystarryoswill only be generated when featureqemuis enabled. Therefore, when runmake vf2, althrough the compilation is successful,starryoswill not be generated, causing the operation to copystarrytoStarryOS_visionfive2.elffailed.However, if we run
make build, there'll be astarryos. If we then runmake vf2without cleaning the previous products, the copy operation will reuse thisstarryosto createStarryOS_visionfive2.elf. But thisStarryOS_visionfive2is essentially forriscv64-qemu-virtrather than forVisionFive2.Patch Advices
For current enviroment, using
required-featuresto restrict generation ofstarryosis unnecessary and may cause unexpected issues. It's better to deleterequired-features = ["qemu"]inCargo.tomlso bothmake buildandmake vf2can generate newstarryos. Patch is as follows: