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_libdeflate.ts
49052 views
1
-- Disable AVX2/AVX-512 SIMD implementations in libdeflate for baseline builds.
2
-- libdeflate uses _target_attribute("avx2") / _target_attribute("pclmul,avx")
3
-- to compile runtime-dispatched SIMD variants regardless of -march. In baseline
4
-- (v1/SSE2) mode these still produce AVX2/AVX instructions in the ELF binary,
5
-- causing the cpu-microarchitecture classifier to report a level above SSE2.
6
-- Two mechanisms are used:
7
-- 1. LIBDEFLATE_DISABLE_SIMD_ABOVE_SSE2 / LIBDEFLATE_ASSEMBLER_DOES_NOT_
8
-- SUPPORT_AVX512VNNI / _VPCLMULQDQ: preprocessor defines that gate the
9
-- AVX2/AVX-512 code paths in the headers.
10
-- 2. bun-internal patches (bun-libdeflate-adler32-disable-avx2.patch and
11
-- bun-libdeflate-crc32-disable-avx.patch, installed by the Makefile
12
-- post-patch target) are applied by bun's fetchDep when it extracts the
13
-- libdeflate tarball from cache.
14
15
--- scripts/build/deps/libdeflate.ts.orig 2026-05-12 22:12:49 UTC
16
+++ scripts/build/deps/libdeflate.ts
17
@@ -21,7 +21,18 @@ export const libdeflate: Dependency = {
18
commit: LIBDEFLATE_COMMIT,
19
}),
20
21
- build: () => ({
22
+ // Apply SIMD-disable patches for baseline (v1/SSE2) builds so that
23
+ // _target_attribute("avx2") and _target_attribute("pclmul,avx") functions
24
+ // are excluded from the extracted source before compilation.
25
+ patches: cfg =>
26
+ cfg.x64 && cfg.baseline
27
+ ? [
28
+ "patches/libdeflate/adler32-disable-avx2.patch",
29
+ "patches/libdeflate/crc32-disable-avx.patch",
30
+ ]
31
+ : [],
32
+
33
+ build: cfg => ({
34
kind: "direct",
35
sources: [
36
"lib/utils.c",
37
@@ -39,6 +50,12 @@ export const libdeflate: Dependency = {
38
// libdeflate.h + common_defs.h live at the repo root; sources reach
39
// lib/*.h by relative include from their own directory.
40
includes: ["."],
41
+ // Disable AVX2/AVX-512 SIMD implementations for baseline (v1/SSE2) builds.
42
+ defines: cfg.x64 && cfg.baseline ? {
43
+ LIBDEFLATE_DISABLE_SIMD_ABOVE_SSE2: true,
44
+ LIBDEFLATE_ASSEMBLER_DOES_NOT_SUPPORT_AVX512VNNI: true,
45
+ LIBDEFLATE_ASSEMBLER_DOES_NOT_SUPPORT_VPCLMULQDQ: true,
46
+ } : {},
47
}),
48
49
provides: () => ({
50
51