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