Skip to content

Visual Studio Code, rebuilt in Rust

Rust

build(terminal): install Zig for libghostty-vt and link ntdll

rokarturb0d098d078ce
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
index e27534bc34b..561ef94ceca 100644
--- a/.github/actions/setup/action.yml
+++ b/.github/actions/setup/action.yml
@@ -31,6 +31,26 @@ runs:
with:
toolchain: stable
components: clippy
+ - name: Zig 0.17.1
+ # libghostty-vt-sys's build.rs builds libghostty-vt with it.
+ shell: bash
+ run: |
+ case "$RUNNER_OS-$RUNNER_ARCH" in
+ macOS-ARM64) zig=zig-aarch64-macos-0.17.1.tar.xz sha=75f1bc7a1e9852f17ec9a0c1895f767c4ec56d46bc8a834920eece1d0359dd8d ;;
+ Linux-X64) zig=zig-x86_64-linux-0.17.1.tar.xz sha=3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a ;;
+ Linux-ARM64) zig=zig-aarch64-linux-0.17.1.tar.xz sha=a1546d5646eb184437918d6635ca6b762a0e889eac09cef720ee7a1ed3fe7795 ;;
+ Windows-X64) zig=zig-x86_64-windows-0.17.1.zip sha=b03f477a1943673e02aca0f570e8030dffd536ce1f45cbc4d3326ec31159562e ;;
+ Windows-ARM64) zig=zig-aarch64-windows-0.17.1.zip sha=4789895bdb1e312a2ea73b2a7c0a0cc8d2ab62ba6976e834a7c54cf443377c15 ;;
+ *) echo "::error::no Zig 0.17.1 archive for $RUNNER_OS-$RUNNER_ARCH"; exit 1 ;;
+ esac
+ curl -fsSL -o "$RUNNER_TEMP/$zig" "https://ziglang.org/download/0.17.1/$zig"
+ # macOS has shasum, not sha256sum.
+ echo "$sha $RUNNER_TEMP/$zig" | shasum -a 256 -c -
+ case "$zig" in
+ *.zip) unzip -q "$RUNNER_TEMP/$zig" -d "$RUNNER_TEMP"; dir=${zig%.zip} ;;
+ *) tar xJf "$RUNNER_TEMP/$zig" -C "$RUNNER_TEMP"; dir=${zig%.tar.xz} ;;
+ esac
+ echo "$RUNNER_TEMP/$dir" >> "$GITHUB_PATH"
# Saved on failure too: the Windows and Linux tests are red today and would otherwise rebuild from scratch each run.
# Saved from main only, as longbridge/gpui-component's CI does: five jobs' Rust and upstream caches pass the 10 GB
# repository limit, and a pull request's caches, scoped to its ref, would evict main's.
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index a3c3154a51f..ac94fa88100 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -39,6 +39,13 @@ jobs:
- uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
with:
toolchain: stable
+ - name: Zig 0.17.1
+ # Builds libghostty-vt (native/crates/ghostty_vt/build.rs).
+ run: |
+ curl -fsSL -o "$RUNNER_TEMP/zig.tar.xz" https://ziglang.org/download/0.17.1/zig-x86_64-linux-0.17.1.tar.xz
+ echo "3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a $RUNNER_TEMP/zig.tar.xz" | sha256sum -c -
+ tar xJf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP"
+ echo "$RUNNER_TEMP/zig-x86_64-linux-0.17.1" >> "$GITHUB_PATH"
- name: VS Code 1.148.0
# @vscode/ripgrep's postinstall downloads from the GitHub API, which answers 403 to runners without a token.
env:
diff --git a/README.md b/README.md
index b367f255e5a..9750a391cde 100644
--- a/README.md
+++ b/README.md
@@ -102,7 +102,7 @@ Counted from the agent session logs, each call once; cost at OpenRouter list pri
## Build
-Rust (stable), [Bun](https://bun.sh) 1.4.5 and Node.js 24:
+Rust (stable), [Bun](https://bun.sh) 1.4.5, Node.js 24 and [Zig](https://ziglang.org) 0.17 (it builds the terminal's libghostty-vt):
```sh
git clone --branch 1.148.0 --depth 1 https://github.com/microsoft/vscode upstream
diff --git a/native/crates/ghostty_vt/build.rs b/native/crates/ghostty_vt/build.rs
index a4799742469..9a44d4ab254 100644
--- a/native/crates/ghostty_vt/build.rs
+++ b/native/crates/ghostty_vt/build.rs
@@ -22,6 +22,9 @@ fn main() {
// Zig names the Windows static archive apart from the DLL's import library.
let name = if target.contains("windows") { "ghostty-vt-static" } else { "ghostty-vt" };
println!("cargo:rustc-link-lib=static={name}");
+ if target.contains("windows") {
+ println!("cargo:rustc-link-lib=dylib=ntdll");
+ }
}
fn build(target: &str) -> PathBuf {
diff --git a/port/tools/linux/Dockerfile b/port/tools/linux/Dockerfile
index 30060d34e21..c15433ac4fb 100644
--- a/port/tools/linux/Dockerfile
+++ b/port/tools/linux/Dockerfile
@@ -30,3 +30,15 @@ RUN arch=$(uname -m) \
&& echo "$sum /tmp/cargo-gc.tgz" | sha256sum -c - \
&& tar xzf /tmp/cargo-gc.tgz -C /usr/local/cargo/bin ./cargo-gc \
&& rm /tmp/cargo-gc.tgz
+
+# Zig builds libghostty-vt (native/crates/ghostty_vt/build.rs).
+RUN arch=$(uname -m) \
+ && case $arch in \
+ aarch64) sum=a1546d5646eb184437918d6635ca6b762a0e889eac09cef720ee7a1ed3fe7795 ;; \
+ x86_64) sum=3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a ;; \
+ esac \
+ && curl -fsSL -o /tmp/zig.tar.xz "https://ziglang.org/download/0.17.1/zig-$arch-linux-0.17.1.tar.xz" \
+ && echo "$sum /tmp/zig.tar.xz" | sha256sum -c - \
+ && tar xJf /tmp/zig.tar.xz -C /opt \
+ && ln -s /opt/zig-$arch-linux-0.17.1/zig /usr/local/bin/zig \
+ && rm /tmp/zig.tar.xz