-
Notifications
You must be signed in to change notification settings - Fork 45
[JSCOnly] Add FreeBSD cross-compile target #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
547a22f
6dbb14f
c0f8901
621cd4a
55a5c39
c3475f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -422,6 +422,59 @@ jobs: | |
| name: ${{matrix.label}} | ||
| path: ${{runner.temp}}/bun-webkit.tar.gz | ||
|
|
||
| freebsd: | ||
| name: FreeBSD | ||
| # Cross-compiled from a Linux host via clang --target + base.txz sysroot, | ||
| # so all FreeBSD targets build on x64 regardless of target arch. | ||
| runs-on: linux-x64-gh | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - label: bun-webkit-freebsd-amd64 | ||
| freebsd_arch: x86_64 | ||
| package_json_arch: "x64" | ||
| CMAKE_BUILD_TYPE: "Release" | ||
| - label: bun-webkit-freebsd-amd64-debug | ||
| freebsd_arch: x86_64 | ||
| package_json_arch: "x64" | ||
| CMAKE_BUILD_TYPE: "Debug" | ||
| - label: bun-webkit-freebsd-arm64 | ||
| freebsd_arch: aarch64 | ||
| package_json_arch: "arm64" | ||
| CMAKE_BUILD_TYPE: "Release" | ||
| - label: bun-webkit-freebsd-arm64-debug | ||
| freebsd_arch: aarch64 | ||
| package_json_arch: "arm64" | ||
| CMAKE_BUILD_TYPE: "Debug" | ||
| timeout-minutes: 90 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ inputs.build_ref }} | ||
| 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 | ||
| FREEBSD_ARCH="${{matrix.freebsd_arch}}" WEBKIT_RELEASE_TYPE="${{matrix.CMAKE_BUILD_TYPE}}" temp=${{runner.temp}} bash freebsd-release.sh | ||
| cd ${{runner.temp}} | ||
| echo "#define BUN_WEBKIT_VERSION \"${{ inputs.build_ref }}\"" >> bun-webkit/include/cmakeconfig.h | ||
| echo '{ "name": "${{matrix.label}}", "version": "0.0.1-${{ inputs.build_ref }}", "os": ["freebsd"], "cpu": ["${{matrix.package_json_arch}}"], "repository": "https://github.com/${{github.repository}}" }' > bun-webkit/package.json | ||
| rm -rf bun-webkit/lib/*.so bun-webkit/lib/*.so.* | ||
| tar -czf bun-webkit.tar.gz bun-webkit | ||
| rm -rf bun-webkit | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{matrix.label}} | ||
| path: ${{runner.temp}}/bun-webkit.tar.gz | ||
|
|
||
| linux-android: | ||
| name: Linux Android | ||
| # NDK only ships linux-x86_64 prebuilts, so all Android targets | ||
|
|
@@ -487,6 +540,7 @@ jobs: | |
| - windows | ||
| - linux-musl | ||
| - linux-android | ||
| - freebsd | ||
| outputs: | ||
| tag: ${{ steps.release_info.outputs.tag }} | ||
| steps: | ||
|
|
@@ -640,6 +694,22 @@ jobs: | |
| with: | ||
| name: bun-webkit-linux-amd64-android-debug | ||
| path: ${{runner.temp}}/bun-webkit-linux-amd64-android-debug | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: bun-webkit-freebsd-amd64 | ||
| path: ${{runner.temp}}/bun-webkit-freebsd-amd64 | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: bun-webkit-freebsd-amd64-debug | ||
| path: ${{runner.temp}}/bun-webkit-freebsd-amd64-debug | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: bun-webkit-freebsd-arm64 | ||
| path: ${{runner.temp}}/bun-webkit-freebsd-arm64 | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: bun-webkit-freebsd-arm64-debug | ||
| path: ${{runner.temp}}/bun-webkit-freebsd-arm64-debug | ||
|
|
||
| - name: Rename files | ||
| run: | | ||
|
|
@@ -679,6 +749,10 @@ jobs: | |
| mv ${{runner.temp}}/bun-webkit-linux-arm64-android-debug/bun-webkit.tar.gz ./out/bun-webkit-linux-arm64-android-debug.tar.gz | ||
| mv ${{runner.temp}}/bun-webkit-linux-amd64-android/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-android.tar.gz | ||
| mv ${{runner.temp}}/bun-webkit-linux-amd64-android-debug/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-android-debug.tar.gz | ||
| mv ${{runner.temp}}/bun-webkit-freebsd-amd64/bun-webkit.tar.gz ./out/bun-webkit-freebsd-amd64.tar.gz | ||
| mv ${{runner.temp}}/bun-webkit-freebsd-amd64-debug/bun-webkit.tar.gz ./out/bun-webkit-freebsd-amd64-debug.tar.gz | ||
| mv ${{runner.temp}}/bun-webkit-freebsd-arm64/bun-webkit.tar.gz ./out/bun-webkit-freebsd-arm64.tar.gz | ||
| mv ${{runner.temp}}/bun-webkit-freebsd-arm64-debug/bun-webkit.tar.gz ./out/bun-webkit-freebsd-arm64-debug.tar.gz | ||
|
|
||
| - name: Set release info | ||
| id: release_info | ||
|
|
@@ -731,6 +805,15 @@ jobs: | |
| ./out/bun-webkit-linux-amd64-android.tar.gz | ||
| ./out/bun-webkit-linux-amd64-android-debug.tar.gz | ||
|
|
||
| - uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ inputs.release_tag }} | ||
| files: | | ||
| ./out/bun-webkit-freebsd-amd64.tar.gz | ||
| ./out/bun-webkit-freebsd-amd64-debug.tar.gz | ||
| ./out/bun-webkit-freebsd-arm64.tar.gz | ||
| ./out/bun-webkit-freebsd-arm64-debug.tar.gz | ||
|
Comment on lines
+808
to
+815
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's read the workflow file around the specified lines
wc -l .github/workflows/build-reusable.ymlRepository: oven-sh/WebKit Length of output: 99 🏁 Script executed: # Read the context around lines 808-815
sed -n '800,820p' .github/workflows/build-reusable.ymlRepository: oven-sh/WebKit Length of output: 835 🏁 Script executed: # Search for all uses of softprops/action-gh-release in the workflow file
rg "softprops/action-gh-release" .github/workflows/build-reusable.yml -n -A 10Repository: oven-sh/WebKit Length of output: 3083 🏁 Script executed: # Search for actionlint config or mentions in the repo
fd actionlintRepository: oven-sh/WebKit Length of output: 40 🏁 Script executed: # Check for any linting configuration files
fd -e yaml -e yml | rg -i "actionlint|action" | head -20Repository: oven-sh/WebKit Length of output: 360 🏁 Script executed: # Look for GitHub Actions documentation or version constraints
rg "action-gh-release" . --type yaml -B 2 -A 10 | head -50Repository: oven-sh/WebKit Length of output: 40 🏁 Script executed: # Check if there's any actionlint configuration in common locations
ls -la .github/ | grep -i actionRepository: oven-sh/WebKit Length of output: 40 🏁 Script executed: # Look for any workflow linting or CI configuration
find .github -type f -name "*.yml" -o -name "*.yaml" | xargs grep -l "actionlint" 2>/dev/nullRepository: oven-sh/WebKit Length of output: 42 🌐 Web query:
💡 Result: softprops/action-gh-release v1 and v2 are major versions of this GitHub Action for creating GitHub Releases. v1 was originally implemented as a Docker container, limiting it to Linux runners only, and required a 'docker://' prefix in some usages. v2 (starting around 2024 with v2.0.0) rewrote it as a JavaScript/TypeScript action for cross-platform support (Linux, Windows, macOS), removed the Docker dependency (no more 'docker://' prefix needed), upgraded the Node runtime (e.g., to node16 then node20), fixed deprecations like set-output warnings, added/improved inputs like make_latest, previous_tag, working_directory, discussion_category_name, append_body, and enhanced features like better asset handling, error recovery, generate_release_notes support, and numerous bug fixes (e.g., concurrent uploads, prerelease behavior). v1 is effectively legacy/outdated; upgrade to v2 (latest v2.6.2 as of 2026-04) or v3 (Node 24). No explicit deprecation notice for v1, but Dependabot auto-upgrades from v1 to v2, and docs/examples use v2/v3. Citations:
Use The FreeBSD release step at lines 808-815 (and all other uses of Proposed fix for FreeBSD section- - uses: softprops/action-gh-release@v1
+ - uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.release_tag }}
files: |
./out/bun-webkit-freebsd-amd64.tar.gz
./out/bun-webkit-freebsd-amd64-debug.tar.gz
./out/bun-webkit-freebsd-arm64.tar.gz
./out/bun-webkit-freebsd-arm64-debug.tar.gz🧰 Tools🪛 actionlint (1.7.12)[error] 808-808: the runner of "softprops/action-gh-release@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) 🤖 Prompt for AI Agents |
||
|
|
||
| - uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: ${{ inputs.release_tag }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,177 @@ | ||||||||||||||||||||||||||
| ARG MARCH_FLAG="-march=haswell" | ||||||||||||||||||||||||||
| ARG WEBKIT_RELEASE_TYPE=Release | ||||||||||||||||||||||||||
| ARG LTO_FLAG="" | ||||||||||||||||||||||||||
| ARG LLVM_VERSION="21" | ||||||||||||||||||||||||||
| ARG FREEBSD_VERSION="14.3" | ||||||||||||||||||||||||||
| ARG FREEBSD_ARCH="x86_64" | ||||||||||||||||||||||||||
|
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default
Consider adding validation or using an empty default: 🔧 Suggested fix-ARG MARCH_FLAG="-march=haswell"
+ARG MARCH_FLAG=""Alternatively, add a build-time check similar to line 50's architecture validation. 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Checkov (3.2.524)[low] 1-183: Ensure that HEALTHCHECK instructions have been added to container images (CKV_DOCKER_2) [low] 1-183: Ensure that a user for the container has been created (CKV_DOCKER_3) 🪛 Trivy (0.69.3)[error] 1-1: Image user should not be 'root' Specify at least 1 USER command in Dockerfile with non-root user as argument Rule: DS-0002 (IaC/Dockerfile) [info] 1-1: No HEALTHCHECK defined Add HEALTHCHECK instruction in your Dockerfile Rule: DS-0026 (IaC/Dockerfile) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| ARG DEFAULT_CFLAGS="-mno-omit-leaf-frame-pointer -g -fno-omit-frame-pointer -ffunction-sections -fdata-sections -faddrsig -fno-unwind-tables -fno-asynchronous-unwind-tables -DU_STATIC_IMPLEMENTATION=1 " | ||||||||||||||||||||||||||
| ARG ICU_VERSION="75_1" | ||||||||||||||||||||||||||
| ARG ICU_RELEASE_TAG="release-75-1" | ||||||||||||||||||||||||||
| ARG ICU_SHA256="cb968df3e4d2e87e8b11c49a5d01c787bd13b9545280fc6642f826527618caef" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| FROM ubuntu:24.04 AS base | ||||||||||||||||||||||||||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ARG LLVM_VERSION | ||||||||||||||||||||||||||
| ARG FREEBSD_VERSION | ||||||||||||||||||||||||||
| ARG FREEBSD_ARCH | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||||||||||||||||||||||||||
| wget unzip xz-utils ca-certificates \ | ||||||||||||||||||||||||||
| cmake ninja-build make git \ | ||||||||||||||||||||||||||
| ruby ruby-getoptlong perl python3 rsync file cpio \ | ||||||||||||||||||||||||||
| lsb-release software-properties-common gnupg \ | ||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Host clang (same version Bun uses) — we cross-compile via --target/--sysroot. | ||||||||||||||||||||||||||
| # apt.llvm.org installs version-suffixed names only, so add unversioned links | ||||||||||||||||||||||||||
| # for -fuse-ld=lld. | ||||||||||||||||||||||||||
| RUN wget -qO- https://apt.llvm.org/llvm.sh | bash -s -- ${LLVM_VERSION} && \ | ||||||||||||||||||||||||||
| for t in clang clang++ ld.lld lld llvm-ar llvm-ranlib; do \ | ||||||||||||||||||||||||||
| ln -sf /usr/bin/${t}-${LLVM_VERSION} /usr/local/bin/${t}; \ | ||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||
|
Comment on lines
+33
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: The recommended apt.llvm.org installation flow that avoids piping llvm.sh to bash is: wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh [version] To install all packages: sudo ./llvm.sh [version] all (or sudo ./llvm.sh all for latest stable). No official checksum or signature files are published for llvm.sh itself on apt.llvm.org; verification relies on HTTPS/TLS and the repo GPG key at https://apt.llvm.org/llvm-snapshot.gpg.key (fingerprint: 6084 F3CF 814B 57C1 CF12 EFD5 15CF 4D18 AF4F 7421). Source packages in the repos use sigstore/rekor for verification. Official checksum/signature files for FreeBSD 14.3-RELEASE base.txz (and other install sets) are published at https://www.freebsd.org/releases/14.3R/signatures/ as PGP-signed SHA512 and SHA256 checksum files per architecture (e.g., SHA512 for amd64 base.txz, etc.). Citations:
Verify downloaded toolchain and sysroot using published checksums before using them in release builds. Lines 29–32 pipe a network-fetched script directly into Lines 42–50 extract This stage produces published prebuilts; unverified inputs introduce supply-chain risk. 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| ENV CC=clang-${LLVM_VERSION} | ||||||||||||||||||||||||||
| ENV CXX=clang++-${LLVM_VERSION} | ||||||||||||||||||||||||||
| ENV AR=llvm-ar-${LLVM_VERSION} | ||||||||||||||||||||||||||
| ENV RANLIB=llvm-ranlib-${LLVM_VERSION} | ||||||||||||||||||||||||||
| ENV LD=lld-${LLVM_VERSION} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # FreeBSD sysroot — extract base.txz (libc, libc++, headers, crt files, | ||||||||||||||||||||||||||
| # compiler-rt). FreeBSD ships its own libc++ in base, so /usr/include/c++/v1 | ||||||||||||||||||||||||||
| # and /usr/lib/libc++.* come from here. | ||||||||||||||||||||||||||
| RUN set -eux; \ | ||||||||||||||||||||||||||
| case "${FREEBSD_ARCH}" in \ | ||||||||||||||||||||||||||
| x86_64) FBSD_DL_ARCH="amd64" ;; \ | ||||||||||||||||||||||||||
| aarch64) FBSD_DL_ARCH="arm64" ;; \ | ||||||||||||||||||||||||||
| *) echo "unsupported FREEBSD_ARCH ${FREEBSD_ARCH}" >&2; exit 1 ;; \ | ||||||||||||||||||||||||||
| esac; \ | ||||||||||||||||||||||||||
| mkdir -p /opt/freebsd-sysroot; \ | ||||||||||||||||||||||||||
| wget -q "https://download.freebsd.org/releases/${FBSD_DL_ARCH}/${FREEBSD_VERSION}-RELEASE/base.txz" -O /tmp/base.txz; \ | ||||||||||||||||||||||||||
| tar -C /opt/freebsd-sysroot -xJf /tmp/base.txz ./usr/include ./usr/lib ./lib; \ | ||||||||||||||||||||||||||
| rm /tmp/base.txz | ||||||||||||||||||||||||||
| ENV FREEBSD_SYSROOT=/opt/freebsd-sysroot | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Sanity check. FreeBSD's base ships builtins as /usr/lib/libgcc.a (it IS | ||||||||||||||||||||||||||
| # compiler-rt, renamed for ABI compat) and clang's freebsd driver finds it | ||||||||||||||||||||||||||
| # via --sysroot, so no resource-dir symlinking is needed (unlike Android). | ||||||||||||||||||||||||||
| RUN echo 'int main(){return 0;}' | $CC --target=${FREEBSD_ARCH}-unknown-freebsd${FREEBSD_VERSION} --sysroot=$FREEBSD_SYSROOT -fuse-ld=lld -xc - -o /tmp/t && file /tmp/t | grep -q FreeBSD | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RUN mkdir -p /output/lib /output/include /output/include/JavaScriptCore /output/include/wtf /output/include/bmalloc /output/include/unicode | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # ─────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||
| # ICU — cross-compiled. Same two-stage host/target build as Android: host | ||||||||||||||||||||||||||
| # tools first, then --with-cross-build. | ||||||||||||||||||||||||||
| # ─────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||
| FROM base AS build_icu | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ARG MARCH_FLAG | ||||||||||||||||||||||||||
| ARG LTO_FLAG | ||||||||||||||||||||||||||
| ARG DEFAULT_CFLAGS | ||||||||||||||||||||||||||
| ARG FREEBSD_VERSION | ||||||||||||||||||||||||||
| ARG FREEBSD_ARCH | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ARG ICU_VERSION | ||||||||||||||||||||||||||
| ARG ICU_RELEASE_TAG | ||||||||||||||||||||||||||
| ARG ICU_SHA256 | ||||||||||||||||||||||||||
| ADD --checksum=sha256:${ICU_SHA256} https://github.com/unicode-org/icu/releases/download/${ICU_RELEASE_TAG}/icu4c-${ICU_VERSION}-src.tgz /icu.tgz | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Host build (tools only — no LTO, fast). | ||||||||||||||||||||||||||
| RUN mkdir -p /icu-host && cd /icu-host \ | ||||||||||||||||||||||||||
| && tar -xf /icu.tgz --strip-components=1 \ | ||||||||||||||||||||||||||
| && cd source \ | ||||||||||||||||||||||||||
| && CC=$CC CXX=$CXX CFLAGS="-Os" CXXFLAGS="-Os" \ | ||||||||||||||||||||||||||
| ./configure --disable-shared --enable-static --disable-samples --disable-tests \ | ||||||||||||||||||||||||||
| && make -j$(nproc) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Target build. | ||||||||||||||||||||||||||
| RUN --mount=type=tmpfs,target=/icu \ | ||||||||||||||||||||||||||
| export TARGET_TRIPLE="${FREEBSD_ARCH}-unknown-freebsd${FREEBSD_VERSION}" && \ | ||||||||||||||||||||||||||
| export CROSS_FLAGS="--target=${TARGET_TRIPLE} --sysroot=${FREEBSD_SYSROOT}" && \ | ||||||||||||||||||||||||||
| export CFLAGS="${CROSS_FLAGS} ${DEFAULT_CFLAGS} ${MARCH_FLAG} -Os -std=c17 ${LTO_FLAG}" && \ | ||||||||||||||||||||||||||
| export CXXFLAGS="${CROSS_FLAGS} ${DEFAULT_CFLAGS} ${MARCH_FLAG} -Os -std=c++20 -fno-exceptions ${LTO_FLAG} -fno-c++-static-destructors" && \ | ||||||||||||||||||||||||||
| export LDFLAGS="${CROSS_FLAGS} -fuse-ld=lld" && \ | ||||||||||||||||||||||||||
| cd /icu && tar -xf /icu.tgz --strip-components=1 && rm /icu.tgz && cd source && \ | ||||||||||||||||||||||||||
| { ./configure --host=${FREEBSD_ARCH}-unknown-freebsd${FREEBSD_VERSION} \ | ||||||||||||||||||||||||||
| --with-cross-build=/icu-host/source \ | ||||||||||||||||||||||||||
| --enable-static --disable-shared --with-data-packaging=static \ | ||||||||||||||||||||||||||
| --disable-samples --disable-tests --disable-debug \ | ||||||||||||||||||||||||||
| || { cat config.log; exit 1; }; } && \ | ||||||||||||||||||||||||||
| make -j$(nproc) && \ | ||||||||||||||||||||||||||
| cp lib/*.a /output/lib && \ | ||||||||||||||||||||||||||
| cp -r i18n/unicode/* common/unicode/* /output/include/unicode | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # ─────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||
| # WebKit (JSCOnly) — cross-compiled. CMAKE_SYSTEM_NAME=FreeBSD is already | ||||||||||||||||||||||||||
| # handled in Source/WTF/wtf/PlatformJSCOnly.cmake (selects | ||||||||||||||||||||||||||
| # generic/MemoryFootprintGeneric.cpp + unix/MemoryPressureHandlerUnix.cpp), | ||||||||||||||||||||||||||
| # and __FreeBSD__ is defined by --target=*-freebsd*. | ||||||||||||||||||||||||||
| # ─────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||||||||||
| FROM base AS build_webkit | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ARG MARCH_FLAG | ||||||||||||||||||||||||||
| ARG WEBKIT_RELEASE_TYPE | ||||||||||||||||||||||||||
| ARG LTO_FLAG | ||||||||||||||||||||||||||
| ARG DEFAULT_CFLAGS | ||||||||||||||||||||||||||
| ARG FREEBSD_VERSION | ||||||||||||||||||||||||||
| ARG FREEBSD_ARCH | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| COPY . /webkit | ||||||||||||||||||||||||||
| WORKDIR /webkit | ||||||||||||||||||||||||||
| COPY --from=build_icu /output /icu | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ENV WEBKIT_OUT_DIR=/webkitbuild | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RUN --mount=type=tmpfs,target=/webkitbuild \ | ||||||||||||||||||||||||||
| export TARGET_TRIPLE="${FREEBSD_ARCH}-unknown-freebsd${FREEBSD_VERSION}" && \ | ||||||||||||||||||||||||||
| export CROSS="--target=${TARGET_TRIPLE} --sysroot=${FREEBSD_SYSROOT}" && \ | ||||||||||||||||||||||||||
| export CFLAGS="${CROSS} ${DEFAULT_CFLAGS} ${MARCH_FLAG} ${LTO_FLAG} -isystem /icu/include -ffile-prefix-map=/webkit/Source=vendor/WebKit/Source -ffile-prefix-map=/webkitbuild/=." && \ | ||||||||||||||||||||||||||
| export CXXFLAGS="${CROSS} -isystem ${FREEBSD_SYSROOT}/usr/include/c++/v1 ${DEFAULT_CFLAGS} ${MARCH_FLAG} ${LTO_FLAG} -isystem /icu/include -fno-c++-static-destructors -ffile-prefix-map=/webkit/Source=vendor/WebKit/Source -ffile-prefix-map=/webkitbuild/=." && \ | ||||||||||||||||||||||||||
| cd /webkitbuild && \ | ||||||||||||||||||||||||||
| cmake \ | ||||||||||||||||||||||||||
| -DCMAKE_SYSTEM_NAME=FreeBSD \ | ||||||||||||||||||||||||||
| -DCMAKE_SYSTEM_PROCESSOR=${FREEBSD_ARCH} \ | ||||||||||||||||||||||||||
| -DCMAKE_SYSROOT=${FREEBSD_SYSROOT} \ | ||||||||||||||||||||||||||
| -DCMAKE_C_COMPILER=$(which $CC) \ | ||||||||||||||||||||||||||
| -DCMAKE_CXX_COMPILER=$(which $CXX) \ | ||||||||||||||||||||||||||
| -DCMAKE_AR=$(which $AR) \ | ||||||||||||||||||||||||||
| -DCMAKE_RANLIB=$(which $RANLIB) \ | ||||||||||||||||||||||||||
| -DPORT=JSCOnly \ | ||||||||||||||||||||||||||
| -DENABLE_STATIC_JSC=ON \ | ||||||||||||||||||||||||||
| -DENABLE_BUN_SKIP_FAILING_ASSERTIONS=ON \ | ||||||||||||||||||||||||||
| -DCMAKE_BUILD_TYPE=${WEBKIT_RELEASE_TYPE} \ | ||||||||||||||||||||||||||
| -DUSE_THIN_ARCHIVES=OFF \ | ||||||||||||||||||||||||||
| -DUSE_BUN_JSC_ADDITIONS=ON \ | ||||||||||||||||||||||||||
| -DUSE_BUN_EVENT_LOOP=ON \ | ||||||||||||||||||||||||||
| -DENABLE_FTL_JIT=ON \ | ||||||||||||||||||||||||||
| -DENABLE_API_TESTS=OFF \ | ||||||||||||||||||||||||||
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | ||||||||||||||||||||||||||
| -DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \ | ||||||||||||||||||||||||||
| -DENABLE_REMOTE_INSPECTOR=ON \ | ||||||||||||||||||||||||||
| -DCMAKE_EXE_LINKER_FLAGS="${CROSS} -fuse-ld=lld" \ | ||||||||||||||||||||||||||
| -DCMAKE_C_FLAGS="$CFLAGS" \ | ||||||||||||||||||||||||||
| -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ | ||||||||||||||||||||||||||
| -DICU_ROOT=/icu \ | ||||||||||||||||||||||||||
| -DICU_INCLUDE_DIR=/icu/include \ | ||||||||||||||||||||||||||
| -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \ | ||||||||||||||||||||||||||
| -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \ | ||||||||||||||||||||||||||
| -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH \ | ||||||||||||||||||||||||||
|
Comment on lines
+161
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Use ONLY mode for CMAKE_FIND_ROOT_PATH_MODE_PACKAGE, CMAKE_FIND_ROOT_PATH_MODE_LIBRARY, and CMAKE_FIND_ROOT_PATH_MODE_INCLUDE when cross-compiling with CMAKE_SYSROOT set, to ensure CMake's find_* commands (find_package, find_library, find_path) search exclusively in the sysroot and CMAKE_FIND_ROOT_PATH directories for target libraries, headers, and packages. Use ONLY in strict cross-compilation scenarios where the sysroot contains all required target dependencies. This is the recommended best practice in toolchain files, as shown in official CMake documentation examples. It forces isolation from the host system, preventing CMake from finding incompatible target artifacts on the host. BOTH mode searches both sysroot paths first, then host system paths. Host-contamination risks include: - Linking against host libraries of wrong architecture, causing linker errors or runtime failures (e.g., x86_64 host lib vs ARM target). - Including host headers with mismatched APIs/versions/ABIs, leading to subtle bugs, compilation failures, or binaries depending on unavailable host-specific symbols on target. - Silent failures where builds succeed but produce broken binaries (e.g., wrong glibc versions, versioned symbols). - Particularly dangerous with package managers like Conan that may override to BOTH, allowing fallback to /usr/lib on host. Set in toolchain file example: set(CMAKE_SYSROOT /path/to/target/sysroot) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # host tools set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) Citations:
Restrict CMake package/library/header discovery to the FreeBSD sysroot. Using 🔧 Suggested change- -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
- -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
- -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=BOTH \
+ -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
+ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \If dependencies are discovered through pkg-config, also set 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| -G Ninja \ | ||||||||||||||||||||||||||
| /webkit && \ | ||||||||||||||||||||||||||
| 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 $WEBKIT_OUT_DIR/*.json /output && \ | ||||||||||||||||||||||||||
| find $WEBKIT_OUT_DIR/JavaScriptCore/DerivedSources/ -name "*.h" -exec sh -c 'cp "$1" "/output/include/JavaScriptCore/$(basename "$1")"' sh {} \; && \ | ||||||||||||||||||||||||||
| find $WEBKIT_OUT_DIR/JavaScriptCore/DerivedSources/ -name "*.json" -exec sh -c 'cp "$1" "/output/$(basename "$1")"' sh {} \; && \ | ||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| FROM scratch AS artifact | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| COPY --from=build_icu /output / | ||||||||||||||||||||||||||
| COPY --from=build_webkit /output / | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,15 @@ uint64_t pas_get_current_monotonic_time_nanoseconds(void) | |
| return ts.tv_sec * 1.0e9 + ts.tv_nsec; | ||
| } | ||
|
|
||
| #elif PAS_OS(FREEBSD) | ||
|
|
||
| uint64_t pas_get_current_monotonic_time_nanoseconds(void) | ||
| { | ||
| struct timespec ts; | ||
| clock_gettime(CLOCK_MONOTONIC_FAST, &ts); | ||
| return (uint64_t)ts.tv_sec * 1000ull * 1000ull * 1000ull + (uint64_t)ts.tv_nsec; | ||
| } | ||
|
Comment on lines
+91
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chain🏁 Script executed: find . -path "*libpas/pas_monotonic_time.c" -type fRepository: oven-sh/WebKit Length of output: 114 🏁 Script executed: cat -n ./Source/bmalloc/libpas/src/libpas/pas_monotonic_time.cRepository: oven-sh/WebKit Length of output: 4580 🏁 Script executed: cat -n ./Source/bmalloc/libpas/src/libpas/pas_monotonic_time.hRepository: oven-sh/WebKit Length of output: 1883 🏁 Script executed: head -100 ./Source/bmalloc/libpas/src/libpas/pas_config.hRepository: oven-sh/WebKit Length of output: 3386 🏁 Script executed: head -150 ./Source/bmalloc/libpas/src/libpas/pas_utils.h | grep -A 5 -B 5 "include"Repository: oven-sh/WebKit Length of output: 1415 Add explicit The FreeBSD implementation at lines 95-96 uses Proposed diff-#if PAS_OS(LINUX) || PAS_PLATFORM(PLAYSTATION)
+#if PAS_OS(LINUX) || PAS_OS(FREEBSD) || PAS_PLATFORM(PLAYSTATION)
`#include` <time.h>
`#endif`🤖 Prompt for AI Agents |
||
|
|
||
| #elif PAS_PLATFORM(PLAYSTATION) | ||
|
|
||
| uint64_t pas_get_current_monotonic_time_nanoseconds(void) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: oven-sh/WebKit
Length of output: 485
🌐 Web query:
docker/setup-buildx-action v2 v3 deprecation supported versions💡 Result:
The docker/setup-buildx-action GitHub Action has versions v2, v3, and v4. v2 is outdated and should be upgraded (examples show migration from v2 to v3). In v3.12.0 (Dec 2025), the 'install' input was deprecated due to upstream docker/buildx changes. v4.0.0 (Mar 2026, current latest as of Apr 2026) fully removes deprecated inputs/outputs including 'install', 'config', 'config-inline', and some outputs like 'endpoint', 'status', 'flags'. Use v4 with recent GitHub Actions runners (v2.327.1+ for Node 24 runtime). Official README examples use docker/setup-buildx-action@v4. v2 and v3 remain functional but lack latest features and fixes; migrate to v4 for support.
Citations:
Upgrade to
docker/setup-buildx-action@v4and remove the deprecatedinstallparameter.Line 459 uses
docker/setup-buildx-action@v2, which is outdated. The current version is v4 (as of Mar 2026). When upgrading, remove theinstall: trueparameter, which was deprecated in v3.12.0 and removed in v4.0.0.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 actionlint (1.7.12)
[error] 459-459: the runner of "docker/setup-buildx-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents