Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Oct 20, 2023
1 parent 5565b93 commit 68cf136
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 42 deletions.
65 changes: 36 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on:
# tag at the end of CI if successful and the tag will trigger the artifact
# uploads as well as publication to crates.io.
- 'release-*'
- 'min-builds'

defaults:
run:
Expand Down Expand Up @@ -116,6 +117,7 @@ jobs:
outputs:
run-full: ${{ steps.calculate.outputs.run-full }}
test-matrix: ${{ steps.calculate.outputs.test-matrix }}
build-matrix: ${{ steps.calculate.outputs.build-matrix }}
test-capi: ${{ steps.calculate.outputs.test-capi }}
build-fuzz: ${{ steps.calculate.outputs.build-fuzz }}
audit: ${{ steps.calculate.outputs.audit }}
Expand Down Expand Up @@ -161,6 +163,9 @@ jobs:
echo "test-matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
echo "$matrix"
matrix="$(node ./ci/build-build-matrix.js)"
echo "build-matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
if [ "$run_full" = "true" ]; then
echo run-full=true >> $GITHUB_OUTPUT
echo test-capi=true >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -658,40 +663,29 @@ jobs:
# Perform release builds of `wasmtime` and `libwasmtime.so`. Builds a variety
# of platforms and architectures and then uploads the release artifacts to
# this workflow run's list of artifacts.
#
# Note that the full matrix is computed by `ci/build-build-matrix.js`.
build:
needs: determine
if: needs.determine.outputs.run-full
name: Release build for ${{ matrix.build }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- build: x86_64-linux
os: ubuntu-latest
- build: x86_64-macos
os: macos-latest
- build: aarch64-macos
os: macos-latest
target: aarch64-apple-darwin
- build: x86_64-windows
os: windows-latest
- build: x86_64-mingw
os: windows-latest
target: x86_64-pc-windows-gnu
- build: aarch64-linux
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- build: s390x-linux
os: ubuntu-latest
target: s390x-unknown-linux-gnu
- build: riscv64gc-linux
os: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
matrix: ${{ fromJson(needs.determine.outputs.build-matrix) }}
steps:
- uses: actions/checkout@v3
with:
submodules: true

# For normal builds use stable Rust, othrewise for minimal builds use the
# same nightly toolchain that other nightly builds in this file use.
- uses: ./.github/actions/install-rust
if: '!matrix.min'
- uses: ./.github/actions/install-rust
with:
toolchain: nightly-2023-10-10
if: matrix.min

# On one builder produce the source tarball since there's no need to produce
# it everywhere
- run: ./ci/build-src-tarball.sh
Expand All @@ -702,16 +696,29 @@ jobs:
- run: |
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
rustup target add ${{ matrix.target }}
if: matrix.target != ''
# Build `wasmtime` and executables. Note that we include some non-default
# features so the # release artifacts can be maximally feature-ful.
- run: $CENTOS cargo build --release --bin wasmtime --features all-arch,component-model
- name: Configure minimal build
if: matrix.min
run: |
echo CARGO_PROFILE_RELEASE_STRIP=debuginfo >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_OPT_LEVEL=s >> $GITHUB_ENV
echo RUSTFLAGS=-Zlocation-detail=none >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_LTO=true >> $GITHUB_ENV
echo CARGO_PROFILE_RELEASE_PANIC=abort >> $GITHUB_ENV
echo BUILD_FLAGS="-Zbuild-std=std,panic_abort --no-default-features -Zbuild-std-features=" >> $GITHUB_ENV
# Build the `wasmtime` executable. Note that we include some non-default
# features so the release artifacts can be maximally feature-ful.
- run: $CENTOS cargo build --release $BUILD_FLAGS
if: matrix.min
- run: $CENTOS cargo build --release --features all-arch,component-model
if: '!matrix.min'

# Build `libwasmtime.so`
- run: $CENTOS cargo build --release --manifest-path crates/c-api/Cargo.toml
- run: $CENTOS cargo build --release -p wasmtime-c-api $BUILD_FLAGS

# Assemble release artifats appropriate for this platform, then upload them
# Assemble release artifacts appropriate for this platform, then upload them
# unconditionally to this workflow's files so we have a copy of them.
- run: ./ci/build-tarballs.sh "${{ matrix.build }}" "${{ matrix.target }}"
- uses: actions/upload-artifact@v3
Expand Down
54 changes: 54 additions & 0 deletions ci/build-build-matrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Small script used to calculate the matrix of builds that are going to be
// done if CI decides to do a release build.

const array = [
{
"build": "x86_64-linux",
"os": "ubuntu-latest",
"target": "x86_64-unknown-linux-gnu",
},
{
"build": "aarch64-linux",
"os": "ubuntu-latest",
"target": "aarch64-unknown-linux-gnu",
},
{
"build": "s390x-linux",
"os": "ubuntu-latest",
"target": "s390x-unknown-linux-gnu",
},
{
"build": "riscv64gc-linux",
"os": "ubuntu-latest",
"target": "riscv64gc-unknown-linux-gnu",
},
{
"build": "x86_64-macos",
"os": "macos-latest",
"target": "x86_64-apple-darwin",
},
{
"build": "aarch64-macos",
"os": "macos-latest",
"target": "aarch64-apple-darwin",
},
{
"build": "x86_64-windows",
"os": "windows-latest",
"target": "x86_64-pc-windows-msvc",
},
{
"build": "x86_64-mingw",
"os": "windows-latest",
"target": "x86_64-pc-windows-gnu",
},
];

const builds = [];
for (let build of array) {
builds.push(JSON.parse(JSON.stringify(build)));
build.min = true;
builds.push(build);
}

console.log(JSON.stringify(builds));
19 changes: 6 additions & 13 deletions ci/build-tarballs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,16 @@ if [ "$platform" = "x86_64-windows" ]; then
"$WIX/bin/light" -out dist/$bin_pkgname.msi target/wasmtime.wixobj -ext WixUtilExtension
rm dist/$bin_pkgname.wixpdb
elif [ "$platform" = "x86_64-mingw" ]; then
cp target/x86_64-pc-windows-gnu/release/wasmtime.exe tmp/$bin_pkgname
cp target/x86_64-pc-windows-gnu/release/{wasmtime.dll,libwasmtime.a,libwasmtime.dll.a} tmp/$api_pkgname/lib
cp target/$target/release/wasmtime.exe tmp/$bin_pkgname
cp target/$target/release/{wasmtime.dll,libwasmtime.a,libwasmtime.dll.a} tmp/$api_pkgname/lib
fmt=zip
elif [ "$platform" = "x86_64-macos" ]; then
elif [[ $platform == *-macos ]]; then
# Postprocess the macOS dylib a bit to have a more reasonable `LC_ID_DYLIB`
# directive than the default one that comes out of the linker when typically
# doing `cargo build`. For more info see #984
install_name_tool -id "@rpath/libwasmtime.dylib" target/release/libwasmtime.dylib
cp target/release/wasmtime tmp/$bin_pkgname
cp target/release/libwasmtime.{a,dylib} tmp/$api_pkgname/lib
elif [ "$platform" = "aarch64-macos" ]; then
install_name_tool -id "@rpath/libwasmtime.dylib" target/aarch64-apple-darwin/release/libwasmtime.dylib
cp target/aarch64-apple-darwin/release/wasmtime tmp/$bin_pkgname
cp target/aarch64-apple-darwin/release/libwasmtime.{a,dylib} tmp/$api_pkgname/lib
elif [ "$target" = "" ]; then
cp target/release/wasmtime tmp/$bin_pkgname
cp target/release/libwasmtime.{a,so} tmp/$api_pkgname/lib
install_name_tool -id "@rpath/libwasmtime.dylib" target/$target/release/libwasmtime.dylib
cp target/$target/release/wasmtime tmp/$bin_pkgname
cp target/$target/release/libwasmtime.{a,dylib} tmp/$api_pkgname/lib
else
cp target/$target/release/wasmtime tmp/$bin_pkgname
cp target/$target/release/libwasmtime.{a,so} tmp/$api_pkgname/lib
Expand Down

0 comments on commit 68cf136

Please sign in to comment.