From ace9dae6611d747b60444252ec55be512246230a Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 3 Nov 2026 15:18:52 +1100 Subject: [PATCH] Sign macOS binaries with `allow-jit` Under the hardened runtime without this entitlement, Bun starts and passes smoke tests but runs with its JIT off. On the shipped 0.6.4 arm64 binary, a CPU loop took about 1690 ms, against about 140 ms for the same bytes with the entitlement. Startup is unaffected: `--version` and `--help` take about 200 ms either way. `verify_code_signing` asserts the entitlement because nothing else would notice it going missing. --- Generated with the help of Claude Code (Opus 5.5), https://code.claude.com --- .changeset/macos-allow-jit-entitlement.md | 5 +++++ fastlane/Fastfile | 10 ++++++++++ packages/cli/macos.entitlements | 8 ++++++++ packages/cli/scripts/sign-macos-binaries.ts | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 .changeset/macos-allow-jit-entitlement.md create mode 100644 packages/cli/macos.entitlements diff --git a/.changeset/macos-allow-jit-entitlement.md b/.changeset/macos-allow-jit-entitlement.md new file mode 100644 index 0000000..7e8cdda --- /dev/null +++ b/.changeset/macos-allow-jit-entitlement.md @@ -0,0 +1,5 @@ +--- +'@beeper/cli': patch +--- + +Sign the macOS binaries with the `allow-jit` entitlement. Without it, Bun runs with its JIT off under the hardened runtime, which makes CPU-heavy JavaScript about 12x slower. diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 9ee82af..7b422a7 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -3,6 +3,7 @@ require 'digest' require 'fileutils' require 'json' +require 'plist' require 'shellwords' UI.user_error!('Please run fastlane via `bundle exec`') unless FastlaneCore::Helper.bundler? @@ -13,6 +14,11 @@ BINARIES_MANIFEST = File.join(PROJECT_ROOT_FOLDER, 'packages', 'cli', 'dist', 'b APPLE_TEAM_ID = 'PZYM8XX95Q' SIGNING_IDENTITY = "Developer ID Application: Automattic, Inc. (#{APPLE_TEAM_ID})" +ENTITLEMENTS_FILE = File.join(PROJECT_ROOT_FOLDER, 'packages', 'cli', 'macos.entitlements') +# Without it, Bun still starts and passes smoke tests under the hardened runtime, but its +# JavaScript engine silently falls back to the interpreter. +ALLOW_JIT_ENTITLEMENT = 'com.apple.security.cs.allow-jit' + CODE_SIGNING_STORAGE_OPTIONS = { storage_mode: 's3', s3_bucket: 'a8c-fastlane-match', @@ -102,6 +108,7 @@ lane :sign_and_notarize do |binary:| '--sign', SIGNING_IDENTITY, # The hardened runtime is a precondition for notarization. '--options', 'runtime', + '--entitlements', ENTITLEMENTS_FILE, '--timestamp', '--force', binary @@ -148,6 +155,9 @@ lane :verify_code_signing do |binary:| UI.user_error!("#{binary} is not signed with the hardened runtime:\n#{details}") unless details.include?('(runtime)') + entitlements = Plist.parse_xml(sh("codesign --display --entitlements - --xml #{binary.shellescape} 2>/dev/null", log: false)) + UI.user_error!("#{binary} is missing the #{ALLOW_JIT_ENTITLEMENT} entitlement") unless entitlements&.fetch(ALLOW_JIT_ENTITLEMENT, false) == true + UI.success("#{binary} is signed by #{SIGNING_IDENTITY}") end diff --git a/packages/cli/macos.entitlements b/packages/cli/macos.entitlements new file mode 100644 index 0000000..86611d6 --- /dev/null +++ b/packages/cli/macos.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.cs.allow-jit + + + diff --git a/packages/cli/scripts/sign-macos-binaries.ts b/packages/cli/scripts/sign-macos-binaries.ts index 10cbdf4..ded5711 100644 --- a/packages/cli/scripts/sign-macos-binaries.ts +++ b/packages/cli/scripts/sign-macos-binaries.ts @@ -51,6 +51,8 @@ try { '--force', '--options', 'runtime', + '--entitlements', + join(root, 'macos.entitlements'), '--timestamp', '--sign', resolvedIdentity,