Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/macos-allow-jit-entitlement.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions packages/cli/macos.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions packages/cli/scripts/sign-macos-binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ try {
'--force',
'--options',
'runtime',
'--entitlements',
join(root, 'macos.entitlements'),
'--timestamp',
'--sign',
resolvedIdentity,
Expand Down
Loading