From aaf87f2d23ded9a54c233727b8391a0d88ebf03b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Mon, 28 Oct 2024 21:40:30 -0700 Subject: [PATCH 01/17] add musl build [v2] --- .github/workflows/build.yml | 67 ++++++++++++++++++ Dockerfile.musl | 132 ++++++++++++++++++++++++------------ musl-release.sh | 46 +++++++++++++ 3 files changed, 203 insertions(+), 42 deletions(-) create mode 100644 musl-release.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eae990178e089..87da00a6dad66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -222,6 +222,72 @@ jobs: name: bun-webkit-windows-${{ matrix.arch }}${{ matrix.suffix }} path: bun-webkit.tar.gz + linux-musl: + name: Linux + runs-on: ${{matrix.os}} + strategy: + matrix: + include: + - lto_flag: "" + label: bun-webkit-linux-amd64-debug + os: big-ubuntu + package_json_arch: "x64" + CMAKE_BUILD_TYPE: "Debug" + - lto_flag: "" + label: bun-webkit-linux-arm64-debug + os: linux-arm64-gh + package_json_arch: "arm64" + CMAKE_BUILD_TYPE: "Debug" + - lto_flag: "-flto=full -fwhole-program-vtables -fforce-emit-vtables" + label: bun-webkit-linux-arm64-lto + os: linux-arm64-gh + package_json_arch: "arm64" + CMAKE_BUILD_TYPE: "Release" + - lto_flag: "" + label: bun-webkit-linux-arm64 + os: linux-arm64-gh + package_json_arch: "arm64" + CMAKE_BUILD_TYPE: "Release" + - lto_flag: "-flto=full -fwhole-program-vtables -fforce-emit-vtables" + label: bun-webkit-linux-amd64-lto + os: big-ubuntu + package_json_arch: "x64" + CMAKE_BUILD_TYPE: "Release" + - lto_flag: "" + label: bun-webkit-linux-amd64 + os: big-ubuntu + package_json_arch: "x64" + CMAKE_BUILD_TYPE: "Release" + + timeout-minutes: 90 + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout-cone-mode: false + sparse-checkout: | + /* + !LayoutTests/ + !JSTests/ + - uses: docker/setup-buildx-action@v2 + id: buildx + with: + install: true + - name: Run + run: | + rm -rf ${{runner.temp}}/bun-webkit ${{runner.temp}}/bun-webkit.tar.gz + WEBKIT_RELEASE_TYPE=${{matrix.CMAKE_BUILD_TYPE}} CPU="native" cpu=native LTO_FLAG="${{matrix.lto_flag}}" temp=${{runner.temp}} bash musl-release.sh + cd ${{runner.temp}} + echo "#define BUN_WEBKIT_VERSION \"${{github.sha}}\"" >> bun-webkit/include/cmakeconfig.h + echo '{ "name": "${{matrix.label}}", "version": "0.0.1-${{github.sha}}", "os": ["linux"], "cpu": ["${{matrix.package_json_arch}}"], "repository": "https://github.com/${{github.repository}}" }' > bun-webkit/package.json + rm -rf bun-webkit/lib/*.so + rm -rf bun-webkit/lib/*.so.* + tar -czf bun-webkit.tar.gz bun-webkit + rm -rf bun-webkit + - uses: actions/upload-artifact@v3 + with: + name: ${{matrix.label}} + path: ${{runner.temp}}/bun-webkit.tar.gz + release: name: release permissions: @@ -232,6 +298,7 @@ jobs: - linux - macos - windows + - linux-musl steps: - uses: actions/download-artifact@v3 with: diff --git a/Dockerfile.musl b/Dockerfile.musl index 869c20fd2ec4b..bbca73ab6310c 100644 --- a/Dockerfile.musl +++ b/Dockerfile.musl @@ -1,66 +1,114 @@ -FROM alpine:3.15 as base +ARG MARCH_FLAG="" +ARG WEBKIT_RELEASE_TYPE=Release +ARG CPU=native +ARG LTO_FLAG="-flto=full -fwhole-program-vtables -fforce-emit-vtables " +ARG LLVM_VERSION="18" +ARG DEFAULT_CFLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 " + +FROM alpine:edge as base + +ARG MARCH_FLAG +ARG WEBKIT_RELEASE_TYPE +ARG CPU +ARG LTO_FLAG +ARG LLVM_VERSION +ARG DEFAULT_CFLAGS RUN apk update -RUN apk add --no-cache cmake make clang clang-static clang-dev llvm12-dev llvm12-static musl-dev git lld libgcc gcc g++ libstdc++ build-base lld-dev lld-static llvm12-libs libc-dev xz zlib zlib-dev libxml2 libxml2-dev +RUN apk add --no-cache cmake make clang18 clang18-static clang18-dev llvm18-dev llvm18-static musl-dev git lld18 libgcc gcc g++ libstdc++ build-base lld18-dev llvm18-libs libc-dev xz zlib zlib-dev libxml2 libxml2-dev -ENV CXX=clang++ -ENV CC=clang -ENV LDFLAGS='-L/usr/include -L/usr/include/llvm12' -ENV CXXFLAGS="-I/usr/include -I/usr/include/llvm12" +ENV CXX=clang++-18 +ENV CC=clang-18 +ENV LDFLAGS='-L/usr/include -L/usr/include/llvm18' +ENV CXXFLAGS="-I/usr/include -I/usr/include/llvm18" ENV PATH="/usr/bin:/usr/local/bin:/zig/bin:$PATH" +ENV CPU=${CPU} +ENV MARCH_FLAG=${MARCH_FLAG} +ENV WEBKIT_OUT_DIR=/webkitbuild +RUN mkdir -p /output/lib /output/include /output/include/JavaScriptCore /output/include/wtf /output/include/bmalloc /output/include/unicode + +FROM base as build_icu + +ARG MARCH_FLAG +ARG WEBKIT_RELEASE_TYPE +ARG CPU +ARG LTO_FLAG +ARG LLVM_VERSION +ARG DEFAULT_CFLAGS + +RUN apk add --no-cache cpio curl icu-dev tar + +WORKDIR /icu-src +RUN --mount=type=tmpfs,target=/icu-src; curl -L https://github.com/unicode-org/icu/releases/download/release-75-1/icu4c-75_1-src.tgz > icu4c-75_1-src.tgz && \ + tar -xzf icu4c-75_1-src.tgz && \ + rm icu4c-75_1-src.tgz && \ + cd icu/source && \ + ./configure --enable-static --disable-shared && \ + make -j$(nproc) && \ + mkdir -p /icu && \ + cp -r lib/*.a /icu FROM base as build_webkit -RUN apk add --no-cache cpio curl file gnupg icu-dev ninja ruby unzip rsync perl python2 openssl-dev openssl linux-headers +ARG MARCH_FLAG +ARG WEBKIT_RELEASE_TYPE +ARG CPU +ARG LTO_FLAG +ARG LLVM_VERSION +ARG DEFAULT_CFLAGS + +RUN apk add --no-cache cpio curl file gnupg icu-dev ninja ruby unzip rsync perl python3 openssl-dev openssl linux-headers ENV WEBKIT_OUT_DIR=/webkit # These are unnecessary on musl # ENV CFLAGS="$CFLAGS -ffat-lto-objects" # ENV CXXFLAGS="$CXXFLAGS -ffat-lto-objects" +COPY . /webkit +WORKDIR /webkit -WORKDIR /webkit-build - -COPY . /webkit-src +COPY --from=build_icu /icu /icu -RUN --mount=type=tmpfs,target=/webkit-build; \ +RUN --mount=type=tmpfs,target=/webkitbuild \ + export CFLAGS="${DEFAULT_CFLAGS} $CFLAGS $LTO_FLAG -ffile-prefix-map=/webkit/Source=src/bun.js/WebKit/Source -ffile-prefix-map=/webkitbuild/=. " && \ + export CXXFLAGS="${DEFAULT_CFLAGS} $CXXFLAGS $LTO_FLAG -fno-c++-static-destructors -ffile-prefix-map=/webkit/Source=src/bun.js/WebKit/Source -ffile-prefix-map=/webkitbuild/=. " && \ + export LDFLAGS="-fuse-ld=lld $LDFLAGS " && \ + cd /webkitbuild && \ cmake \ -DPORT="JSCOnly" \ -DENABLE_STATIC_JSC=ON \ + -DENABLE_BUN_SKIP_FAILING_ASSERTIONS=ON \ -DCMAKE_BUILD_TYPE=Release \ -DUSE_THIN_ARCHIVES=OFF \ + -DUSE_BUN_JSC_ADDITIONS=ON \ -DENABLE_FTL_JIT=ON \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \ + -DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \ + -DENABLE_REMOTE_INSPECTOR=ON \ + -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \ + -DCMAKE_AR=$(which llvm-ar) \ + -DCMAKE_RANLIB=$(which llvm-ranlib) \ + -DCMAKE_C_FLAGS="$CFLAGS" \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ + -DICU_ROOT=/icu \ -G Ninja \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DCMAKE_C_COMPILER=clang \ - /webkit-src && \ - cd /webkit-build && \ - cmake --build /webkit-build --config release -- "jsc" && \ - mkdir -p ${WEBKIT_OUT_DIR}/lib ${WEBKIT_OUT_DIR}/include/JavaScriptCore && \ - cp -r /webkit-build/lib/*.a $WEBKIT_OUT_DIR/lib && \ - cp /webkit-build/*.h $WEBKIT_OUT_DIR/include && \ - find /webkit-build/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} $WEBKIT_OUT_DIR/include/JavaScriptCore/ \; && \ - find /webkit-build/JavaScriptCore/PrivateHeaders/JavaScriptCore/ -name "*.h" -exec cp {} $WEBKIT_OUT_DIR/include/JavaScriptCore/ \; && \ - cp -r /webkit-build/WTF/Headers/wtf/ $WEBKIT_OUT_DIR/include && \ - cp -r /webkit-build/bmalloc/Headers/bmalloc/ $WEBKIT_OUT_DIR/include && echo "Done"; - - -FROM base as build_icu - -RUN apk add --no-cache cpio curl icu-dev tar - - -WORKDIR /icu-src -RUN --mount=type=tmpfs,target=/icu-src; curl -L https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.tgz > icu4c-66_1-src.tgz && \ - tar -xzf icu4c-66_1-src.tgz && \ - rm icu4c-66_1-src.tgz && \ - cd icu/source && \ - ./configure --enable-static --disable-shared && \ - make -j$(nproc) && \ - mkdir -p /icu && \ - cp -r lib/*.a /icu - - -FROM alpine:3.15 as webkit + /webkit && \ + cd /webkitbuild && \ + cmake --build /webkitbuild --config Release --target "jsc" && \ + cp -r $WEBKIT_OUT_DIR/lib/*.a /output/lib && \ + cp $WEBKIT_OUT_DIR/*.h /output/include && \ + cp -r $WEBKIT_OUT_DIR/bin /output/bin && \ + cp $WEBKIT_OUT_DIR/*.json /output && \ + find $WEBKIT_OUT_DIR/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} /output/include/JavaScriptCore/ \; && \ + find $WEBKIT_OUT_DIR/JavaScriptCore/PrivateHeaders/JavaScriptCore/ -name "*.h" -exec cp {} /output/include/JavaScriptCore/ \; && \ + cp -r $WEBKIT_OUT_DIR/WTF/Headers/wtf/ /output/include && \ + cp -r $WEBKIT_OUT_DIR/bmalloc/Headers/bmalloc/ /output/include && \ + mkdir -p /output/Source/JavaScriptCore && \ + cp -r /webkit/Source/JavaScriptCore/Scripts /output/Source/JavaScriptCore && \ + cp /webkit/Source/JavaScriptCore/create_hash_table /output/Source/JavaScriptCore && \ + echo ""; + +FROM alpine:edge as artifact COPY --from=build_webkit /webkit /webkit COPY --from=build_icu /icu/*.a /webkit/lib diff --git a/musl-release.sh b/musl-release.sh new file mode 100644 index 0000000000000..6e1041d3cbd9d --- /dev/null +++ b/musl-release.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -euxo pipefail + +export DOCKER_BUILDKIT=1 + +export BUILDKIT_ARCH=$(uname -m) +export ARCH=${BUILDKIT_ARCH} +export LTO_FLAG="${LTO_FLAG:-""}" +if [ "$BUILDKIT_ARCH" == "amd64" ]; then + export BUILDKIT_ARCH="amd64" + export ARCH=x64 +fi + +if [ "$BUILDKIT_ARCH" == "x86_64" ]; then + export BUILDKIT_ARCH="amd64" + export ARCH=x64 +fi + +if [ "$BUILDKIT_ARCH" == "arm64" ]; then + export BUILDKIT_ARCH="arm64" + export ARCH=aarch64 +fi + +if [ "$BUILDKIT_ARCH" == "aarch64" ]; then + export BUILDKIT_ARCH="arm64" + export ARCH=aarch64 +fi + +if [ "$BUILDKIT_ARCH" == "armv7l" ]; then + echo "Unsupported platform: $BUILDKIT_ARCH" + exit 1 +fi + +export WEBKIT_RELEASE_TYPE=${WEBKIT_RELEASE_TYPE:-"Release"} + +export CONTAINER_NAME=bun-webkit-linux-$BUILDKIT_ARCH + +if [ "$WEBKIT_RELEASE_TYPE" == "relwithdebuginfo" ]; then + CONTAINER_NAME=bun-webkit-linux-$BUILDKIT_ARCH-dbg +fi + +mkdir -p $temp +rm -rf $temp/bun-webkit + +docker buildx build -f Dockerfile.musl -t $CONTAINER_NAME --build-arg LTO_FLAG="$LTO_FLAG" --build-arg WEBKIT_RELEASE_TYPE=$WEBKIT_RELEASE_TYPE --build-arg DEBIAN_VERSION=$DEBIAN_VERSION --progress=plain --platform=linux/$BUILDKIT_ARCH --target=artifact --output type=local,dest=$temp/bun-webkit . From abfc39c908190398db0a3fb491501e4ad9b79fa8 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Mon, 28 Oct 2024 21:45:32 -0700 Subject: [PATCH 02/17] run the ci --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87da00a6dad66..a4ca9a775a880 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ env: on: # Triggers the workflow on push or pull request events but only for the "master" branch push: - branches: ["main"] + branches: ["main", "musl"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From c13aeb019183efc06373f79e539e273f2bf78560 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:21:15 -0700 Subject: [PATCH 03/17] run ci on branches but only run release on master --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a4ca9a775a880..02bd33949bdd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,10 +5,6 @@ env: # Controls when the workflow will run on: - # Triggers the workflow on push or pull request events but only for the "master" branch - push: - branches: ["main", "musl"] - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: @@ -294,6 +290,7 @@ jobs: contents: write runs-on: ubuntu-latest timeout-minutes: 90 + if: github.ref == 'refs/heads/master' needs: - linux - macos From 83a3ee9cbbcfb6001cae024c6af0f3b9994ede38 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:22:14 -0700 Subject: [PATCH 04/17] fix line order here --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02bd33949bdd8..14331d10e3c6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -356,8 +356,8 @@ jobs: mv ${{runner.temp}}/bun-webkit-linux-arm64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-debug.tar.gz mv ${{runner.temp}}/bun-webkit-macos-arm64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64-debug.tar.gz mv ${{runner.temp}}/bun-webkit-macos-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64-debug.tar.gz - mv ${{runner.temp}}/bun-webkit-linux-arm64-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-lto.tar.gz mv ${{runner.temp}}/bun-webkit-linux-amd64-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-lto.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-arm64-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-lto.tar.gz mv ${{runner.temp}}/bun-webkit-windows-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64.tar.gz mv ${{runner.temp}}/bun-webkit-windows-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64-debug.tar.gz - name: Release From 0893bb92666ac612ea7172760e5e21679b21d315 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:22:30 -0700 Subject: [PATCH 05/17] remove spaces here --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 14331d10e3c6e..5c31ab4616ed5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -349,13 +349,13 @@ jobs: - name: Rename files run: | mv ${{runner.temp}}/bun-webkit-linux-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64.tar.gz - mv ${{runner.temp}}/bun-webkit-linux-arm64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-arm64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64.tar.gz mv ${{runner.temp}}/bun-webkit-macos-arm64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64.tar.gz - mv ${{runner.temp}}/bun-webkit-macos-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64.tar.gz + mv ${{runner.temp}}/bun-webkit-macos-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64.tar.gz mv ${{runner.temp}}/bun-webkit-linux-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-debug.tar.gz - mv ${{runner.temp}}/bun-webkit-linux-arm64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-debug.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-arm64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-debug.tar.gz mv ${{runner.temp}}/bun-webkit-macos-arm64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64-debug.tar.gz - mv ${{runner.temp}}/bun-webkit-macos-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64-debug.tar.gz + mv ${{runner.temp}}/bun-webkit-macos-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64-debug.tar.gz mv ${{runner.temp}}/bun-webkit-linux-amd64-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-lto.tar.gz mv ${{runner.temp}}/bun-webkit-linux-arm64-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-lto.tar.gz mv ${{runner.temp}}/bun-webkit-windows-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64.tar.gz From 24e8eabd270da67f14187c77f706964ca86c199e Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:22:51 -0700 Subject: [PATCH 06/17] fix labels here --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c31ab4616ed5..1f1fc900cd502 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -225,32 +225,32 @@ jobs: matrix: include: - lto_flag: "" - label: bun-webkit-linux-amd64-debug + label: bun-webkit-linux-amd64-musl-debug os: big-ubuntu package_json_arch: "x64" CMAKE_BUILD_TYPE: "Debug" - lto_flag: "" - label: bun-webkit-linux-arm64-debug + label: bun-webkit-linux-arm64-musl-debug os: linux-arm64-gh package_json_arch: "arm64" CMAKE_BUILD_TYPE: "Debug" - lto_flag: "-flto=full -fwhole-program-vtables -fforce-emit-vtables" - label: bun-webkit-linux-arm64-lto + label: bun-webkit-linux-arm64-musl-lto os: linux-arm64-gh package_json_arch: "arm64" CMAKE_BUILD_TYPE: "Release" - lto_flag: "" - label: bun-webkit-linux-arm64 + label: bun-webkit-linux-arm64-musl os: linux-arm64-gh package_json_arch: "arm64" CMAKE_BUILD_TYPE: "Release" - lto_flag: "-flto=full -fwhole-program-vtables -fforce-emit-vtables" - label: bun-webkit-linux-amd64-lto + label: bun-webkit-linux-amd64-musl-lto os: big-ubuntu package_json_arch: "x64" CMAKE_BUILD_TYPE: "Release" - lto_flag: "" - label: bun-webkit-linux-amd64 + label: bun-webkit-linux-amd64-musl os: big-ubuntu package_json_arch: "x64" CMAKE_BUILD_TYPE: "Release" From eb501c77f2b82be3c15511560dca77c18629158e Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:27:23 -0700 Subject: [PATCH 07/17] dockerfile fixes --- Dockerfile.musl | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Dockerfile.musl b/Dockerfile.musl index bbca73ab6310c..69d97f2f249ea 100644 --- a/Dockerfile.musl +++ b/Dockerfile.musl @@ -21,12 +21,18 @@ ENV CXX=clang++-18 ENV CC=clang-18 ENV LDFLAGS='-L/usr/include -L/usr/include/llvm18' ENV CXXFLAGS="-I/usr/include -I/usr/include/llvm18" -ENV PATH="/usr/bin:/usr/local/bin:/zig/bin:$PATH" +ENV PATH="/usr/bin:/usr/local/bin:/zig/bin:/usr/lib/llvm18/bin:$PATH" ENV CPU=${CPU} ENV MARCH_FLAG=${MARCH_FLAG} ENV WEBKIT_OUT_DIR=/webkitbuild RUN mkdir -p /output/lib /output/include /output/include/JavaScriptCore /output/include/wtf /output/include/bmalloc /output/include/unicode +ENV AR llvm-ar +ENV RANLIB llvm-ranlib +ENV LD lld +ENV LTO_FLAG="${LTO_FLAG}" +ENV WEBKIT_RELEASE_TYPE="${WEBKIT_RELEASE_TYPE}" + FROM base as build_icu ARG MARCH_FLAG @@ -39,14 +45,18 @@ ARG DEFAULT_CFLAGS RUN apk add --no-cache cpio curl icu-dev tar WORKDIR /icu-src -RUN --mount=type=tmpfs,target=/icu-src; curl -L https://github.com/unicode-org/icu/releases/download/release-75-1/icu4c-75_1-src.tgz > icu4c-75_1-src.tgz && \ - tar -xzf icu4c-75_1-src.tgz && \ - rm icu4c-75_1-src.tgz && \ - cd icu/source && \ - ./configure --enable-static --disable-shared && \ +ADD https://github.com/unicode-org/icu/releases/download/release-75-1/icu4c-75_1-src.tgz /icu.tgz +RUN --mount=type=tmpfs,target=/icu \ + export CFLAGS="${DEFAULT_CFLAGS} $CFLAGS -O3 -std=c17 $LTO_FLAG" && \ + export CXXFLAGS="${DEFAULT_CFLAGS} $CXXFLAGS -O3 -std=c++20 -fno-exceptions $LTO_FLAG -fno-c++-static-destructors " && \ + export LDFLAGS="-fuse-ld=lld " && \ + cd /icu && \ + tar -xf /icu.tgz --strip-components=1 && \ + rm /icu.tgz && \ + cd source && \ + ./configure --enable-static --disable-shared --with-data-packaging=static --disable-samples --disable-debug --disable-tests && \ make -j$(nproc) && \ - mkdir -p /icu && \ - cp -r lib/*.a /icu + make install && cp -r /icu/source/lib/* /output/lib && cp -r /icu/source/i18n/unicode/* /icu/source/common/unicode/* /output/include/unicode FROM base as build_webkit @@ -59,7 +69,7 @@ ARG DEFAULT_CFLAGS RUN apk add --no-cache cpio curl file gnupg icu-dev ninja ruby unzip rsync perl python3 openssl-dev openssl linux-headers -ENV WEBKIT_OUT_DIR=/webkit +ENV WEBKIT_OUT_DIR=/webkitbuild # These are unnecessary on musl # ENV CFLAGS="$CFLAGS -ffat-lto-objects" # ENV CXXFLAGS="$CXXFLAGS -ffat-lto-objects" @@ -77,7 +87,7 @@ RUN --mount=type=tmpfs,target=/webkitbuild \ -DPORT="JSCOnly" \ -DENABLE_STATIC_JSC=ON \ -DENABLE_BUN_SKIP_FAILING_ASSERTIONS=ON \ - -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_BUILD_TYPE=${WEBKIT_RELEASE_TYPE} \ -DUSE_THIN_ARCHIVES=OFF \ -DUSE_BUN_JSC_ADDITIONS=ON \ -DENABLE_FTL_JIT=ON \ @@ -94,7 +104,7 @@ RUN --mount=type=tmpfs,target=/webkitbuild \ -G Ninja \ /webkit && \ cd /webkitbuild && \ - cmake --build /webkitbuild --config Release --target "jsc" && \ + cmake --build /webkitbuild --config ${WEBKIT_RELEASE_TYPE} --target "jsc" && \ cp -r $WEBKIT_OUT_DIR/lib/*.a /output/lib && \ cp $WEBKIT_OUT_DIR/*.h /output/include && \ cp -r $WEBKIT_OUT_DIR/bin /output/bin && \ @@ -108,7 +118,6 @@ RUN --mount=type=tmpfs,target=/webkitbuild \ cp /webkit/Source/JavaScriptCore/create_hash_table /output/Source/JavaScriptCore && \ echo ""; -FROM alpine:edge as artifact +FROM scratch as artifact -COPY --from=build_webkit /webkit /webkit -COPY --from=build_icu /icu/*.a /webkit/lib +COPY --from=base /output / From f53126d13bcdf56ffac6ba23afc988fe541ee083 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:27:38 -0700 Subject: [PATCH 08/17] add musl artifacts to release --- .github/workflows/build.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f1fc900cd502..9111dc42b9558 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -345,21 +345,44 @@ jobs: with: name: bun-webkit-windows-amd64-debug path: ${{runner.temp}}/bun-webkit-windows-amd64-debug + - uses: actions/download-artifact@v3 + with: + name: bun-webkit-linux-amd64-musl + path: ${{runner.temp}}/bun-webkit-linux-amd64-musl + - uses: actions/download-artifact@v3 + with: + name: bun-webkit-linux-arm64-musl + path: ${{runner.temp}}/bun-webkit-linux-arm64-musl + - uses: actions/download-artifact@v3 + with: + name: bun-webkit-linux-amd64-musl-debug + path: ${{runner.temp}}/bun-webkit-linux-amd64-musl-debug + - uses: actions/download-artifact@v3 + with: + name: bun-webkit-linux-arm64-musl-debug + path: ${{runner.temp}}/bun-webkit-linux-arm64-musl-debug - name: Rename files run: | mv ${{runner.temp}}/bun-webkit-linux-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64.tar.gz mv ${{runner.temp}}/bun-webkit-linux-arm64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-amd64-musl/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-musl.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-arm64-musl/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-musl.tar.gz mv ${{runner.temp}}/bun-webkit-macos-arm64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64.tar.gz mv ${{runner.temp}}/bun-webkit-macos-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64.tar.gz mv ${{runner.temp}}/bun-webkit-linux-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-debug.tar.gz mv ${{runner.temp}}/bun-webkit-linux-arm64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-debug.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-amd64-musl-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-musl-debug.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-arm64-musl-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-musl-debug.tar.gz mv ${{runner.temp}}/bun-webkit-macos-arm64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64-debug.tar.gz mv ${{runner.temp}}/bun-webkit-macos-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64-debug.tar.gz mv ${{runner.temp}}/bun-webkit-linux-amd64-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-lto.tar.gz mv ${{runner.temp}}/bun-webkit-linux-arm64-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-lto.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto.tar.gz + mv ${{runner.temp}}/bun-webkit-linux-arm64-musl-lto/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-musl-lto.tar.gz mv ${{runner.temp}}/bun-webkit-windows-amd64/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64.tar.gz mv ${{runner.temp}}/bun-webkit-windows-amd64-debug/bun-webkit.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64-debug.tar.gz + - name: Release uses: softprops/action-gh-release@v1 id: release @@ -369,13 +392,19 @@ jobs: files: | ${{runner.temp}}/bun-webkit-linux-amd64-debug.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-debug.tar.gz + ${{runner.temp}}/bun-webkit-linux-amd64-musl-debug.tar.gz + ${{runner.temp}}/bun-webkit-linux-amd64-musl-debug.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64-debug.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64-debug.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64.tar.gz + ${{runner.temp}}/bun-webkit-linux-amd64-musl.tar.gz + ${{runner.temp}}/bun-webkit-linux-amd64-musl.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-lto.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-lto.tar.gz + ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto.tar.gz + ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64-debug.tar.gz From 82924af26d55a7ae32970f1f9062df7874375d80 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:28:59 -0700 Subject: [PATCH 09/17] add push events back --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9111dc42b9558..b739b4db231d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,9 @@ env: # Controls when the workflow will run on: + # Triggers the workflow on push or pull request events + push: + # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: From f1952f397171e6b9e7162d49739448096375ffbe Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:34:11 -0700 Subject: [PATCH 10/17] diff in this file too --- musl-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/musl-release.sh b/musl-release.sh index 6e1041d3cbd9d..f32d58a509ebc 100644 --- a/musl-release.sh +++ b/musl-release.sh @@ -43,4 +43,4 @@ fi mkdir -p $temp rm -rf $temp/bun-webkit -docker buildx build -f Dockerfile.musl -t $CONTAINER_NAME --build-arg LTO_FLAG="$LTO_FLAG" --build-arg WEBKIT_RELEASE_TYPE=$WEBKIT_RELEASE_TYPE --build-arg DEBIAN_VERSION=$DEBIAN_VERSION --progress=plain --platform=linux/$BUILDKIT_ARCH --target=artifact --output type=local,dest=$temp/bun-webkit . +docker buildx build -f Dockerfile.musl -t $CONTAINER_NAME --build-arg LTO_FLAG="$LTO_FLAG" --build-arg WEBKIT_RELEASE_TYPE=$WEBKIT_RELEASE_TYPE --progress=plain --platform=linux/$BUILDKIT_ARCH --target=artifact --output type=local,dest=$temp/bun-webkit . From 372cbe56235da98009a42d7ba83cd685c4a6bb85 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:46:11 -0700 Subject: [PATCH 11/17] wrong copy --- Dockerfile.musl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.musl b/Dockerfile.musl index 69d97f2f249ea..f90032232a635 100644 --- a/Dockerfile.musl +++ b/Dockerfile.musl @@ -120,4 +120,4 @@ RUN --mount=type=tmpfs,target=/webkitbuild \ FROM scratch as artifact -COPY --from=base /output / +COPY --from=build_webkit /output / From d3cddc25d75591ed80ecad7be29c055abf2776ec Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:56:04 -0700 Subject: [PATCH 12/17] disable fail-fast --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b739b4db231d2..a44c349539f66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,7 @@ jobs: runs-on: ${{ matrix.runner }} timeout-minutes: 90 strategy: + fail-fast: false matrix: include: - runner: macos-13-large @@ -114,6 +115,7 @@ jobs: name: Linux runs-on: ${{matrix.os}} strategy: + fail-fast: false matrix: include: - lto_flag: "" @@ -178,6 +180,7 @@ jobs: windows: strategy: + fail-fast: false matrix: include: - runner: windows @@ -225,6 +228,7 @@ jobs: name: Linux runs-on: ${{matrix.os}} strategy: + fail-fast: false matrix: include: - lto_flag: "" From 5b4ba0f6e3d3f673a580254d1aa8b005a00de01e Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 00:59:39 -0700 Subject: [PATCH 13/17] hardcode icu output prefix --- Dockerfile.musl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.musl b/Dockerfile.musl index f90032232a635..5623cef5d66e6 100644 --- a/Dockerfile.musl +++ b/Dockerfile.musl @@ -54,7 +54,7 @@ RUN --mount=type=tmpfs,target=/icu \ tar -xf /icu.tgz --strip-components=1 && \ rm /icu.tgz && \ cd source && \ - ./configure --enable-static --disable-shared --with-data-packaging=static --disable-samples --disable-debug --disable-tests && \ + ./configure --enable-static --disable-shared --with-data-packaging=static --disable-samples --disable-debug --disable-tests --prefix=/icu && \ make -j$(nproc) && \ make install && cp -r /icu/source/lib/* /output/lib && cp -r /icu/source/i18n/unicode/* /icu/source/common/unicode/* /output/include/unicode From 6baeca8a3ca132390117d38939114946c87c4130 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 01:13:56 -0700 Subject: [PATCH 14/17] another icu fix --- Dockerfile.musl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile.musl b/Dockerfile.musl index 5623cef5d66e6..13ca2cc67c0ea 100644 --- a/Dockerfile.musl +++ b/Dockerfile.musl @@ -44,7 +44,6 @@ ARG DEFAULT_CFLAGS RUN apk add --no-cache cpio curl icu-dev tar -WORKDIR /icu-src ADD https://github.com/unicode-org/icu/releases/download/release-75-1/icu4c-75_1-src.tgz /icu.tgz RUN --mount=type=tmpfs,target=/icu \ export CFLAGS="${DEFAULT_CFLAGS} $CFLAGS -O3 -std=c17 $LTO_FLAG" && \ @@ -54,7 +53,7 @@ RUN --mount=type=tmpfs,target=/icu \ tar -xf /icu.tgz --strip-components=1 && \ rm /icu.tgz && \ cd source && \ - ./configure --enable-static --disable-shared --with-data-packaging=static --disable-samples --disable-debug --disable-tests --prefix=/icu && \ + ./configure --enable-static --disable-shared --with-data-packaging=static --disable-samples --disable-debug --disable-tests && \ make -j$(nproc) && \ make install && cp -r /icu/source/lib/* /output/lib && cp -r /icu/source/i18n/unicode/* /icu/source/common/unicode/* /output/include/unicode @@ -76,7 +75,7 @@ ENV WEBKIT_OUT_DIR=/webkitbuild COPY . /webkit WORKDIR /webkit -COPY --from=build_icu /icu /icu +COPY --from=build_icu /output /icu RUN --mount=type=tmpfs,target=/webkitbuild \ export CFLAGS="${DEFAULT_CFLAGS} $CFLAGS $LTO_FLAG -ffile-prefix-map=/webkit/Source=src/bun.js/WebKit/Source -ffile-prefix-map=/webkitbuild/=. " && \ From 6db6e86d051c0902666f30955caecabd77f6fcf5 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 14:30:38 -0700 Subject: [PATCH 15/17] Apply suggestions from code review Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a44c349539f66..c2e673afd0264 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -297,7 +297,7 @@ jobs: contents: write runs-on: ubuntu-latest timeout-minutes: 90 - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/main' needs: - linux - macos @@ -400,18 +400,18 @@ jobs: ${{runner.temp}}/bun-webkit-linux-amd64-debug.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-debug.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-musl-debug.tar.gz - ${{runner.temp}}/bun-webkit-linux-amd64-musl-debug.tar.gz + ${{runner.temp}}/bun-webkit-linux-arm64-musl-debug.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64-debug.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64-debug.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-musl.tar.gz - ${{runner.temp}}/bun-webkit-linux-amd64-musl.tar.gz + ${{runner.temp}}/bun-webkit-linux-arm64-musl.tar.gz ${{runner.temp}}/bun-webkit-macos-arm64.tar.gz ${{runner.temp}}/bun-webkit-macos-amd64.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-lto.tar.gz ${{runner.temp}}/bun-webkit-linux-arm64-lto.tar.gz ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto.tar.gz - ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto.tar.gz + ${{runner.temp}}/bun-webkit-linux-arm64-musl-lto.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64.tar.gz ${{runner.temp}}/bun-webkit-windows-amd64-debug.tar.gz From 2f92351f31d64d3b0e6daa59be1d6c8e4a99c919 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 15:06:38 -0700 Subject: [PATCH 16/17] [skip ci] Update .github/workflows/build.yml --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2e673afd0264..114d6cd211525 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -368,6 +368,14 @@ jobs: with: name: bun-webkit-linux-arm64-musl-debug path: ${{runner.temp}}/bun-webkit-linux-arm64-musl-debug + - uses: actions/download-artifact@v3 + with: + name: bun-webkit-linux-amd64-musl-debug + path: ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto + - uses: actions/download-artifact@v3 + with: + name: bun-webkit-linux-arm64-musl-debug + path: ${{runner.temp}}/bun-webkit-linux-arm64-musl-lto - name: Rename files run: | From 3857d1786c20d497c903f06390519e56500e6d35 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 29 Oct 2024 15:40:58 -0700 Subject: [PATCH 17/17] [skip ci] add fail-fast back --- .github/workflows/build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 114d6cd211525..35751767198ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,6 @@ jobs: runs-on: ${{ matrix.runner }} timeout-minutes: 90 strategy: - fail-fast: false matrix: include: - runner: macos-13-large @@ -115,7 +114,6 @@ jobs: name: Linux runs-on: ${{matrix.os}} strategy: - fail-fast: false matrix: include: - lto_flag: "" @@ -180,7 +178,6 @@ jobs: windows: strategy: - fail-fast: false matrix: include: - runner: windows @@ -228,7 +225,6 @@ jobs: name: Linux runs-on: ${{matrix.os}} strategy: - fail-fast: false matrix: include: - lto_flag: ""