Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cargo-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Hyperlight setup
uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1
with:
rust-toolchain: "1.90"
additional-toolchain-directory: src/hyperlight-js-runtime
just-version: "1.51"

- name: Install cargo-overlay-registry
Expand Down Expand Up @@ -101,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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dep_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

- uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1
with:
rust-toolchain: "1.90"
additional-toolchain-directory: src/hyperlight-js-runtime
just-version: "1.51"

- name: Install github-cli (Azure Linux)
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/dep_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:

- uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1
with:
rust-toolchain: "1.90"
additional-toolchain-directory: src/hyperlight-js-runtime
just-version: "1.51"

# Unlike upstream hyperlight, which builds its guests once per architecture
Expand All @@ -104,10 +104,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
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Hyperlight setup
uses: hyperlight-dev/ci-setup-workflow@59673866360458f8dd035f4a9fa766aeebad2038 # v2.3.1
with:
rust-toolchain: "1.90"
additional-toolchain-directory: src/hyperlight-js-runtime
just-version: "1.51"

- name: Setup Node.js
Expand All @@ -94,10 +94,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
Expand Down
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
34 changes: 32 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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 } }}

Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.90"
components = ["clippy", "llvm-tools", "rustfmt"]
channel = "1.99.1"
components = ["clippy", "rustfmt"]
3 changes: 3 additions & 0 deletions src/hyperlight-js-runtime/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.90"
components = ["clippy", "llvm-tools", "rust-src"]
3 changes: 2 additions & 1 deletion src/hyperlight-js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
7 changes: 7 additions & 0 deletions src/hyperlight-js/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,14 @@ fn build_js_runtime(custom: Option<PathBuf>) -> PathBuf {
.canonicalize()
.expect("hyperlight-js-runtime include directory not found");
println!("cargo:rerun-if-changed={}", include_dir.display());
let toolchain_file = include_dir.with_file_name("rust-toolchain.toml");
println!("cargo:rerun-if-changed={}", toolchain_file.display());
let cflags = format!("-I{} {QUICKJS_CFLAGS}", include_dir.display()).replace("\\", "\\\\");

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")
Expand All @@ -249,6 +254,8 @@ fn build_js_runtime(custom: Option<PathBuf>) -> 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);

Expand Down
Loading