Skip to content

Commit

Permalink
ci: add x86_64-linux-musl release
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrorJack committed Feb 28, 2024
1 parent c62a0c9 commit 5300d6e
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 1 deletion.
50 changes: 50 additions & 0 deletions .github/workflows/release-musl.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
49 changes: 49 additions & 0 deletions build-alpine.sh
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 13 additions & 0 deletions clang++.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5300d6e

Please sign in to comment.