From 5300d6e136759a43dbb4f145786496dd8ab8002d Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Thu, 21 Sep 2023 17:24:38 +0000 Subject: [PATCH] ci: add x86_64-linux-musl release --- .github/workflows/release-musl.yml | 50 ++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- build-alpine.sh | 49 +++++++++++++++++++++++++++++ clang++.py | 13 ++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-musl.yml create mode 100755 build-alpine.sh create mode 100755 clang++.py diff --git a/.github/workflows/release-musl.yml b/.github/workflows/release-musl.yml new file mode 100644 index 00000000000..04fb4c06971 --- /dev/null +++ b/.github/workflows/release-musl.yml @@ -0,0 +1,50 @@ +name: release-musl + +on: + push: + tags: + - "*" + workflow_dispatch: + +jobs: + release-musl: + name: release-x86_64-linux-musl + runs-on: ubuntu-latest + steps: + + - name: build-image + run: | + pushd "$(mktemp -d)" + curl -f -L --retry 5 https://github.com/tweag/rust-alpine-mimalloc/archive/refs/heads/master.tar.gz | tar xz --strip-components=1 + podman build \ + --network host \ + --pull \ + --squash-all \ + --tag rust:alpine-mimalloc \ + . + popd + + - name: checkout + uses: actions/checkout@v4 + + - name: checkout-submodules + run: git submodule update --init --depth 1 --jobs 2 + + - name: build & test + run: | + podman run \ + --env GITHUB_REF_NAME=$GITHUB_REF_NAME \ + --init \ + --network host \ + --rm \ + --tmpfs /tmp:exec \ + --volume $PWD:/workspace \ + --workdir /workspace \ + rust:alpine-mimalloc \ + /workspace/build-alpine.sh + + - name: upload-artifact + uses: actions/upload-artifact@v4 + with: + name: binaryen-x86_64-linux-musl + path: binaryen-*-x86_64-linux-musl.tar.zst diff --git a/CMakeLists.txt b/CMakeLists.txt index d86f4c30cd5..2dff3636540 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,7 +299,7 @@ else() else() add_link_flag("-Wl,--stack,8388608") endif() - elseif(NOT EMSCRIPTEN) + elseif((NOT EMSCRIPTEN) AND (NOT BUILD_STATIC_LIB)) add_compile_flag("-fPIC") endif() add_debug_compile_flag("-g3") diff --git a/build-alpine.sh b/build-alpine.sh new file mode 100755 index 00000000000..42b5c573ac5 --- /dev/null +++ b/build-alpine.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +set -eu + +apk upgrade +apk add \ + alpine-sdk \ + clang \ + cmake \ + coreutils \ + git \ + lld \ + llvm \ + nodejs \ + py3-pip \ + samurai \ + zstd + +pip3 install --break-system-packages -r requirements-dev.txt + +cmake \ + -Bbuild \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER="$PWD/clang++.py" \ + -DCMAKE_INSTALL_PREFIX="/tmp/binaryen-$GITHUB_REF_NAME" \ + -DCMAKE_JOB_POOLS="linking=1" \ + -DCMAKE_JOB_POOL_LINK=linking \ + -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld -Wl,--thinlto-cache-dir=$PWD/build/lto-cache -s -static" \ + -DBUILD_STATIC_LIB=ON \ + -DENABLE_WERROR=OFF \ + -DINSTALL_LIBS=OFF + +cmake --build build --target install -- -v + +CC=clang CXX=clang++ COMPILER_FLAGS="-Wno-unused-command-line-argument -fuse-ld=lld -Wl,--thinlto-cache-dir=$PWD/build/lto-cache -s -static" ./check.py --binaryen-bin build/bin --binaryen-lib build/lib + +tar \ + --sort=name \ + --mtime=1970-01-01T00:00:00Z \ + --owner=0 \ + --group=0 \ + --numeric-owner \ + --use-compress-program="zstd --ultra -22 --threads=0" \ + -cf "binaryen-$GITHUB_REF_NAME-x86_64-linux-musl.tar.zst" \ + -C /tmp \ + "binaryen-$GITHUB_REF_NAME" diff --git a/clang++.py b/clang++.py new file mode 100755 index 00000000000..d416d6bc955 --- /dev/null +++ b/clang++.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os +import sys + +if __name__ == "__main__": + args = [arg for arg in sys.argv[1:] if not arg in {"-fcolor-diagnostics"}] + if any(any(arg.endswith(f) for f in {"Precompute.cpp"}) for arg in args): + compiler = "g++" + args = [arg for arg in args if not arg.startswith("-flto")] + else: + compiler = "clang++" + os.execvp(compiler, [compiler] + args)