From 68cf13607816f323e87c1cf3bfed19a5272527f0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 20 Oct 2023 12:05:00 -0700 Subject: [PATCH] wip --- .github/workflows/main.yml | 65 +++++++++++++++++++++----------------- ci/build-build-matrix.js | 54 +++++++++++++++++++++++++++++++ ci/build-tarballs.sh | 19 ++++------- 3 files changed, 96 insertions(+), 42 deletions(-) create mode 100644 ci/build-build-matrix.js diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2df6de8fa74d..65f46040b18c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -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 }} @@ -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 @@ -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 @@ -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 diff --git a/ci/build-build-matrix.js b/ci/build-build-matrix.js new file mode 100644 index 000000000000..155e257299de --- /dev/null +++ b/ci/build-build-matrix.js @@ -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)); diff --git a/ci/build-tarballs.sh b/ci/build-tarballs.sh index eb6197c2a5ac..5dfb9b047457 100755 --- a/ci/build-tarballs.sh +++ b/ci/build-tarballs.sh @@ -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