Skip to content

Commit

Permalink
Merge pull request wasmerio#3552 from wasmerio/link-headless
Browse files Browse the repository at this point in the history
create-exe: link with libwasmer-headless
  • Loading branch information
fschutt authored Jan 30, 2023
2 parents 6e850db + b73f4a2 commit a90b82a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
build-what: [
{
key: capi,
build-cmd: 'make build-capi && make package-capi && make tar-capi',
build-cmd: 'make build-capi && make build-capi-headless && make package-capi && make tar-capi',
name: 'Build and test C-API'
},
{
Expand Down Expand Up @@ -530,7 +530,7 @@ jobs:
test_integration_cli:
name: CLI integration tests on ${{ matrix.build }}
runs-on: ${{ matrix.os }}
needs: [build]
needs: [build, build_linux_aarch64]
strategy:
fail-fast: false
matrix:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ build-capi-llvm-universal:
build-capi-headless:
ifeq ($(CARGO_TARGET_FLAG),)
RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build --target $(HOST_TARGET) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/$(CARGO_TARGET)/headless
--no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/headless
else
RUSTFLAGS="${RUSTFLAGS} -C panic=abort -C link-dead-code -C lto -O -C embed-bitcode=yes" $(CARGO_BINARY) build $(CARGO_TARGET_FLAG) --manifest-path lib/c-api/Cargo.toml --release \
--no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/$(CARGO_TARGET)/headless
--no-default-features --features compiler-headless,wasi,webc_runner --target-dir target/headless
endif

build-capi-headless-ios:
Expand Down Expand Up @@ -561,7 +561,7 @@ test-wasi-unit:
test-wasi:
$(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --release --tests $(compiler_features) -- wasi::wasitests

test-integration-cli: build-wasmer build-capi package dist
test-integration-cli: build-wasmer build-capi package distribution
cp ./dist/wasmer.tar.gz ./link.tar.gz
rustup target add wasm32-wasi
$(CARGO_BINARY) test $(CARGO_TARGET_FLAG) --features webc_runner --no-fail-fast -p wasmer-integration-tests-cli -- --nocapture --test-threads=1
Expand Down Expand Up @@ -727,7 +727,7 @@ package-docs: build-docs build-docs-capi
echo '<meta http-equiv="refresh" content="0; url=crates/wasmer/index.html">' > package/docs/index.html
echo '<meta http-equiv="refresh" content="0; url=wasmer/index.html">' > package/docs/crates/index.html

package: package-wasmer package-minimal-headless-wasmer package-capi
package: package-wasmer package-minimal-headless-wasmer package-capi package-capi-headless

tar-capi:
ls -R package
Expand Down
14 changes: 10 additions & 4 deletions lib/cli/src/commands/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1757,11 +1757,17 @@ pub(super) mod utils {
target: &Triple,
files: &[PathBuf],
) -> Result<PathBuf, anyhow::Error> {
let a = OsStr::new("libwasmer.a");
let b = OsStr::new("wasmer.lib");
files
let target_files = &[
OsStr::new("libwasmer-headless.a"),
OsStr::new("wasmer-headless.lib"),
OsStr::new("libwasmer.a"),
OsStr::new("wasmer.lib"),
];
target_files
.iter()
.find(|f| f.file_name() == Some(a) || f.file_name() == Some(b))
.find_map(|q| {
files.iter().find(|f| f.file_name() == Some(*q))
})
.cloned()
.ok_or_else(|| {
anyhow!("Could not find libwasmer.a for {} target in the provided tarball path (files = {files:#?})", target)
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/cli/tests/create_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ impl WasmerCreateExe {

let output = output.output()?;

let stdout = std::str::from_utf8(&output.stdout)
.expect("stdout is not utf8! need to handle arbitrary bytes");

assert!(
stdout.contains("headless."),
"create-exe stdout should link with libwasmer-headless"
);

if !output.status.success() {
bail!(
"{cmd}\r\n failed with: stdout: {}\n\nstderr: {}",
std::str::from_utf8(&output.stdout)
.expect("stdout is not utf8! need to handle arbitrary bytes"),
"{cmd}\r\n failed with: stdout: {stdout}\n\nstderr: {}",
std::str::from_utf8(&output.stderr)
.expect("stderr is not utf8! need to handle arbitrary bytes")
);
Expand Down

0 comments on commit a90b82a

Please sign in to comment.