Path: blob/main/lang/bun/files/patch-scripts_build_deps_boringssl.ts
49052 views
-- Exclude all x86-64 ELF assembly from BoringSSL when building for baseline1-- (v1/SSE2). BoringSSL ships assembly that uses AVX, AVX2, AVX-512, BMI2, and2-- ADX instructions. In baseline mode the binary must contain only SSE2-level3-- code so that it runs on any x86-64 CPU. Setting OPENSSL_NO_ASM causes all4-- BoringSSL C dispatch code to use pure-C fallbacks; filtering the assembly5-- from the source list ensures none of the higher-ISA objects are linked in.6-- The AVX-512 bun-internal patch is kept as belt-and-suspenders.78--- scripts/build/deps/boringssl.ts.orig 2026-05-23 02:36:52 UTC9+++ scripts/build/deps/boringssl.ts10@@ -36,10 +36,26 @@ export const boringssl: Dependency = {11commit: BORINGSSL_COMMIT,12}),1314+ // Apply source patches for baseline (v1/SSE2) builds to guard the AVX-51215+ // GCM declarations and dispatch paths with OPENSSL_NO_AVX512, matching the16+ // exclusion of the AVX-512 assembly file below.17+ patches: cfg =>18+ cfg.x64 && cfg.baseline19+ ? ["patches/boringssl/disable-avx512-gcm.patch"]20+ : [],21+22build: cfg => {23// win-x64 uses NASM-syntax .asm; everything else (including win-aarch64)24// uses gas .S that clang assembles.25- const asm = cfg.windows && cfg.x64 ? NASM : ASM;26+ let asm = cfg.windows && cfg.x64 ? NASM : ASM;27+ // For baseline (v1/SSE2) builds: exclude ALL ELF x86-64 assembly.28+ // OPENSSL_NO_ASM (set below) causes C fallbacks to be used for all crypto.29+ // The wrong-arch files already assemble to empty TUs; the x86-64 linux30+ // ones (including AVX2, BMI2, ADX, SSSE3) must also be removed so their31+ // instructions do not appear in the final binary.32+ if (cfg.x64 && cfg.baseline) {33+ asm = asm.filter(f => !f.endsWith("-linux.S") && !f.includes("fiat_"));34+ }3536const spec: DirectBuild = {37kind: "direct",38@@ -53,6 +69,11 @@ export const boringssl: Dependency = {39WIN32_LEAN_AND_MEAN: true,40NOMINMAX: true,41_CRT_SECURE_NO_WARNINGS: true,42+ }),43+ // Disable ASM dispatch and guard AVX-512 GCM C code for baseline builds.44+ ...(cfg.x64 && cfg.baseline && {45+ OPENSSL_NO_ASM: true,46+ OPENSSL_NO_AVX512: true,47}),48},49cflags: cfg.windows505152