3ds: try partial linking
authornotaz <notasas@gmail.com>
Tue, 15 Oct 2024 22:45:51 +0000 (01:45 +0300)
committernotaz <notasas@gmail.com>
Thu, 24 Oct 2024 23:50:18 +0000 (02:50 +0300)
Makefile
Makefile.libretro
frontend/libretro-extern [new file with mode: 0644]
frontend/libretro-version-script [moved from frontend/link.T with 100% similarity]
jni/Android.mk

index 9d278a5..2985dbe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -470,14 +470,20 @@ frontend/revision.h: FORCE
 target_: $(TARGET)
 
 $(TARGET): $(OBJS)
-ifeq ($(STATIC_LINKING), 1)
-       $(AR) rcs $@ $(OBJS)
+ifeq ($(PARTIAL_LINKING), 1)
+       sed -e 's/.*/EXTERN(\0)/' frontend/libretro-extern > frontend/libretro-extern.T
+       $(LD) -o $(basename $(TARGET))1.o -r --gc-sections -T frontend/libretro-extern.T $^
+       $(OBJCOPY) --keep-global-symbols=frontend/libretro-extern $(basename $(TARGET))1.o $(basename $(TARGET)).o
+       $(AR) rcs $@ $(basename $(TARGET)).o
+else ifeq ($(STATIC_LINKING), 1)
+       $(AR) rcs $@ $^
 else
        $(CC_LINK) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(EXTRA_LDFLAGS)
 endif
 
 clean: $(PLAT_CLEAN) clean_plugins
-       $(RM) $(TARGET) $(OBJS) $(TARGET).map frontend/revision.h
+       $(RM) $(TARGET) *.o $(OBJS) $(TARGET).map frontend/revision.h
+       $(RM) frontend/libretro-extern.T
 
 ifneq ($(PLUGINS),)
 plugins_: $(PLUGINS)
index 7639520..e1fadde 100644 (file)
@@ -59,9 +59,12 @@ else ifeq ($(platform), psl1ght)
 else ifeq ($(platform), psp1)
   CC = psp-gcc$(EXE_EXT)
   AR = psp-ar$(EXE_EXT)
+  LD = psp-ld$(EXE_EXT)
 else ifeq ($(platform), vita)
   CC = arm-vita-eabi-gcc$(EXE_EXT)
   AR = arm-vita-eabi-ar$(EXE_EXT)
+  LD = arm-vita-eabi-ld$(EXE_EXT)
+  OBJCOPY = arm-vita-eabi-objcopy$(EXE_EXT)
 else ifeq ($(platform), ctr)
   ifeq ($(strip $(DEVKITARM)),)
   $(error "DEVKITARM env var is not set")
@@ -69,6 +72,8 @@ else ifeq ($(platform), ctr)
   CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
   CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
   AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
+  LD = $(DEVKITARM)/bin/arm-none-eabi-ld$(EXE_EXT)
+  OBJCOPY = $(DEVKITARM)/bin/arm-none-eabi-objcopy$(EXE_EXT)
 else ifeq ($(platform), libnx)
   export DEPSDIR := $(CURDIR)/
   ifeq ($(strip $(DEVKITPRO)),)
@@ -79,6 +84,7 @@ else ifeq ($(platform), libnx)
 else ifeq ($(platform), xenon)
   CC = xenon-gcc$(EXE_EXT)
   AR = xenon-ar$(EXE_EXT)
+  LD = xenon-ld$(EXE_EXT)
 else ifneq (,$(filter $(platform),ngc wii wiiu))
   ifeq ($(strip $(DEVKITPPC)),)
   $(error "DEVKITPPC env var is not set")
@@ -86,6 +92,7 @@ else ifneq (,$(filter $(platform),ngc wii wiiu))
   CC  = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
   CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
   AR  = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
+  LD  = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT)
 else ifeq ($(platform), qnx)
   CC = qcc -Vgcc_ntoarmv7le
 else ifeq ($(platform), miyoo)
@@ -269,7 +276,7 @@ else ifeq ($(platform), libnx)
    NO_PTHREAD=1
    NO_MMAP := 1 # for psxmem
    LIBPTHREAD :=
-   STATIC_LINKING=1
+   PARTIAL_LINKING = 1
    BUILTIN_GPU = neon
    HAVE_NEON = 1
    DYNAREC = ari64
@@ -327,7 +334,7 @@ else ifeq ($(platform), vita)
 
        DYNAREC = ari64
        ARCH = arm
-       STATIC_LINKING = 1
+       PARTIAL_LINKING = 1
        NO_PTHREAD=1
        NO_POSIX_MEMALIGN := 1
        HAVE_PHYSICAL_CDROM = 0
@@ -359,7 +366,8 @@ else ifeq ($(platform), ctr)
        DYNAREC = ari64
        ARCH = arm
        HAVE_NEON = 0
-       STATIC_LINKING = 1
+       PARTIAL_LINKING = 1
+       WANT_ZLIB = 0
        NO_POSIX_MEMALIGN := 1
        NO_MMAP := 1 # for psxmem
        HAVE_PHYSICAL_CDROM = 0
@@ -635,7 +643,7 @@ HAVE_NEON_ASM = $(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep -q
 endif
 ifeq ($(NO_UNDEF_CHECK)$(shell $(LD) -v 2> /dev/null | awk '{print $$1}'),GNU)
  ifeq (,$(findstring $(platform),win32))
- MAIN_LDFLAGS += -Wl,-version-script=frontend/link.T
+ MAIN_LDFLAGS += -Wl,-version-script=frontend/libretro-version-script
  endif
 MAIN_LDFLAGS += -Wl,--no-undefined
 endif
diff --git a/frontend/libretro-extern b/frontend/libretro-extern
new file mode 100644 (file)
index 0000000..c3c490c
--- /dev/null
@@ -0,0 +1,25 @@
+retro_api_version
+retro_cheat_reset
+retro_cheat_set
+retro_deinit
+retro_get_memory_data
+retro_get_memory_size
+retro_get_region
+retro_get_system_av_info
+retro_get_system_info
+retro_init
+retro_load_game
+retro_load_game_special
+retro_reset
+retro_run
+retro_serialize
+retro_serialize_size
+retro_set_audio_sample
+retro_set_audio_sample_batch
+retro_set_controller_port_device
+retro_set_environment
+retro_set_input_poll
+retro_set_input_state
+retro_set_video_refresh
+retro_unload_game
+retro_unserialize
index bba07cc..27459da 100644 (file)
@@ -235,7 +235,7 @@ LOCAL_CFLAGS        := $(COREFLAGS)
 LOCAL_C_INCLUDES    := $(ROOT_DIR)/include
 LOCAL_C_INCLUDES    += $(DEPS_DIR)/crypto
 LOCAL_C_INCLUDES    += $(EXTRA_INCLUDES)
-LOCAL_LDFLAGS       := -Wl,-version-script=$(FRONTEND_DIR)/link.T
+LOCAL_LDFLAGS       := -Wl,-version-script=$(FRONTEND_DIR)/libretro-version-script
 LOCAL_LDLIBS        := -lz -llog
 LOCAL_ARM_MODE      := arm