objdiff-wasm build improvements

This commit is contained in:
Luke Street 2025-08-30 12:42:14 -06:00
parent 48804dc2e3
commit 84079c3934
12 changed files with 72 additions and 56 deletions

View File

@ -36,9 +36,9 @@ jobs:
- name: Cache Rust workspace - name: Cache Rust workspace
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Cargo check - name: Cargo check
run: cargo check --all-targets --all-features run: cargo check --all-targets --all-features --workspace
- name: Cargo clippy - name: Cargo clippy
run: cargo clippy --all-targets --all-features run: cargo clippy --all-targets --all-features --workspace
fmt: fmt:
name: Format name: Format
@ -92,7 +92,7 @@ jobs:
- name: Cache Rust workspace - name: Cache Rust workspace
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Cargo test - name: Cargo test
run: cargo test --release --features all run: cargo test --release --all-features --workspace
build-cli: build-cli:
name: Build objdiff-cli name: Build objdiff-cli

View File

@ -24,7 +24,7 @@ repos:
description: Run cargo clippy on all project files. description: Run cargo clippy on all project files.
language: system language: system
entry: cargo entry: cargo
args: ["+nightly", "clippy", "--all-targets", "--all-features"] args: ["+nightly", "clippy", "--all-targets", "--all-features", "--workspace"]
pass_filenames: false pass_filenames: false
- id: cargo-deny - id: cargo-deny
name: cargo deny name: cargo deny

50
Cargo.lock generated
View File

@ -3436,7 +3436,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-cli" name = "objdiff-cli"
version = "3.0.0" version = "3.0.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"argp", "argp",
@ -3459,7 +3459,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-core" name = "objdiff-core"
version = "3.0.0" version = "3.0.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arm-attr", "arm-attr",
@ -3514,7 +3514,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-gui" name = "objdiff-gui"
version = "3.0.0" version = "3.0.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"argp", "argp",
@ -3551,7 +3551,7 @@ dependencies = [
[[package]] [[package]]
name = "objdiff-wasm" name = "objdiff-wasm"
version = "3.0.0" version = "3.0.1"
dependencies = [ dependencies = [
"log", "log",
"objdiff-core", "objdiff-core",
@ -5863,9 +5863,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-encoder" name = "wasm-encoder"
version = "0.235.0" version = "0.236.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3bc393c395cb621367ff02d854179882b9a351b4e0c93d1397e6090b53a5c2a" checksum = "724fccfd4f3c24b7e589d333fc0429c68042897a7e8a5f8694f31792471841e7"
dependencies = [ dependencies = [
"leb128fmt", "leb128fmt",
"wasmparser", "wasmparser",
@ -5873,9 +5873,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-metadata" name = "wasm-metadata"
version = "0.235.0" version = "0.236.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b055604ba04189d54b8c0ab2c2fc98848f208e103882d5c0b984f045d5ea4d20" checksum = "c909f94a49a8de3365f3c0344f064818f1e369ff1740c5b04f455f85d454768e"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"indexmap", "indexmap",
@ -5898,9 +5898,9 @@ dependencies = [
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.235.0" version = "0.236.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "161296c618fa2d63f6ed5fffd1112937e803cb9ec71b32b01a76321555660917" checksum = "a9b1e81f3eb254cf7404a82cee6926a4a3ccc5aad80cc3d43608a070c67aa1d7"
dependencies = [ dependencies = [
"bitflags 2.9.1", "bitflags 2.9.1",
"hashbrown", "hashbrown",
@ -6726,19 +6726,19 @@ dependencies = [
[[package]] [[package]]
name = "wit-bindgen" name = "wit-bindgen"
version = "0.43.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a18712ff1ec5bd09da500fe1e91dec11256b310da0ff33f8b4ec92b927cf0c6" checksum = "04bd9ed271234163b18c92783b0d406f08ca32c232e972f207a68c7b324c44bf"
dependencies = [ dependencies = [
"wit-bindgen-rt 0.43.0", "wit-bindgen-rt 0.44.0",
"wit-bindgen-rust-macro", "wit-bindgen-rust-macro",
] ]
[[package]] [[package]]
name = "wit-bindgen-core" name = "wit-bindgen-core"
version = "0.43.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c53468e077362201de11999c85c07c36e12048a990a3e0d69da2bd61da355d0" checksum = "b4103c7a3e178b75cd8b0b574fa199ed015e8399c9859b003865cc28834b474b"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"heck", "heck",
@ -6756,18 +6756,18 @@ dependencies = [
[[package]] [[package]]
name = "wit-bindgen-rt" name = "wit-bindgen-rt"
version = "0.43.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fd734226eac1fd7c450956964e3a9094c9cee65e9dafdf126feef8c0096db65" checksum = "653c85dd7aee6fe6f4bded0d242406deadae9819029ce6f7d258c920c384358a"
dependencies = [ dependencies = [
"bitflags 2.9.1", "bitflags 2.9.1",
] ]
[[package]] [[package]]
name = "wit-bindgen-rust" name = "wit-bindgen-rust"
version = "0.43.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "531ebfcec48e56473805285febdb450e270fa75b2dacb92816861d0473b4c15f" checksum = "95d164b3b6fbd2b0dd8b639b1012110c0bc256519a0a6def410d4020fa8ae106"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"heck", "heck",
@ -6781,9 +6781,9 @@ dependencies = [
[[package]] [[package]]
name = "wit-bindgen-rust-macro" name = "wit-bindgen-rust-macro"
version = "0.43.0" version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7852bf8a9d1ea80884d26b864ddebd7b0c7636697c6ca10f4c6c93945e023966" checksum = "2c9100a5e1ac85e526dcd4ef49c3ff7689e026fa5e56e2a2047fd377fc682e02"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"prettyplease", "prettyplease",
@ -6796,9 +6796,9 @@ dependencies = [
[[package]] [[package]]
name = "wit-component" name = "wit-component"
version = "0.235.0" version = "0.236.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64a57a11109cc553396f89f3a38a158a97d0b1adaec113bd73e0f64d30fb601f" checksum = "3622959ed7ed6341c38e5aa35af243632534b0a36226852faa802939ce11e00f"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bitflags 2.9.1", "bitflags 2.9.1",
@ -6840,9 +6840,9 @@ dependencies = [
[[package]] [[package]]
name = "wit-parser" name = "wit-parser"
version = "0.235.0" version = "0.236.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a1f95a87d03a33e259af286b857a95911eb46236a0f726cbaec1227b3dfc67a" checksum = "16e4833a20cd6e85d6abfea0e63a399472d6f88c6262957c17f546879a80ba15"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"id-arena", "id-arena",

View File

@ -5,18 +5,28 @@ members = [
"objdiff-gui", "objdiff-gui",
"objdiff-wasm", "objdiff-wasm",
] ]
default-members = [
"objdiff-cli",
"objdiff-core",
"objdiff-gui",
# Exclude objdiff-wasm by default
]
resolver = "3" resolver = "3"
[workspace.package]
version = "3.0.1"
authors = ["Luke Street <luke@street.dev>"]
edition = "2024"
license = "MIT OR Apache-2.0"
repository = "https://github.com/encounter/objdiff"
rust-version = "1.88"
[profile.release-lto] [profile.release-lto]
inherits = "release" inherits = "release"
lto = "fat" lto = "fat"
strip = "debuginfo" strip = "debuginfo"
codegen-units = 1 codegen-units = 1
[workspace.package] [profile.release-min]
version = "3.0.0" inherits = "release-lto"
authors = ["Luke Street <luke@street.dev>"] opt-level = "z"
edition = "2024"
license = "MIT OR Apache-2.0"
repository = "https://github.com/encounter/objdiff"
rust-version = "1.88"

View File

@ -74,6 +74,7 @@ ignore = [
#"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish #"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish
#{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, #{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" },
{ id = "RUSTSEC-2024-0436", reason = "Unmaintained paste crate is an indirect dependency" }, { id = "RUSTSEC-2024-0436", reason = "Unmaintained paste crate is an indirect dependency" },
{ id = "RUSTSEC-2025-0052", reason = "Unmaintained async-std crate is an indirect dependency" },
] ]
# If this is true, then cargo deny will use the git executable to fetch advisory database. # If this is true, then cargo deny will use the git executable to fetch advisory database.
# If this is false, then it uses a built-in git library. # If this is false, then it uses a built-in git library.
@ -241,8 +242,8 @@ allow-git = []
[sources.allow-org] [sources.allow-org]
# github.com organizations to allow git sources for # github.com organizations to allow git sources for
github = [ github = [
"enarx", # flagset
"encounter", "encounter",
"gimli-rs", # gimli
] ]
# gitlab.com organizations to allow git sources for # gitlab.com organizations to allow git sources for
gitlab = [] gitlab = []

View File

@ -170,13 +170,6 @@ pub enum JobResult {
CreateScratch(Option<Box<CreateScratchResult>>), CreateScratch(Option<Box<CreateScratchResult>>),
} }
fn should_cancel(rx: &Receiver<()>) -> bool {
match rx.try_recv() {
Ok(_) | Err(TryRecvError::Disconnected) => true,
Err(_) => false,
}
}
fn start_job( fn start_job(
waker: Waker, waker: Waker,
title: &str, title: &str,
@ -203,7 +196,6 @@ fn start_job(
} }
}); });
let id = JOB_ID.fetch_add(1, Ordering::Relaxed); let id = JOB_ID.fetch_add(1, Ordering::Relaxed);
// log::info!("Started job {}", id); TODO
JobState { id, kind, handle: Some(handle), context, cancel: tx } JobState { id, kind, handle: Some(handle), context, cancel: tx }
} }
@ -228,3 +220,10 @@ fn update_status(
context.waker.wake_by_ref(); context.waker.wake_by_ref();
Ok(()) Ok(())
} }
fn should_cancel(rx: &Receiver<()>) -> bool {
match rx.try_recv() {
Ok(_) | Err(TryRecvError::Disconnected) => true,
Err(_) => false,
}
}

View File

@ -0,0 +1,6 @@
[build]
target = "wasm32-wasip2"
[unstable]
build-std = ["panic_abort", "core", "alloc"]
build-std-features = ["compiler-builtins-mem"]

View File

@ -17,12 +17,13 @@ build = "build.rs"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[features] [features]
default = ["std"] default = []
std = ["objdiff-core/std"] std = ["objdiff-core/std"]
[dependencies] [dependencies]
log = { version = "0.4", default-features = false } log = { version = "0.4", default-features = false }
regex = { version = "1.11", default-features = false, features = ["unicode-case"] } regex = { version = "1.11", default-features = false, features = ["unicode-case"] }
wit-bindgen = { version = "0.44", default-features = false, features = ["macros"] }
xxhash-rust = { version = "0.8", default-features = false, features = ["xxh3"] } xxhash-rust = { version = "0.8", default-features = false, features = ["xxh3"] }
[dependencies.objdiff-core] [dependencies.objdiff-core]
@ -33,8 +34,5 @@ features = ["arm", "arm64", "mips", "ppc", "superh", "x86", "dwarf"]
[target.'cfg(target_family = "wasm")'.dependencies] [target.'cfg(target_family = "wasm")'.dependencies]
talc = { version = "4.4", default-features = false, features = ["lock_api"] } talc = { version = "4.4", default-features = false, features = ["lock_api"] }
[target.'cfg(target_os = "wasi")'.dependencies]
wit-bindgen = { version = "0.43", default-features = false, features = ["macros"] }
[build-dependencies] [build-dependencies]
wit-deps = "0.5" wit-deps = "0.5"

View File

@ -1,12 +1,12 @@
{ {
"name": "objdiff-wasm", "name": "objdiff-wasm",
"version": "3.0.0", "version": "3.0.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "objdiff-wasm", "name": "objdiff-wasm",
"version": "3.0.0", "version": "3.0.1",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.9.3", "@biomejs/biome": "^1.9.3",

View File

@ -1,6 +1,6 @@
{ {
"name": "objdiff-wasm", "name": "objdiff-wasm",
"version": "3.0.0", "version": "3.0.1",
"description": "A local diffing tool for decompilation projects.", "description": "A local diffing tool for decompilation projects.",
"author": { "author": {
"name": "Luke Street", "name": "Luke Street",
@ -19,8 +19,8 @@
"types": "dist/objdiff.d.ts", "types": "dist/objdiff.d.ts",
"scripts": { "scripts": {
"build": "npm run build:wasm && npm run build:transpile && npm run build:lib", "build": "npm run build:wasm && npm run build:transpile && npm run build:lib",
"build:wasm": "cargo +nightly -Zbuild-std=panic_abort,core,alloc -Zbuild-std-features=compiler-builtins-mem build --target wasm32-wasip2 --release --no-default-features", "build:wasm": "cargo build --profile release-min --no-default-features",
"build:transpile": "jco transpile ../target/wasm32-wasip2/release/objdiff_wasm.wasm --no-nodejs-compat --no-wasi-shim --no-namespaced-exports --map wasi:logging/logging=./wasi-logging.js --optimize -o pkg --name objdiff", "build:transpile": "jco transpile ../target/wasm32-wasip2/release-min/objdiff_wasm.wasm --no-nodejs-compat --no-wasi-shim --no-namespaced-exports --map wasi:logging/logging=./wasi-logging.js --optimize -o pkg --name objdiff",
"build:lib": "rslib build" "build:lib": "rslib build"
}, },
"devDependencies": { "devDependencies": {

View File

@ -0,0 +1,4 @@
[toolchain]
channel = "nightly"
components = ["rust-src"]
targets = ["wasm32-wasip2"]

View File

@ -1,9 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc; extern crate alloc;
#[cfg(target_os = "wasi")]
mod api; mod api;
#[cfg(target_os = "wasi")]
mod logging; mod logging;
#[cfg(all(target_os = "wasi", not(feature = "std")))] #[cfg(all(target_os = "wasi", not(feature = "std")))]