Path: blob/main/lang/bun/files/patch-scripts_build_deps_libdeflate.ts
49052 views
-- Disable AVX2/AVX-512 SIMD implementations in libdeflate for baseline builds.1-- libdeflate uses _target_attribute("avx2") / _target_attribute("pclmul,avx")2-- to compile runtime-dispatched SIMD variants regardless of -march. In baseline3-- (v1/SSE2) mode these still produce AVX2/AVX instructions in the ELF binary,4-- causing the cpu-microarchitecture classifier to report a level above SSE2.5-- Two mechanisms are used:6-- 1. LIBDEFLATE_DISABLE_SIMD_ABOVE_SSE2 / LIBDEFLATE_ASSEMBLER_DOES_NOT_7-- SUPPORT_AVX512VNNI / _VPCLMULQDQ: preprocessor defines that gate the8-- AVX2/AVX-512 code paths in the headers.9-- 2. bun-internal patches (bun-libdeflate-adler32-disable-avx2.patch and10-- bun-libdeflate-crc32-disable-avx.patch, installed by the Makefile11-- post-patch target) are applied by bun's fetchDep when it extracts the12-- libdeflate tarball from cache.1314--- scripts/build/deps/libdeflate.ts.orig 2026-05-12 22:12:49 UTC15+++ scripts/build/deps/libdeflate.ts16@@ -21,7 +21,18 @@ export const libdeflate: Dependency = {17commit: LIBDEFLATE_COMMIT,18}),1920- build: () => ({21+ // Apply SIMD-disable patches for baseline (v1/SSE2) builds so that22+ // _target_attribute("avx2") and _target_attribute("pclmul,avx") functions23+ // are excluded from the extracted source before compilation.24+ patches: cfg =>25+ cfg.x64 && cfg.baseline26+ ? [27+ "patches/libdeflate/adler32-disable-avx2.patch",28+ "patches/libdeflate/crc32-disable-avx.patch",29+ ]30+ : [],31+32+ build: cfg => ({33kind: "direct",34sources: [35"lib/utils.c",36@@ -39,6 +50,12 @@ export const libdeflate: Dependency = {37// libdeflate.h + common_defs.h live at the repo root; sources reach38// lib/*.h by relative include from their own directory.39includes: ["."],40+ // Disable AVX2/AVX-512 SIMD implementations for baseline (v1/SSE2) builds.41+ defines: cfg.x64 && cfg.baseline ? {42+ LIBDEFLATE_DISABLE_SIMD_ABOVE_SSE2: true,43+ LIBDEFLATE_ASSEMBLER_DOES_NOT_SUPPORT_AVX512VNNI: true,44+ LIBDEFLATE_ASSEMBLER_DOES_NOT_SUPPORT_VPCLMULQDQ: true,45+ } : {},46}),4748provides: () => ({495051