Skip to content

Commit

Permalink
Add release binaries for x86_64-musl (#8668)
Browse files Browse the repository at this point in the history
* Add release binaries for x86_64-musl

This was requested in bytecodealliance/wasmtime-py#237 and shouldn't
cost us too much in terms of CI resources and maintenance overhead.

* Fix combining rustflags

prtest:full
  • Loading branch information
alexcrichton authored May 21, 2024
1 parent 7c29813 commit cc93e8f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ci/build-build-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const array = [
"os": "ubuntu-latest",
"target": "x86_64-linux-android",
},
{
"build": "x86_64-musl",
"os": "ubuntu-latest",
"target": "x86_64-unknown-linux-musl",
},
];

const builds = [];
Expand Down
2 changes: 1 addition & 1 deletion ci/build-release-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if [[ "$build" = *-min ]]; then
# Configure a whole bunch of compile-time options which help reduce the size
# of the binary artifact produced.
export CARGO_PROFILE_RELEASE_OPT_LEVEL=s
export RUSTFLAGS=-Zlocation-detail=none
export RUSTFLAGS="-Zlocation-detail=none $RUSTFLAGS"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO=true
build_std=-Zbuild-std=std,panic_abort
Expand Down
17 changes: 17 additions & 0 deletions ci/docker/x86_64-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Rust binaries need `libgcc_s.so` but ubuntu's musl toolchain does not have it.
# Get it from alpine instead.
FROM alpine:3.16 as libgcc_s_src
RUN apk add libgcc

# Use something glibc-based for the actual compile because the Rust toolchain
# we're using is glibc-based in CI.
FROM ubuntu:24.04
RUN apt-get update -y && apt-get install -y cmake musl-tools
COPY --from=libgcc_s_src /usr/lib/libgcc_s.so.1 /usr/lib/x86_64-linux-musl

ENV PATH=$PATH:/rust/bin

# Note that `-crt-feature` is passed here to specifically disable static linking
# with musl. We want a `*.so` to pop out so static linking isn't what we want.
ENV RUSTFLAGS=-Ctarget-feature=-crt-static
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc
4 changes: 4 additions & 0 deletions crates/wasmtime/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ fn build_c_helpers() {
println!("cargo:rerun-if-changed=src/runtime/vm/helpers.c");
build.file("src/runtime/vm/helpers.c");
build.compile("wasmtime-helpers");

if os == "linux" {
println!("cargo:rustc-link-lib=m");
}
}
6 changes: 6 additions & 0 deletions docs/stability-tiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ For explanations of what each tier means see below.
| Target | `wasm32-wasi` [^3] | Supported but not tested |
| Target | `aarch64-linux-android` | CI testing, full-time maintainer |
| Target | `x86_64-linux-android` | CI testing, full-time maintainer |
| Target | `x86_64-unknown-linux-musl` [^4] | CI testing, full-time maintainer |
| Compiler Backend | Winch on aarch64 | finished implementation |
| WebAssembly Proposal | [`gc`] | Complete implementation |
| WASI Proposal | [`wasi-nn`] | More expansive CI testing |
Expand Down Expand Up @@ -119,6 +120,11 @@ as well.
but not the `runtime` feature at this time. This means that
Wasmtime-compiled-to-wasm can itself compile wasm but cannot execute wasm.

[^4]: Binary artifacts for MUSL are dynamically linked, not statically
linked, meaning that they are not suitable for "run on any linux distribution"
style use cases. Wasmtime does not have static binary artifacts at this time and
that will require building from source.

#### Unsupported features and platforms

While this is not an exhaustive list, Wasmtime does not currently have support
Expand Down

0 comments on commit cc93e8f

Please sign in to comment.