Files
DucielPerf/build.sh
T
DucielandClaude Opus 5.5 797673cc37 Phase 2: performance module (decompression, MPQ file cache, Lua strings)
- Decompression: MPQ zlib blocks (DecompressData_WithOptions, 0x661A80)
  decoded with libdeflate 1.26 (vendored, decompression only), one
  decompressor per thread. Like the original, reports the produced size
  through outSize (verified in the client at +0x174).
- MPQ file-lookup cache for File_FindInArchive (0x6549a0), re-implemented
  from WeirdUtils with an SRW lock (lookups also happen on loading
  threads) and stricter archive re-validation on hits.
- Lua strings: table-driven matchclass (built lazily from the original on
  first use), a literal prefilter for string.find / gsub / the gfind
  iterator, and luaS_newlstr with a hash check before comparing bytes.
- Claims WeirdUtils' "weirdperformance" mutex so an old weirdutils.dll never
  runs its custom Lua GC alongside.

Prefilter fix over WeirdUtils: string.gfind does not treat a leading '^'
as an anchor (Lua 5.0 gfind_aux calls match() directly), so '^' is an
ordinary, quantifiable character there. Treating it as an anchor made
patterns like "^*abab" wrongly report no match.

Tests: tests/test_prefilter checks the prefilter against the real Lua
5.0.3 string library (vendored in tests/lua50): 4.7M fuzz checks plus
10M checks of 531 real addon patterns against combat-log and chat lines,
0 violations; the matcher is skipped in about half of real-world calls.
Decompression verified through the hook in the offline harness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 23:51:31 +01:00

47 lines
2.0 KiB
Bash

#!/usr/bin/env bash
# Builds build/ducielperf.dll (32-bit Windows) with clang via Zig.
#
# ./build.sh release build
# ./build.sh debug also writes per-event debug lines to Logs\ducielperf.log
#
# Needs Zig (any recent version, used only as a C/C++ compiler) at tools/zig/zig.exe
# or on PATH. Zig's own language is not used: its 0.16.0 release miscompiles
# x86 __fastcall, which is why this project is C++.
set -euo pipefail
cd "$(dirname "$0")"
ZIG=tools/zig/zig.exe
[ -x "$ZIG" ] || ZIG=$(command -v zig || true)
[ -n "$ZIG" ] || { echo "Zig not found (tools/zig/zig.exe or PATH)"; exit 1; }
TARGET=x86-windows-gnu
DEFS=()
[ "${1:-}" = "debug" ] && DEFS+=(-DDP_DEBUG)
mkdir -p build/obj
COMMON=(-target "$TARGET" -O2 -Wall -Wno-unused-function -Wno-nullability-completeness
-Ithird_party/minhook/include -Ithird_party/libdeflate "${DEFS[@]}")
objs=()
# Third-party C code: MinHook (hooks) and libdeflate (decompression only).
for src in third_party/minhook/src/buffer.c third_party/minhook/src/hook.c \
third_party/minhook/src/trampoline.c third_party/minhook/src/hde/hde32.c \
third_party/libdeflate/lib/deflate_decompress.c third_party/libdeflate/lib/zlib_decompress.c \
third_party/libdeflate/lib/adler32.c third_party/libdeflate/lib/utils.c \
third_party/libdeflate/lib/x86/cpu_features.c; do
obj=build/obj/3p_$(basename "${src%.c}").o
# The AVX-512 VNNI Adler-32 variant does not build with this clang's evex512 rules.
"$ZIG" cc "${COMMON[@]}" -Wno-everything -DLIBDEFLATE_ASSEMBLER_DOES_NOT_SUPPORT_AVX512VNNI -c "$src" -o "$obj"
objs+=("$obj")
done
for src in src/dllmain.cpp src/core/*.cpp src/modules/*.cpp; do
obj=build/obj/$(basename "${src%.cpp}").o
"$ZIG" c++ "${COMMON[@]}" -std=c++17 -fno-exceptions -fno-rtti -c "$src" -o "$obj"
objs+=("$obj")
done
"$ZIG" c++ -target "$TARGET" -shared -s -o build/ducielperf.dll "${objs[@]}"
rm -f build/ducielperf.lib build/ducielperf.pdb
ls -l build/ducielperf.dll