Skip to content

Commit af4a391

Browse files
committed
Rely less on wasm-component-ld for tests
This repository is often used to test experimental/upcoming features for components such as async/etc, but this creates a chicken-and-egg problem where it becomes difficult to compile tests. Many tests use upstream toolchains which use `wasm-component-ld` (e.g. Rust/C tests) but it can take time to get this updated. There's already logic to handle having tests target wasip1 and running the wit-component step manually, so this PR makes that step unconditional. This means that test binaries are always assembled with a crate-dependency of `wit-component` which should enable easier updates since it's "just" a Cargo dependency vs being part of a toolchain in a separate project.
1 parent f7f3b49 commit af4a391

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
with:
123123
submodules: true
124124
- name: Install Rust
125-
run: rustup update nightly --no-self-update && rustup default nightly
125+
run: rustup update stable --no-self-update && rustup default stable
126126
- run: rustup target add wasm32-wasip2
127127
- uses: ./.github/actions/install-wasi-sdk
128128
- run: |

crates/test/src/c.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ fn compile(runner: &Runner<'_>, compile: &Compile<'_>, compiler: PathBuf) -> Res
123123

124124
// Now compile the runner's source code to with the above object and the
125125
// component-type object into a final component.
126-
let output = if produces_component(runner) {
127-
compile.output.to_path_buf()
128-
} else {
129-
compile.output.with_extension("core.wasm")
130-
};
126+
let output = compile.output.with_extension("core.wasm");
131127
let mut cmd = Command::new(compiler);
132128
cmd.arg(&compile.component.path)
133129
.arg(&bindings_object)
@@ -154,13 +150,14 @@ fn compile(runner: &Runner<'_>, compile: &Compile<'_>, compiler: PathBuf) -> Res
154150
cmd.arg("-mexec-model=reactor");
155151
}
156152
}
153+
if produces_component(runner) {
154+
cmd.arg("-Wl,--skip-wit-component");
155+
}
157156
runner.run_command(&mut cmd)?;
158157

159-
if !produces_component(runner) {
160-
runner
161-
.convert_p1_to_component(&output, compile)
162-
.with_context(|| format!("failed to convert {output:?}"))?;
163-
}
158+
runner
159+
.convert_p1_to_component(&output, compile)
160+
.with_context(|| format!("failed to convert {output:?}"))?;
164161
Ok(())
165162
}
166163

crates/test/src/rust.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ path = 'lib.rs'
166166
// If this rust target doesn't natively produce a component then place
167167
// the compiler output in a temporary location which is componentized
168168
// later on.
169-
let output = if runner.produces_component() {
170-
compile.output.to_path_buf()
171-
} else {
172-
compile.output.with_extension("core.wasm")
173-
};
169+
let output = compile.output.with_extension("core.wasm");
174170

175171
// Compile all extern crates, if any
176172
let mut externs = Vec::new();
@@ -216,13 +212,14 @@ path = 'lib.rs'
216212
cmd.arg("--crate-type=cdylib");
217213
}
218214
}
215+
if runner.produces_component() {
216+
cmd.arg("-Clink-arg=--skip-wit-component");
217+
}
219218
runner.run_command(&mut cmd)?;
220219

221-
if !runner.produces_component() {
222-
runner
223-
.convert_p1_to_component(&output, compile)
224-
.with_context(|| format!("failed to convert {output:?}"))?;
225-
}
220+
runner
221+
.convert_p1_to_component(&output, compile)
222+
.with_context(|| format!("failed to convert {output:?}"))?;
226223

227224
Ok(())
228225
}

0 commit comments

Comments
 (0)