From 04d429888b367a37bfec11ed6841cdcdb11a1751 Mon Sep 17 00:00:00 2001 From: gshlok <109033902+gshlok@users.noreply.github.com> Date: Tue, 24 Nov 2026 13:14:36 +0530 Subject: [PATCH] Makefile: link the section-GC tests on Windows test-textures and test-two-button-rows compile one large runtime file each (textures.c, game_options.mm) and rely on --gc-sections to drop everything but the functions under test. ELF lld only reports undefined symbols that live code uses, but COFF lld reports them before it discards sections, so on Windows both links failed with dozens of undefined Vulkan, HDR and renderer symbols. On Windows only, let these two links leave them unresolved. Co-Authored-By: Claude Opus 5.5 --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6df1bf29c..09f132326 100644 --- a/Makefile +++ b/Makefile @@ -789,6 +789,11 @@ test-hour: $(B)/test_hour .PHONY: test-hour +# Tests that keep a few functions of a large runtime file and let --gc-sections drop the rest. ELF lld reports an +# undefined symbol only when live code uses it; COFF lld (Windows) reports them before discarding sections, so there +# the link allows them. +GC_TEST_UNDEF := $(if $(filter windows,$(PLATFORM)),-Wl$(comma)-Xlink=-force:unresolved) + # The BC5 view format (NVN 0x4C, SAVAGEWIND_BC5_UNORM): vk_format is the only function the section GC keeps from # textures.c, so no Vulkan device is needed. Run twice so both initial environment states cache the right format. ifneq ($(PLATFORM),macos) @@ -796,7 +801,7 @@ $(B)/test_textures_format: tests/test_textures_format.c runtime/nvn/vulkan/textu @mkdir -p $(dir $@) $(CC) -O2 -ffunction-sections -fdata-sections $(OSFLAGS) $(DEPINC) -Iruntime -Iruntime/nvn -isystem third_party -isystem third_party/stb \ -o $@ tests/test_textures_format.c runtime/nvn/vulkan/textures.c -fuse-ld=lld -Wl,--gc-sections \ - $(if $(filter windows,$(PLATFORM)),-Wl$(comma)--exclude-all-symbols) -lpthread -lm + $(if $(filter windows,$(PLATFORM)),-Wl$(comma)--exclude-all-symbols) $(GC_TEST_UNDEF) -lpthread -lm test-textures: $(B)/test_textures_format env -u SAVAGEWIND_BC5_UNORM $(B)/test_textures_format @@ -814,7 +819,7 @@ $(B)/two_button_bindings.o: runtime/hle/bindings.c runtime/input_bind.h $(CC) -O1 -ffunction-sections -fdata-sections -DSDL_STATIC_LIB $(OSFLAGS) $(DEPINC) -Iruntime -c $< -o $@ $(B)/test_two_button_rows: tools/test_two_button_rows.cpp runtime/ui/game_options.mm runtime/ui/binding_row_layout.h $(B)/two_button_bindings.o - $(CXX) -std=c++17 -O1 -ffunction-sections -fdata-sections -DSDL_STATIC_LIB $(OSFLAGS) $(DEPINC) -Iruntime -Ithird_party -o $@ $< $(B)/two_button_bindings.o -fuse-ld=lld -Wl,--gc-sections $(if $(filter windows,$(PLATFORM)),-Wl$(comma)--exclude-all-symbols) -lSDL3 -lm + $(CXX) -std=c++17 -O1 -ffunction-sections -fdata-sections -DSDL_STATIC_LIB $(OSFLAGS) $(DEPINC) -Iruntime -Ithird_party -o $@ $< $(B)/two_button_bindings.o -fuse-ld=lld -Wl,--gc-sections $(if $(filter windows,$(PLATFORM)),-Wl$(comma)--exclude-all-symbols) $(GC_TEST_UNDEF) -lSDL3 -lm test-two-button-rows: $(B)/test_two_button_rows $(B)/test_two_button_rows