Skip to content

Commit 208d624

Browse files
committed
Initial commit
0 parents  commit 208d624

File tree

8 files changed

+825
-0
lines changed

8 files changed

+825
-0
lines changed

.github/workflows/build-reusable.yml

Lines changed: 637 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
# Check for updates every 6 hours
5+
schedule:
6+
- cron: '0 */6 * * *'
7+
8+
# Manual trigger with optional SHA override
9+
workflow_dispatch:
10+
inputs:
11+
webkit_sha:
12+
description: 'WebKit commit SHA to build (leave empty for latest main)'
13+
required: false
14+
default: ''
15+
force_build:
16+
description: 'Force build even if release exists'
17+
required: false
18+
default: 'false'
19+
type: boolean
20+
llvm_version:
21+
description: 'LLVM version'
22+
default: '19'
23+
24+
jobs:
25+
check:
26+
name: Check for Updates
27+
runs-on: ubuntu-latest
28+
outputs:
29+
should_build: ${{ steps.check.outputs.should_build }}
30+
webkit_sha: ${{ steps.check.outputs.webkit_sha }}
31+
release_tag: ${{ steps.check.outputs.release_tag }}
32+
steps:
33+
- name: Get latest WebKit SHA
34+
id: get_sha
35+
run: |
36+
if [ -n "${{ inputs.webkit_sha }}" ]; then
37+
SHA="${{ inputs.webkit_sha }}"
38+
else
39+
SHA=$(git ls-remote https://github.com/oven-sh/WebKit.git refs/heads/main | cut -f1)
40+
fi
41+
echo "sha=$SHA" >> $GITHUB_OUTPUT
42+
echo "Latest WebKit SHA: $SHA"
43+
44+
- name: Check if release exists
45+
id: check
46+
env:
47+
GH_TOKEN: ${{ github.token }}
48+
run: |
49+
SHA="${{ steps.get_sha.outputs.sha }}"
50+
RELEASE_TAG="autobuild-$SHA"
51+
52+
echo "webkit_sha=$SHA" >> $GITHUB_OUTPUT
53+
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
54+
55+
# Check if release already exists
56+
if [ "${{ inputs.force_build }}" = "true" ]; then
57+
echo "Force build requested"
58+
echo "should_build=true" >> $GITHUB_OUTPUT
59+
elif gh release view "$RELEASE_TAG" --repo ${{ github.repository }} > /dev/null 2>&1; then
60+
echo "Release $RELEASE_TAG already exists, skipping build"
61+
echo "should_build=false" >> $GITHUB_OUTPUT
62+
else
63+
echo "Release $RELEASE_TAG does not exist, triggering build"
64+
echo "should_build=true" >> $GITHUB_OUTPUT
65+
fi
66+
67+
build:
68+
name: Build and Release
69+
needs: check
70+
if: needs.check.outputs.should_build == 'true'
71+
permissions:
72+
contents: write
73+
uses: ./.github/workflows/build-reusable.yml
74+
with:
75+
webkit_sha: ${{ needs.check.outputs.webkit_sha }}
76+
release_tag: ${{ needs.check.outputs.release_tag }}
77+
is_prerelease: false
78+
llvm_version: ${{ inputs.llvm_version || '19' }}
79+

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# libbun-webkit
2+
3+
Bun's fork of WebKit with `-ftls-model=global-dynamic` for dlopen compatibility.
4+
5+
A workflow runs every 6hrs and publishes to GitHub actions for the latest sha on `oven-sh/WebKit`.

patches/001-webkit-runloop.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/Source/WTF/wtf/bun/RunLoopBun.cpp b/Source/WTF/wtf/bun/RunLoopBun.cpp
2+
index 744fb7508a0b..246be6438d7a 100644
3+
--- a/Source/WTF/wtf/bun/RunLoopBun.cpp
4+
+++ b/Source/WTF/wtf/bun/RunLoopBun.cpp
5+
@@ -202,6 +202,7 @@ void RunLoop::wakeUp()
6+
case Kind::Bun:
7+
// Do nothing. This means that JSRunLoopTimer::Manager::PerVMData's RunLoop::Timer leaks instead
8+
// of being freed.
9+
+ return;
10+
}
11+
}
12+
13+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/Dockerfile b/Dockerfile
2+
index 1111111..2222222 100644
3+
--- a/Dockerfile
4+
+++ b/Dockerfile
5+
@@ -4,7 +4,8 @@ ARG CPU=native
6+
ARG LTO_FLAG="-flto=full -fwhole-program-vtables -fforce-emit-vtables "
7+
ARG RELEASE_FLAGS="-O3 -DNDEBUG=1"
8+
ARG LLVM_VERSION="19"
9+
-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 "
10+
+# Added -ftls-model=global-dynamic for Node.js addon (dlopen) compatibility
11+
+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 -ftls-model=global-dynamic "
12+
ARG ENABLE_SANITIZERS=""
13+
14+
# Use different base images for ARM64 vs x86_64
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/Dockerfile.musl b/Dockerfile.musl
2+
index 1111111..2222222 100644
3+
--- a/Dockerfile.musl
4+
+++ b/Dockerfile.musl
5+
@@ -3,7 +3,8 @@ ARG WEBKIT_RELEASE_TYPE=Release
6+
ARG CPU=native
7+
ARG LTO_FLAG="-flto=full -fwhole-program-vtables -fforce-emit-vtables "
8+
ARG LLVM_VERSION="19"
9+
-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 "
10+
+# Added -ftls-model=global-dynamic for Node.js addon (dlopen) compatibility
11+
+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 -ftls-model=global-dynamic "
12+
13+
FROM alpine:3.21 as base
14+
15+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/mac-release.bash b/mac-release.bash
2+
index 1111111..2222222 100644
3+
--- a/mac-release.bash
4+
+++ b/mac-release.bash
5+
@@ -8,6 +8,9 @@
6+
7+
THIS_DIR=$(pwd)
8+
9+
+# Added for Node.js addon (dlopen) compatibility
10+
+LIBBUN_TLS_FLAG="-ftls-model=global-dynamic"
11+
+
12+
# Set default values for environment variables that are not set.
13+
CMAKE_C_COMPILER=${CMAKE_C_COMPILER:-clang-19}
14+
CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER:-clang++}
15+
@@ -40,8 +43,8 @@ cmake \
16+
-DPORT="JSCOnly" \
17+
-DENABLE_STATIC_JSC=ON \
18+
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
19+
-DENABLE_BUN_SKIP_FAILING_ASSERTIONS=ON \
20+
-DUSE_THIN_ARCHIVES=OFF \
21+
-DENABLE_FTL_JIT=ON \
22+
-DCMAKE_C_COMPILER="$CMAKE_C_COMPILER" \
23+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
24+
-DCMAKE_CXX_COMPILER="$CMAKE_CXX_COMPILER" \
25+
- -DCMAKE_C_FLAGS="-g $CMAKE_C_FLAGS -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
26+
- -DCMAKE_CXX_FLAGS="-g $CMAKE_CXX_FLAGS -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
27+
+ -DCMAKE_C_FLAGS="-g $CMAKE_C_FLAGS $LIBBUN_TLS_FLAG -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
28+
+ -DCMAKE_CXX_FLAGS="-g $CMAKE_CXX_FLAGS $LIBBUN_TLS_FLAG -ffile-prefix-map=$THIS_DIR/Source=vendor/WebKit/Source" \
29+
-DENABLE_MALLOC_HEAP_BREAKDOWN=$ENABLE_MALLOC_HEAP_BREAKDOWN \
30+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
31+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
diff --git a/windows-release.ps1 b/windows-release.ps1
2+
index 1111111..2222222 100644
3+
--- a/windows-release.ps1
4+
+++ b/windows-release.ps1
5+
@@ -168,6 +168,9 @@ Write-Host ":: Configuring WebKit"
6+
7+
$env:PATH = $PathWithPerl
8+
9+
+# Added for Node.js addon (dlopen) compatibility
10+
+$LibbunTlsFlag = "-Xclang -ftls-model=global-dynamic"
11+
+
12+
$env:CFLAGS = "/Zi"
13+
$env:CXXFLAGS = "/Zi"
14+
15+
@@ -201,10 +204,10 @@ cmake -S . -B $WebKitBuild `
16+
"-DICU_LIBRARY=${ICU_STATIC_LIBRARY}" `
17+
"-DICU_INCLUDE_DIR=${ICU_STATIC_INCLUDE_DIR}" `
18+
"-DCMAKE_C_COMPILER=clang-cl" `
19+
"-DCMAKE_CXX_COMPILER=clang-cl" `
20+
- "-DCMAKE_C_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG " `
21+
- "-DCMAKE_CXX_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG -Xclang -fno-c++-static-destructors " `
22+
- "-DCMAKE_C_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 " `
23+
- "-DCMAKE_CXX_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 -Xclang -fno-c++-static-destructors " `
24+
+ "-DCMAKE_C_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG $LibbunTlsFlag " `
25+
+ "-DCMAKE_CXX_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG $LibbunTlsFlag -Xclang -fno-c++-static-destructors " `
26+
+ "-DCMAKE_C_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 $LibbunTlsFlag " `
27+
+ "-DCMAKE_CXX_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 $LibbunTlsFlag -Xclang -fno-c++-static-destructors " `
28+
-DENABLE_REMOTE_INSPECTOR=ON `
29+
"-DCMAKE_MSVC_RUNTIME_LIBRARY=${CmakeMsvcRuntimeLibrary}" `
30+

0 commit comments

Comments
 (0)