Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 68 additions & 5 deletions .github/workflows/build-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ jobs:
package_json_arch: "x64"
CMAKE_BUILD_TYPE: "Release"
RELEASE_FLAGS: "-O3 -DNDEBUG=1"
- lto_flag: "-flto=full -fwhole-program-vtables -fforce-emit-vtables"
label: bun-webkit-linux-amd64-baseline-lto
os: linux-x64-gh
package_json_arch: "x64"
CMAKE_BUILD_TYPE: "Release"
RELEASE_FLAGS: "-O3 -DNDEBUG=1"
MARCH_FLAG: "-march=nehalem"
- lto_flag: ""
label: bun-webkit-linux-amd64-baseline
os: linux-x64-gh
package_json_arch: "x64"
CMAKE_BUILD_TYPE: "Release"
RELEASE_FLAGS: "-O3 -DNDEBUG=1"
MARCH_FLAG: "-march=nehalem"
- lto_flag: ""
label: bun-webkit-linux-amd64-asan
os: linux-x64-gh
Expand Down Expand Up @@ -218,8 +232,8 @@ jobs:
rm -rf ${{runner.temp}}/bun-webkit ${{runner.temp}}/bun-webkit.tar.gz
if [ "${{matrix.package_json_arch}}" = "arm64" ]; then
export MARCH_FLAG="-march=armv8-a+crc -mtune=ampere1"
elif [ "${{matrix.package_json_arch}}" = "x64" ]; then
export MARCH_FLAG="-march=nehalem"
else
export MARCH_FLAG="${{ matrix.MARCH_FLAG || '-march=haswell' }}"
fi
WEBKIT_RELEASE_TYPE=${{matrix.CMAKE_BUILD_TYPE}} CPU="native" cpu=native LTO_FLAG="${{matrix.lto_flag}}" temp=${{runner.temp}} ENABLE_SANITIZERS="${{matrix.ENABLE_SANITIZERS}}" bash release.sh
cd ${{runner.temp}}
Expand Down Expand Up @@ -248,6 +262,12 @@ jobs:
package_json_arch: "x64"
label: bun-webkit-windows-amd64-debug
platform: x64
- runner: windows
build-type: Release
package_json_arch: "x64"
label: bun-webkit-windows-amd64-baseline
platform: x64
baseline: true
- runner: windows-11-arm
build-type: Release
package_json_arch: "arm64"
Expand Down Expand Up @@ -312,7 +332,8 @@ jobs:
$env:GITHUB_SHA = "${{ inputs.build_ref }}"
$env:PACKAGE_JSON_ARCH = "${{matrix.package_json_arch}}"
$env:GITHUB_REPOSITORY = "${{ github.repository }}"
./windows-release.ps1 -Platform ${{matrix.platform}}
$baselineArg = if ("${{ matrix.baseline }}" -eq "true") { @("-Baseline") } else { @() }
./windows-release.ps1 -Platform ${{matrix.platform}} @baselineArg
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.label}}
Expand Down Expand Up @@ -354,6 +375,18 @@ jobs:
os: linux-x64-gh
package_json_arch: "x64"
CMAKE_BUILD_TYPE: "MinSizeRel"
- lto_flag: "-flto=full -fwhole-program-vtables -fforce-emit-vtables"
label: bun-webkit-linux-amd64-musl-baseline-lto
os: linux-x64-gh
package_json_arch: "x64"
CMAKE_BUILD_TYPE: "MinSizeRel"
MARCH_FLAG: "-march=nehalem"
- lto_flag: ""
label: bun-webkit-linux-amd64-musl-baseline
os: linux-x64-gh
package_json_arch: "x64"
CMAKE_BUILD_TYPE: "MinSizeRel"
MARCH_FLAG: "-march=nehalem"
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
Expand All @@ -373,8 +406,8 @@ jobs:
rm -rf ${{runner.temp}}/bun-webkit ${{runner.temp}}/bun-webkit.tar.gz
if [ "${{matrix.package_json_arch}}" = "arm64" ]; then
export MARCH_FLAG="-march=armv8-a+crc -mtune=ampere1"
elif [ "${{matrix.package_json_arch}}" = "x64" ]; then
export MARCH_FLAG="-march=nehalem"
else
export MARCH_FLAG="${{ matrix.MARCH_FLAG || '-march=haswell' }}"
fi
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}}
Expand Down Expand Up @@ -477,10 +510,22 @@ jobs:
with:
name: bun-webkit-linux-arm64-lto
path: ${{runner.temp}}/bun-webkit-linux-arm64-lto
- uses: actions/download-artifact@v4
with:
name: bun-webkit-linux-amd64-baseline
path: ${{runner.temp}}/bun-webkit-linux-amd64-baseline
- uses: actions/download-artifact@v4
with:
name: bun-webkit-linux-amd64-baseline-lto
path: ${{runner.temp}}/bun-webkit-linux-amd64-baseline-lto
- uses: actions/download-artifact@v4
with:
name: bun-webkit-windows-amd64
path: ${{runner.temp}}/bun-webkit-windows-amd64
- uses: actions/download-artifact@v4
with:
name: bun-webkit-windows-amd64-baseline
path: ${{runner.temp}}/bun-webkit-windows-amd64-baseline
- uses: actions/download-artifact@v4
with:
name: bun-webkit-windows-amd64-debug
Expand Down Expand Up @@ -517,6 +562,14 @@ jobs:
with:
name: bun-webkit-linux-arm64-musl-lto
path: ${{runner.temp}}/bun-webkit-linux-arm64-musl-lto
- uses: actions/download-artifact@v4
with:
name: bun-webkit-linux-amd64-musl-baseline
path: ${{runner.temp}}/bun-webkit-linux-amd64-musl-baseline
- uses: actions/download-artifact@v4
with:
name: bun-webkit-linux-amd64-musl-baseline-lto
path: ${{runner.temp}}/bun-webkit-linux-amd64-musl-baseline-lto

- name: Rename files
run: |
Expand All @@ -541,9 +594,14 @@ jobs:
mv ${{runner.temp}}/bun-webkit-macos-amd64-debug/bun-webkit.tar.gz ./out/bun-webkit-macos-amd64-debug.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-amd64-lto/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-lto.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-arm64-lto/bun-webkit.tar.gz ./out/bun-webkit-linux-arm64-lto.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-amd64-baseline/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-baseline.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-amd64-baseline-lto/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-baseline-lto.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-amd64-musl-lto/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-musl-lto.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-arm64-musl-lto/bun-webkit.tar.gz ./out/bun-webkit-linux-arm64-musl-lto.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-amd64-musl-baseline/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-musl-baseline.tar.gz
mv ${{runner.temp}}/bun-webkit-linux-amd64-musl-baseline-lto/bun-webkit.tar.gz ./out/bun-webkit-linux-amd64-musl-baseline-lto.tar.gz
mv ${{runner.temp}}/bun-webkit-windows-amd64/bun-webkit.tar.gz ./out/bun-webkit-windows-amd64.tar.gz
mv ${{runner.temp}}/bun-webkit-windows-amd64-baseline/bun-webkit.tar.gz ./out/bun-webkit-windows-amd64-baseline.tar.gz
mv ${{runner.temp}}/bun-webkit-windows-amd64-debug/bun-webkit.tar.gz ./out/bun-webkit-windows-amd64-debug.tar.gz
mv ${{runner.temp}}/bun-webkit-windows-arm64/bun-webkit.tar.gz ./out/bun-webkit-windows-arm64.tar.gz
mv ${{runner.temp}}/bun-webkit-windows-arm64-debug/bun-webkit.tar.gz ./out/bun-webkit-windows-arm64-debug.tar.gz
Expand All @@ -568,6 +626,8 @@ jobs:
./out/bun-webkit-linux-arm64.tar.gz
./out/bun-webkit-linux-amd64-lto.tar.gz
./out/bun-webkit-linux-arm64-lto.tar.gz
./out/bun-webkit-linux-amd64-baseline.tar.gz
./out/bun-webkit-linux-amd64-baseline-lto.tar.gz
./out/bun-webkit-linux-amd64-asan.tar.gz
./out/bun-webkit-linux-arm64-asan.tar.gz
./out/bun-webkit-linux-amd64-debug.tar.gz
Expand All @@ -583,6 +643,8 @@ jobs:
./out/bun-webkit-linux-arm64-musl.tar.gz
./out/bun-webkit-linux-amd64-musl-lto.tar.gz
./out/bun-webkit-linux-arm64-musl-lto.tar.gz
./out/bun-webkit-linux-amd64-musl-baseline.tar.gz
./out/bun-webkit-linux-amd64-musl-baseline-lto.tar.gz
./out/bun-webkit-linux-amd64-musl-debug.tar.gz
./out/bun-webkit-linux-arm64-musl-debug.tar.gz

Expand All @@ -602,6 +664,7 @@ jobs:
tag_name: ${{ inputs.release_tag }}
files: |
./out/bun-webkit-windows-amd64.tar.gz
./out/bun-webkit-windows-amd64-baseline.tar.gz
./out/bun-webkit-windows-amd64-debug.tar.gz
./out/bun-webkit-windows-arm64.tar.gz
./out/bun-webkit-windows-arm64-debug.tar.gz
14 changes: 13 additions & 1 deletion build-icu.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ param(
[ValidateSet("Release", "Debug")]
[string]$BuildType = "Release",

[string]$OutputDir = ""
[string]$OutputDir = "",

[switch]$Baseline
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -73,6 +75,12 @@ if (-not (Test-Path $ICU_SOURCE_DIR)) {
if ($LASTEXITCODE -ne 0) { throw "tar failed with exit code $LASTEXITCODE" }
}

if ($Platform -eq "x64") {
$ArchFlag = if ($Baseline) { "/arch:SSE2" } else { "/arch:AVX2" }
} else {
$ArchFlag = ""
}

# --- Function to patch vcxproj files for static library build with /MT ---
function Patch-IcuVcxProj {
param(
Expand Down Expand Up @@ -106,6 +114,10 @@ function Patch-IcuVcxProj {
$content = $content -replace '(<PreprocessorDefinitions>)', '$1U_STATIC_IMPLEMENTATION;'
}

if ($ArchFlag) {
$content = $content -replace '(<ClCompile>)', "`$1`n <AdditionalOptions>$ArchFlag %(AdditionalOptions)</AdditionalOptions>"
}
Comment on lines +117 to +119
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Make the vcxproj arch patch idempotent.

Line [118] always inserts a new <AdditionalOptions> node. Re-running in the same output tree can accumulate conflicting /arch: values.

♻️ Proposed fix
-    if ($ArchFlag) {
-        $content = $content -replace '(<ClCompile>)', "`$1`n      <AdditionalOptions>$ArchFlag %(AdditionalOptions)</AdditionalOptions>"
-    }
+    if ($ArchFlag) {
+        if ($content -match '/arch:(SSE2|AVX2)') {
+            $content = $content -replace '/arch:(SSE2|AVX2)', $ArchFlag
+        } else {
+            $content = $content -replace '(<ClCompile>)', "`$1`n      <AdditionalOptions>$ArchFlag %(AdditionalOptions)</AdditionalOptions>"
+        }
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ($ArchFlag) {
$content = $content -replace '(<ClCompile>)', "`$1`n <AdditionalOptions>$ArchFlag %(AdditionalOptions)</AdditionalOptions>"
}
if ($ArchFlag) {
if ($content -match '/arch:(SSE2|AVX2)') {
$content = $content -replace '/arch:(SSE2|AVX2)', $ArchFlag
} else {
$content = $content -replace '(<ClCompile>)', "`$1`n <AdditionalOptions>$ArchFlag %(AdditionalOptions)</AdditionalOptions>"
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build-icu.ps1` around lines 117 - 119, The current insertion always appends a
new <AdditionalOptions> node via the $content -replace using $ArchFlag, which
duplicates /arch: values on repeated runs; modify the patch logic (the block
that checks $ArchFlag and updates $content) to be idempotent by detecting an
existing <AdditionalOptions> element and either updating any existing /arch:
token to the new $ArchFlag or replacing the whole AdditionalOptions value, and
only inserting a new <AdditionalOptions> element when none exists; ensure the
implementation targets the same pattern currently matched and preserves other
%(AdditionalOptions) entries while removing or replacing any prior /arch:
setting so rerunning the script does not accumulate multiple /arch: flags.


# Disable /GL - lld-link cannot read LTCG object files
$content = $content -replace '<WholeProgramOptimization>true</WholeProgramOptimization>', '<WholeProgramOptimization>false</WholeProgramOptimization>'

Expand Down
23 changes: 17 additions & 6 deletions windows-release.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
param(
[ValidateSet("x64", "ARM64")]
[string]$Platform = "x64"
[string]$Platform = "x64",

[switch]$Baseline
)
$ErrorActionPreference = "Stop"

Expand Down Expand Up @@ -41,6 +43,15 @@ clang-cl.exe --version
$env:CC = "clang-cl"
$env:CXX = "clang-cl"

if ($Platform -eq "ARM64") {
$MarchFlag = "/clang:-march=armv8-a+crc /clang:-mtune=ampere1"
} elseif ($Baseline) {
$MarchFlag = "/clang:-march=nehalem"
} else {
$MarchFlag = "/clang:-march=haswell"
}
Comment on lines +46 to +52
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Fail fast when -Baseline is used on non-x64 targets.

Right now, -Baseline on ARM64 is silently ignored. A guard would prevent accidental misconfiguration.

💡 Proposed guard
 $env:CC = "clang-cl"
 $env:CXX = "clang-cl"
 
+if ($Baseline -and $Platform -ne "x64") {
+    throw "-Baseline is only supported for x64 builds."
+}
+
 if ($Platform -eq "ARM64") {
     $MarchFlag = "/clang:-march=armv8-a+crc /clang:-mtune=ampere1"
 } elseif ($Baseline) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ($Platform -eq "ARM64") {
$MarchFlag = "/clang:-march=armv8-a+crc /clang:-mtune=ampere1"
} elseif ($Baseline) {
$MarchFlag = "/clang:-march=nehalem"
} else {
$MarchFlag = "/clang:-march=haswell"
}
$env:CC = "clang-cl"
$env:CXX = "clang-cl"
if ($Baseline -and $Platform -ne "x64") {
throw "-Baseline is only supported for x64 builds."
}
if ($Platform -eq "ARM64") {
$MarchFlag = "/clang:-march=armv8-a+crc /clang:-mtune=ampere1"
} elseif ($Baseline) {
$MarchFlag = "/clang:-march=nehalem"
} else {
$MarchFlag = "/clang:-march=haswell"
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@windows-release.ps1` around lines 46 - 52, Add a guard that fails fast when
the Baseline switch is set but the Platform is not x64: check $Baseline together
with $Platform and if $Baseline is true and $Platform is not "x64" (e.g., equals
"ARM64") write an error and exit with a non‑zero code instead of silently
falling through; update the logic around the $Platform/$Baseline decision that
currently sets $MarchFlag to ensure you validate $Baseline first (referencing
the $Platform, $Baseline and $MarchFlag variables) so misconfiguration is
rejected immediately.

Write-Host ":: WebKit codegen floor: $MarchFlag"

$output = if ($env:WEBKIT_OUTPUT_DIR) { $env:WEBKIT_OUTPUT_DIR } else { "bun-webkit" }
$WebKitBuild = if ($env:WEBKIT_BUILD_DIR) { $env:WEBKIT_BUILD_DIR } else { "WebKitBuild" }
$CMAKE_BUILD_TYPE = if ($env:CMAKE_BUILD_TYPE) { $env:CMAKE_BUILD_TYPE } else { "Release" }
Expand All @@ -52,7 +63,7 @@ $ICU_STATIC_LIBRARY = Join-Path $ICU_STATIC_ROOT "lib"
$ICU_STATIC_INCLUDE_DIR = Join-Path $ICU_STATIC_ROOT "include"

$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
& "$ScriptDir/build-icu.ps1" -Platform $Platform -BuildType $CMAKE_BUILD_TYPE -OutputDir $ICU_STATIC_ROOT
& "$ScriptDir/build-icu.ps1" -Platform $Platform -BuildType $CMAKE_BUILD_TYPE -OutputDir $ICU_STATIC_ROOT -Baseline:$Baseline
if ($LASTEXITCODE -ne 0) { throw "build-icu.ps1 failed with exit code $LASTEXITCODE" }

Write-Host ":: Configuring WebKit"
Expand Down Expand Up @@ -108,10 +119,10 @@ cmake -S . -B $WebKitBuild `
"-DCMAKE_C_COMPILER=${ClangPath}" `
"-DCMAKE_CXX_COMPILER=${ClangPath}" `
"-DCMAKE_LINKER=${LldLinkPath}" `
"-DCMAKE_C_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG /DU_STATIC_IMPLEMENTATION ${ARM64SehWorkaround}" `
"-DCMAKE_CXX_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG /DU_STATIC_IMPLEMENTATION /clang:-fno-c++-static-destructors ${ARM64SehWorkaround}" `
"-DCMAKE_C_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 /DU_STATIC_IMPLEMENTATION ${ARM64SehWorkaround}" `
"-DCMAKE_CXX_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 /DU_STATIC_IMPLEMENTATION /clang:-fno-c++-static-destructors ${ARM64SehWorkaround}" `
"-DCMAKE_C_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG /DU_STATIC_IMPLEMENTATION ${MarchFlag} ${ARM64SehWorkaround}" `
"-DCMAKE_CXX_FLAGS_RELEASE=/Zi /O2 /Ob2 /DNDEBUG /DU_STATIC_IMPLEMENTATION ${MarchFlag} /clang:-fno-c++-static-destructors ${ARM64SehWorkaround}" `
"-DCMAKE_C_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 /DU_STATIC_IMPLEMENTATION ${MarchFlag} ${ARM64SehWorkaround}" `
"-DCMAKE_CXX_FLAGS_DEBUG=/Zi /FS /O0 /Ob0 /DU_STATIC_IMPLEMENTATION ${MarchFlag} /clang:-fno-c++-static-destructors ${ARM64SehWorkaround}" `
-DENABLE_REMOTE_INSPECTOR=ON `
"-DCMAKE_MSVC_RUNTIME_LIBRARY=${CmakeMsvcRuntimeLibrary}" `
-G Ninja
Expand Down
Loading