Skip to content

Commit 00a1d8c

Browse files
committed
chore: wip
1 parent c022676 commit 00a1d8c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

scripts/build-php.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,25 @@ exec "$@"
14421442

14431443
// Update PATH to use our wrapper
14441444
buildEnv.PATH = `${phpSourceDir}:${buildEnv.PATH}`
1445+
1446+
// Fix "fixup not sufficiently aligned" errors in OPcache JIT on macOS
1447+
// Add compiler flags to ensure proper alignment for inline assembly
1448+
const additionalCFlags = [
1449+
'-mno-unaligned-access', // ARM64-specific: prevent unaligned access
1450+
'-falign-functions=16', // Align functions to 16-byte boundaries
1451+
'-falign-loops=16', // Align loops to 16-byte boundaries
1452+
'-fno-strict-aliasing', // Prevent strict aliasing optimizations
1453+
'-fno-delete-null-pointer-checks', // Prevent null pointer optimizations
1454+
]
1455+
1456+
// Add these flags to CFLAGS and CXXFLAGS if they don't already exist
1457+
const currentCFlags = buildEnv.CFLAGS || ''
1458+
const currentCXXFlags = buildEnv.CXXFLAGS || ''
1459+
1460+
buildEnv.CFLAGS = `${currentCFlags} ${additionalCFlags.join(' ')}`.trim()
1461+
buildEnv.CXXFLAGS = `${currentCXXFlags} ${additionalCFlags.join(' ')}`.trim()
1462+
1463+
log('✅ Added macOS-specific compiler flags to prevent alignment errors')
14451464
}
14461465

14471466
// Check if configure already exists (some PHP releases include it)

0 commit comments

Comments
 (0)