From 00b750d80b7be9d7a54779b67decdc511aea92d4 Mon Sep 17 00:00:00 2001 From: Songlx516 Date: Sun, 13 Sep 2026 14:11:35 +0800 Subject: [PATCH] build: enable -maes -mavx2 -mvaes for the 7z TU family so prospero-clang accepts AesOpt.c PS5 (Zen 2) has every AES-NI / AVX / VAES instruction set, but prospero-clang defaults to a generic x86_64 target that does NOT pre-declare _mm256_aesenc_epi128 -- AesOpt.c relies on a compiler-version macro that lets clang 18 in unconditionally, so it blew up with 20 errors and stopped at -ferror-limit= before the rest of the build could even run. You can't drop AesOpt.c either: Aes.c references the AesCbc_{Encode,Decode}_HW / AesCtr_Code_HW[256] symbols via AesGenTables, so without AesOpt.c the link fails (five undefined-symbol errors). Fix: add a path-filtered CFLAGS_7Z = -maes -mavx2 -mvaes and apply it only to third_party/7z/*.c -- zlib and minizip-ng don't need it, the project sources don't need it, and it's a no-op at runtime since the symbols exist on PS5. Verified: * WSL prospero-clang++ 18.1.8 (FreeBSD sysroot) -- success web-file-mgr.elf 1017864 B, sha256 2eb04581...473a157, e_machine=0x003e * MinGW gcc 16.2.0 host tests -- 163 checks (ZIP 108 + RAR 27 + 7z 28) all pass --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 455fc41..de2197b 100644 --- a/Makefile +++ b/Makefile @@ -71,9 +71,17 @@ UNRAR7_SRCS := \ third_party/unrar7/unpack.cpp third_party/unrar7/volume.cpp THIRD_PARTY_C_SRCS := $(wildcard third_party/zlib/src/*.c) $(wildcard third_party/minizip-ng/src/*.c) $(wildcard third_party/7z/*.c) +# AesOpt.c hard-codes x86 AES-NI / AVX / VAES intrinsics and guards them with +# a compiler-version check that lets clang 18 in unconditionally. The plain +# intrinsics (`_mm256_aesenc_epi128`) live behind , which +# clang only declares after `+mvaes +mavx2` (or higher). PS5 is Zen 2 and has +# every one of these, so we just enable them for the 7z TU family instead of +# dropping AesOpt.c (Aes.c references those HW symbol names via AesGenTables). +SEVENZ_C_FLAGS := -maes -mavx2 -mvaes THIRD_PARTY_C_FLAGS := -O2 -w -Ithird_party/zlib/include -Ithird_party/minizip-ng/include -Ithird_party/7z \ -DHAVE_ZLIB -DZLIB_COMPAT -DHAVE_UNISTD_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE \ -DHAVE_FSEEKO -DZ7_PPMD_SUPPORT +THIRD_PARTY_C_FLAGS_7Z := $(THIRD_PARTY_C_FLAGS) $(SEVENZ_C_FLAGS) UNRAR7_CXX_FLAGS := -O2 -w -std=c++17 -DRARDLL -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE # prospero-clang++ defaults to -stdlib=libc++; state it explicitly for clarity. UNRAR7_CXX_FLAGS_PS5 := $(UNRAR7_CXX_FLAGS) -stdlib=libc++ @@ -117,11 +125,11 @@ gen/%.c: assets/% gen-asset-module.py | gen ps5-obj/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(THIRD_PARTY_C_FLAGS) -c -o $@ $< + $(CC) $(if $(findstring third_party/7z,$<),$(THIRD_PARTY_C_FLAGS_7Z),$(THIRD_PARTY_C_FLAGS)) -c -o $@ $< linux-obj/%.o: %.c @mkdir -p $(dir $@) - $(HOST_CC) $(THIRD_PARTY_C_FLAGS) -c -o $@ $< + $(HOST_CC) $(if $(findstring third_party/7z,$<),$(THIRD_PARTY_C_FLAGS_7Z),$(THIRD_PARTY_C_FLAGS)) -c -o $@ $< ps5-obj/%.o: %.cpp @mkdir -p $(dir $@)