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_libwebp.ts
49052 views
1
-- Exclude AVX2 DSP sources from libwebp for baseline (v1/SSE2) builds.
2
-- libwebp compiles lossless_avx2.c and lossless_enc_avx2.c with -mavx2 so the
3
-- compiler emits AVX2 instructions. Although libwebp uses runtime CPU dispatch
4
-- so these paths are only executed when AVX2 is detected, the instructions are
5
-- present in the ELF binary and cause the cpu-microarchitecture classifier to
6
-- require AVX2. Exclude the _avx2.c files entirely for baseline builds; the
7
-- SSE2 code paths remain available and are selected at runtime.
8
9
--- scripts/build/deps/libwebp.ts.orig 2026-05-23 02:36:10 UTC
10
+++ scripts/build/deps/libwebp.ts
11
@@ -98,14 +98,20 @@ const SHARPYUV = [
12
// (on arm64 these compile to the stub body and the x86 -m flags are invalid).
13
// Runtime CPU dispatch in dsp/cpu.c picks the best available, so a baseline
14
// binary still runs on pre-AVX2 hardware.
15
-function simd(path: string, x64: boolean) {
16
+function simd(path: string, x64: boolean, baseline: boolean = false) {
17
if (x64) {
18
for (const [suf, flag] of [
19
["_avx2.c", "-mavx2"],
20
["_sse41.c", "-msse4.1"],
21
["_sse2.c", "-msse2"],
22
] as const) {
23
- if (path.endsWith(suf)) return { path, cflags: [flag] };
24
+ if (path.endsWith(suf)) {
25
+ // Exclude AVX2 files for baseline (v1/SSE2) builds: even though
26
+ // libwebp uses runtime CPU dispatch, the AVX2 instructions must not
27
+ // be present in the ELF binary at all for baseline compliance.
28
+ if (baseline && suf === "_avx2.c") return null;
29
+ return { path, cflags: [flag] };
30
+ }
31
}
32
}
33
return path;
34
@@ -126,11 +132,11 @@ export const libwebp: Dependency = {
35
sources: [
36
...DEC.map(f => `src/dec/${f}.c`),
37
...ENC.map(f => `src/enc/${f}.c`),
38
- ...DSP.map(f => simd(`src/dsp/${f}.c`, cfg.x64)),
39
+ ...DSP.map(f => simd(`src/dsp/${f}.c`, cfg.x64, cfg.baseline)).filter(Boolean),
40
...UTILS.map(f => `src/utils/${f}.c`),
41
...DEMUX.map(f => `src/demux/${f}.c`),
42
...MUX.map(f => `src/mux/${f}.c`),
43
- ...SHARPYUV.map(f => simd(`sharpyuv/${f}.c`, cfg.x64)),
44
+ ...SHARPYUV.map(f => simd(`sharpyuv/${f}.c`, cfg.x64, cfg.baseline)).filter(Boolean),
45
],
46
// src/webp/*.h is the public API; internal headers use "src/..."
47
// includes from the repo root, sharpyuv uses "sharpyuv/...".
48
49