From ecd304320be59388f7807ca097dd196ac92d415d Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Tue, 3 Nov 2026 14:29:11 +0000 Subject: [PATCH 1/6] Splits the rust version between host and guest so that they can evolve independently Signed-off-by: Simon Davies --- .github/workflows/cargo-publish.yml | 3 +- .github/workflows/dep_benchmarks.yml | 1 + .github/workflows/dep_build.yml | 4 ++- .github/workflows/npm-publish.yml | 4 ++- CONTRIBUTING.md | 15 ++++++++ Cargo.lock | 34 +++++++++++++++++-- Justfile | 18 +++++++--- rust-toolchain.toml | 4 +-- src/hyperlight-js-runtime/rust-toolchain.toml | 3 ++ src/hyperlight-js/Cargo.toml | 3 +- src/hyperlight-js/build.rs | 8 +++++ 11 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 src/hyperlight-js-runtime/rust-toolchain.toml diff --git a/.github/workflows/cargo-publish.yml b/.github/workflows/cargo-publish.yml index 50977a22..920dd224 100644 --- a/.github/workflows/cargo-publish.yml +++ b/.github/workflows/cargo-publish.yml @@ -49,6 +49,7 @@ jobs: - name: Hyperlight setup uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1 with: + additional-toolchain-directory: src/hyperlight-js-runtime just-version: "1.51" - name: Install cargo-overlay-registry @@ -100,7 +101,7 @@ jobs: -p hyperlight-js-runtime - name: Authenticate with crates.io - uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9 # v1 + uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1 id: crates-io-auth - name: Publish hyperlight-js-common diff --git a/.github/workflows/dep_benchmarks.yml b/.github/workflows/dep_benchmarks.yml index c82bd273..bd22cb49 100644 --- a/.github/workflows/dep_benchmarks.yml +++ b/.github/workflows/dep_benchmarks.yml @@ -59,6 +59,7 @@ jobs: - uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1 with: + additional-toolchain-directory: src/hyperlight-js-runtime just-version: "1.51" - name: Install github-cli (Azure Linux) diff --git a/.github/workflows/dep_build.yml b/.github/workflows/dep_build.yml index 78b90cbf..5f4239b3 100644 --- a/.github/workflows/dep_build.yml +++ b/.github/workflows/dep_build.yml @@ -111,6 +111,7 @@ jobs: - uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1 with: + additional-toolchain-directory: src/hyperlight-js-runtime just-version: "1.51" # Unlike upstream hyperlight, which builds its guests once per architecture @@ -123,10 +124,11 @@ jobs: # to /usr/bin/ar when llvm-ar is missing from PATH, which yields a guest # link with every QuickJS and libc symbol undefined. Prefer a provisioned # llvm-ar when the runner image supplies one; otherwise use the active Rust - # toolchain's llvm-tools component, installing it if necessary. + # guest toolchain's llvm-tools component, installing it if necessary. - name: Set up LLVM guest toolchain (macOS) if: runner.os == 'macOS' shell: bash + working-directory: src/hyperlight-js-runtime run: | set -euo pipefail if command -v llvm-ar >/dev/null 2>&1; then diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index e4efcf5f..3aca5c88 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -82,6 +82,7 @@ jobs: - name: Hyperlight setup uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1 with: + additional-toolchain-directory: src/hyperlight-js-runtime just-version: "1.51" - name: Setup Node.js @@ -97,10 +98,11 @@ jobs: # cannot produce ELF archives, and cargo-hyperlight silently falls back to # it when llvm-ar is absent from PATH, leaving every QuickJS and libc # symbol undefined at the guest link. Prefer a provisioned llvm-ar and - # fall back to the active Rust toolchain's llvm-tools component. + # fall back to the guest Rust toolchain's llvm-tools component. - name: Set up LLVM guest toolchain (macOS) if: runner.os == 'macOS' shell: bash + working-directory: src/hyperlight-js-runtime run: | set -euo pipefail if command -v llvm-ar >/dev/null 2>&1; then diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6a9c586..acad3047 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,3 +118,18 @@ For more detailed instructions on setting up GPG signing, see [GitHub's document ### Rust Analyzer If you are using the [Rust Analyzer](https://rust-analyzer.github.io/manual.html) then you may need to set the configuration option `rust-analyzer.rustfmt.extraArgs` to `["+nightly"]` to ensure that formatting works correctly as this project has a [`rustfmt.toml`](./rustfmt.toml) file that uses nightly features. + +### Rust Toolchains + +Host builds and tools use the root `rust-toolchain.toml`. The guest runtime +uses a separate toolchain pinned in +`src/hyperlight-js-runtime/rust-toolchain.toml`, allowing the host compiler to +advance independently of guest target support. + +Build with: + +```sh +just build +``` + +The build installs both toolchains and their required components automatically. diff --git a/Cargo.lock b/Cargo.lock index 6fc29b3b..9e84a65e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -333,8 +333,7 @@ checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" [[package]] name = "cargo-hyperlight" version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c52f1c9d4b6173aefb66fdc2e3e112ddb359fe2fbdbaafe1b9ba25f7ac578b39" +source = "git+https://github.com/hyperlight-dev/cargo-hyperlight?rev=5993b956fdcfd091a02ad3c3592baff67e0a2b9f#5993b956fdcfd091a02ad3c3592baff67e0a2b9f" dependencies = [ "anyhow", "clap", @@ -352,6 +351,7 @@ dependencies = [ "serde", "serde_json", "tempfile", + "toml", "which", ] @@ -3569,6 +3569,15 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_spanned" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +dependencies = [ + "serde_core", +] + [[package]] name = "sha2" version = "0.10.9" @@ -3934,6 +3943,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c96ecdfa941c8fc4fcaed14f99ada8ebed502eef533015095a07e3301d4c3c" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + [[package]] name = "toml_datetime" version = "1.1.1+spec-1.1.0" @@ -3964,6 +3988,12 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_writer" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" + [[package]] name = "tonic" version = "0.14.6" diff --git a/Justfile b/Justfile index 49e36211..dc659e69 100644 --- a/Justfile +++ b/Justfile @@ -24,8 +24,16 @@ export CMAKE_GENERATOR := if os() == "windows" { "Ninja" } else { "" } # host, so derive it rather than hardcoding x86_64. guest-target := arch() + "-hyperlight-none" -ensure-tools: - cargo install cargo-hyperlight --locked +# Temporary pin for guest toolchain selection: hyperlight-dev/cargo-hyperlight#83. +cargo-hyperlight-rev := "5993b956fdcfd091a02ad3c3592baff67e0a2b9f" + +# Install the host and guest toolchains and components from their pin files. +ensure-toolchains: + rustup toolchain install + cd src/hyperlight-js-runtime && rustup toolchain install + +ensure-tools: ensure-toolchains + cargo install cargo-hyperlight --git https://github.com/hyperlight-dev/cargo-hyperlight --rev {{ cargo-hyperlight-rev }} --locked # Check if npm is installed, install automatically if missing (Linux) [private] @@ -46,7 +54,7 @@ check-license-headers: ./dev/check-license-headers.sh clippy target=default-target features="": (ensure-tools) - cargo hyperlight clippy -p hyperlight-js-runtime \ + cd src/hyperlight-js-runtime && cargo hyperlight clippy -p hyperlight-js-runtime \ --target={{ guest-target }} \ --profile={{ if target == "debug" {"dev"} else { target } }} \ -- -D warnings @@ -113,11 +121,11 @@ build-trace target=default-target features="": (build-rust-trace target features build-native-runtime target=default-target: cargo build --manifest-path=./src/hyperlight-js-runtime/Cargo.toml --profile={{ if target == "debug" {"dev"} else { target } }} -build-rust target=default-target features="": +build-rust target=default-target features="": ensure-toolchains cd src/hyperlight-js && \ cargo build {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} -build-rust-trace target=default-target features="": +build-rust-trace target=default-target features="": ensure-toolchains cd src/hyperlight-js && \ cargo build {{ if features =="" {'-F trace_guest'} else if features=="no-default-features" {"--no-default-features -F trace_guest" } else {"--no-default-features -F trace_guest," + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 93d3914a..10427b94 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.90" -components = ["clippy", "llvm-tools", "rustfmt"] +channel = "1.99.1" +components = ["clippy", "rustfmt"] diff --git a/src/hyperlight-js-runtime/rust-toolchain.toml b/src/hyperlight-js-runtime/rust-toolchain.toml new file mode 100644 index 00000000..bad87574 --- /dev/null +++ b/src/hyperlight-js-runtime/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.90" +components = ["clippy", "llvm-tools", "rust-src"] \ No newline at end of file diff --git a/src/hyperlight-js/Cargo.toml b/src/hyperlight-js/Cargo.toml index 0edd16b8..ae00eab1 100644 --- a/src/hyperlight-js/Cargo.toml +++ b/src/hyperlight-js/Cargo.toml @@ -37,7 +37,8 @@ libc = { version = "0.2", optional = true } windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_System_Registry", "Win32_System_WindowsProgramming"], optional = true } [build-dependencies] -cargo-hyperlight = "0.1.14" +# Temporary pin for guest toolchain selection: hyperlight-dev/cargo-hyperlight#83. +cargo-hyperlight = { git = "https://github.com/hyperlight-dev/cargo-hyperlight", rev = "5993b956fdcfd091a02ad3c3592baff67e0a2b9f" } cfg_aliases = "0.2.1" serde_json = { version = "1.0" } diff --git a/src/hyperlight-js/build.rs b/src/hyperlight-js/build.rs index d86ca3f9..a80f69f3 100644 --- a/src/hyperlight-js/build.rs +++ b/src/hyperlight-js/build.rs @@ -232,8 +232,14 @@ fn build_js_runtime(custom: Option) -> PathBuf { println!("cargo:rerun-if-changed={}", include_dir.display()); // Forward slashes keep Clang's include path intact so it finds the ARM math shim. let cflags = format!("-I{} {QUICKJS_CFLAGS}", include_dir.display()).replace('\\', "/"); + + let toolchain_file = include_dir.with_file_name("rust-toolchain.toml"); + println!("cargo:rerun-if-changed={}", toolchain_file.display()); let mut cargo_cmd = cargo_hyperlight::cargo().unwrap(); + cargo_cmd + .toolchain_file(&toolchain_file) + .unwrap_or_else(|error| panic!("Could not select JS guest toolchain: {error:#}")); let cmd = cargo_cmd .arg(if is_custom { "rustc" } else { "build" }) .arg("--profile") @@ -250,6 +256,8 @@ fn build_js_runtime(custom: Option) -> PathBuf { .arg(&manifest_path) .arg("--locked") .env_clear_cargo() + // Host Clippy must not wrap the separately pinned guest compiler. + .env_remove("RUSTC_WORKSPACE_WRAPPER") .current_dir(runtime_dir) .env("HYPERLIGHT_CFLAGS", cflags); From e35e59c5ee7cd2f2b22d77a733ae2479a76e7150 Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Wed, 11 Nov 2026 16:38:30 +0000 Subject: [PATCH 2/6] update to new release of cargo hyperlight Signed-off-by: Simon Davies --- src/hyperlight-js/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hyperlight-js/Cargo.toml b/src/hyperlight-js/Cargo.toml index ae00eab1..5b426855 100644 --- a/src/hyperlight-js/Cargo.toml +++ b/src/hyperlight-js/Cargo.toml @@ -37,8 +37,7 @@ libc = { version = "0.2", optional = true } windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_System_Registry", "Win32_System_WindowsProgramming"], optional = true } [build-dependencies] -# Temporary pin for guest toolchain selection: hyperlight-dev/cargo-hyperlight#83. -cargo-hyperlight = { git = "https://github.com/hyperlight-dev/cargo-hyperlight", rev = "5993b956fdcfd091a02ad3c3592baff67e0a2b9f" } +cargo-hyperlight = = 0.1.15 cfg_aliases = "0.2.1" serde_json = { version = "1.0" } From 46296e2c2cf0f000a8452345bfa9b023a1a99a9c Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Wed, 11 Nov 2026 16:45:18 +0000 Subject: [PATCH 3/6] fix typo Signed-off-by: Simon Davies --- src/hyperlight-js/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyperlight-js/Cargo.toml b/src/hyperlight-js/Cargo.toml index 5b426855..81bda42c 100644 --- a/src/hyperlight-js/Cargo.toml +++ b/src/hyperlight-js/Cargo.toml @@ -37,7 +37,7 @@ libc = { version = "0.2", optional = true } windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_System_Registry", "Win32_System_WindowsProgramming"], optional = true } [build-dependencies] -cargo-hyperlight = = 0.1.15 +cargo-hyperlight = 0.1.15 cfg_aliases = "0.2.1" serde_json = { version = "1.0" } From 93b635de20f495b8899504ed249cd5611e475f2a Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Wed, 11 Nov 2026 17:10:52 +0000 Subject: [PATCH 4/6] fix another typo Signed-off-by: Simon Davies --- Cargo.lock | 9 +++++---- src/hyperlight-js/Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e84a65e..cc1114bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -332,8 +332,9 @@ checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" [[package]] name = "cargo-hyperlight" -version = "0.1.14" -source = "git+https://github.com/hyperlight-dev/cargo-hyperlight?rev=5993b956fdcfd091a02ad3c3592baff67e0a2b9f#5993b956fdcfd091a02ad3c3592baff67e0a2b9f" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cca0d3b8a8a79c7d55aecb3f68afe40675e70871ec7056f30fecee82cff1b877" dependencies = [ "anyhow", "clap", @@ -2520,9 +2521,9 @@ dependencies = [ [[package]] name = "object" -version = "0.39.1" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b" +checksum = "dd229a0361b9d0d4396176e02d65897f487eebeab7caa6d443855ee152ca0b9c" dependencies = [ "memchr", ] diff --git a/src/hyperlight-js/Cargo.toml b/src/hyperlight-js/Cargo.toml index 81bda42c..74e55b7c 100644 --- a/src/hyperlight-js/Cargo.toml +++ b/src/hyperlight-js/Cargo.toml @@ -37,7 +37,7 @@ libc = { version = "0.2", optional = true } windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_System_Threading", "Win32_System_Registry", "Win32_System_WindowsProgramming"], optional = true } [build-dependencies] -cargo-hyperlight = 0.1.15 +cargo-hyperlight = "0.1.15" cfg_aliases = "0.2.1" serde_json = { version = "1.0" } From d0c932e8f5a3b7a6fc2f6e005883148efa6acf19 Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Wed, 11 Nov 2026 20:24:30 +0000 Subject: [PATCH 5/6] fix fmt Signed-off-by: Simon Davies --- src/hyperlight-js/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hyperlight-js/build.rs b/src/hyperlight-js/build.rs index a80f69f3..5696d537 100644 --- a/src/hyperlight-js/build.rs +++ b/src/hyperlight-js/build.rs @@ -232,7 +232,7 @@ fn build_js_runtime(custom: Option) -> PathBuf { println!("cargo:rerun-if-changed={}", include_dir.display()); // Forward slashes keep Clang's include path intact so it finds the ARM math shim. let cflags = format!("-I{} {QUICKJS_CFLAGS}", include_dir.display()).replace('\\', "/"); - + let toolchain_file = include_dir.with_file_name("rust-toolchain.toml"); println!("cargo:rerun-if-changed={}", toolchain_file.display()); From 84464e3aedc9e15de3cbc7d58da1e1bc55b9246e Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Wed, 11 Nov 2026 21:59:01 +0000 Subject: [PATCH 6/6] remove git reference Signed-off-by: Simon Davies --- Justfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Justfile b/Justfile index dc659e69..d3c12a7f 100644 --- a/Justfile +++ b/Justfile @@ -24,16 +24,13 @@ export CMAKE_GENERATOR := if os() == "windows" { "Ninja" } else { "" } # host, so derive it rather than hardcoding x86_64. guest-target := arch() + "-hyperlight-none" -# Temporary pin for guest toolchain selection: hyperlight-dev/cargo-hyperlight#83. -cargo-hyperlight-rev := "5993b956fdcfd091a02ad3c3592baff67e0a2b9f" - # Install the host and guest toolchains and components from their pin files. ensure-toolchains: rustup toolchain install cd src/hyperlight-js-runtime && rustup toolchain install ensure-tools: ensure-toolchains - cargo install cargo-hyperlight --git https://github.com/hyperlight-dev/cargo-hyperlight --rev {{ cargo-hyperlight-rev }} --locked + cargo install cargo-hyperlight --locked # Check if npm is installed, install automatically if missing (Linux) [private]