Skip to content

Cargo version check - #72

Merged
jprendes merged 2 commits into
hyperlight-dev:mainfrom
jprendes:cargo-version-check
Aug 20, 2026
Merged

Cargo version check#72
jprendes merged 2 commits into
hyperlight-dev:mainfrom
jprendes:cargo-version-check

Conversation

@jprendes

Copy link
Copy Markdown
Contributor

No description provided.

@jprendes
jprendes force-pushed the cargo-version-check branch 2 times, most recently from 55ab615 to 26a7867 Compare August 20, 2026 14:44
The hyperlight guest targets are described by a custom target
specification JSON file. Support for those was made unstable in Rust
1.95, so on a newer stable toolchain the build failed deep inside cargo
with an error that gave no hint about what to do about it.

Probe the toolchain instead of guessing from its version. Once the
target specification has been written to the sysroot, run
`rustc --sysroot <sysroot> --target <target> --print=cfg`, which forces
rustc to load it. If the plain invocation fails, retry with
`-Zunstable-options`; when that succeeds the requirement is recorded in
`Args::unstable_target_spec` and the flag is added to the RUSTFLAGS of
the sysroot, guest and C API builds, which is what makes nightly
toolchains work. If neither invocation succeeds, fail early and report
rustc's own diagnostic together with guidance on picking a usable
toolchain.

Asking the compiler is more accurate than comparing release numbers: it
distinguishes nightly from beta without hardcoding channel names, and it
will keep working if custom target specifications are stabilised again.

While here, propagate errors out of `main` instead of unwrapping them,
so a failure to spawn cargo prints the same tidy diagnostic as any other
error rather than a panic.

Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
@jprendes
jprendes force-pushed the cargo-version-check branch from 26a7867 to fa9d03b Compare August 20, 2026 15:21
Add a job that builds a guest with three toolchains and asserts the
outcome of each: 1.94, where custom target specifications are still
stable and the build must succeed; 1.95, the first release where they
became unstable and the build must be rejected up front with the
diagnostic that explains how to fix it; and nightly, where they are
available behind `-Zunstable-options` and the build must succeed again.

cargo-hyperlight itself is always built from the toolchain pinned in
rust-toolchain.toml, and only the guest build runs under the toolchain
being tested, so the job exercises the detection rather than whichever
compiler happened to build the tool.

Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
@jprendes
jprendes merged commit c29ab17 into hyperlight-dev:main Aug 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant