From 1eecfb308cb8409bd1299e45e7302086441e55bb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 20 Apr 2021 18:35:43 -0400 Subject: [PATCH 1/4] Full support for modern ARM toolchains --- Makefile | 14 +++++++++----- ld_script_modern.txt | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3cd5ea184..da0af791d 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,14 @@ endif ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) include $(TOOLCHAIN)/base_tools +LIBSUBDIR := thumb else export PATH := $(TOOLCHAIN)/bin:$(PATH) PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy export CC := $(PREFIX)gcc export AS := $(PREFIX)as +LIBSUBDIR := thumb/nofp endif export CPP := $(PREFIX)cpp export LD := $(PREFIX)ld @@ -42,8 +44,7 @@ LIBPATH := -L ../../tools/agbcc/lib else CC1 := $(shell $(CC) --print-prog-name=cc1) -quiet override CFLAGS += -mthumb -mthumb-interwork -O2 -mtune=arm7tdmi -march=armv4t -mabi=apcs-gnu -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast -#LIBPATH := -L $(TOOLCHAIN)/lib/gcc/arm-none-eabi/$(GCC_VER)/thumb -L $(TOOLCHAIN)/arm-none-eabi/lib/thumb -LIBPATH := -L ../../tools/agbcc/lib +LIBPATH := -L $(shell dirname $(shell $(CC) --print-file-name=libgcc.a)) -L $(shell dirname $(shell $(CC) --print-file-name=libc.a)) endif CPPFLAGS := -iquote include -D$(GAME_VERSION) -DREVISION=$(GAME_REVISION) -D$(GAME_LANGUAGE) -DMODERN=$(MODERN) @@ -77,9 +78,12 @@ ASFLAGS := -mcpu=arm7tdmi --defsym $(GAME_VERSION)=1 --defsym REVISION=$(GAME_RE LDFLAGS = -Map ../../$(MAP) LIB := $(LIBPATH) -lc -lgcc -#ifneq ($(MODERN),0) -#LIB += -lsysbase -#endif +ifneq ($(MODERN),0) +ifeq ($(TOOLCHAIN),$(DEVKITARM)) +LIB += -lsysbase -lc +endif +LIB += -lnosys +endif SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c GFX := tools/gbagfx/gbagfx diff --git a/ld_script_modern.txt b/ld_script_modern.txt index 9f1508067..fc6c0d0b7 100644 --- a/ld_script_modern.txt +++ b/ld_script_modern.txt @@ -29,6 +29,7 @@ SECTIONS { /* COMMON starts at 0x30022A8 */ *(COMMON); end = .; + __end__ = .; . = 0x8000; } From 961e6e938f965e340e5a1686dc2095c2c194905b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 20 Apr 2021 20:07:02 -0400 Subject: [PATCH 2/4] Fix for when devkitARM not installed --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index da0af791d..ac25c0e6d 100644 --- a/Makefile +++ b/Makefile @@ -79,9 +79,11 @@ LDFLAGS = -Map ../../$(MAP) LIB := $(LIBPATH) -lc -lgcc ifneq ($(MODERN),0) +ifneq ($(DEVKITARM),) ifeq ($(TOOLCHAIN),$(DEVKITARM)) LIB += -lsysbase -lc endif +endif LIB += -lnosys endif From 2a8a37b4b69494b037db6897b3dd4388330455a4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 6 May 2021 14:42:01 -0400 Subject: [PATCH 3/4] Remove disused variable LIBSUBDIR --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index ac25c0e6d..a9b7e4e5d 100644 --- a/Makefile +++ b/Makefile @@ -15,14 +15,12 @@ endif ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) include $(TOOLCHAIN)/base_tools -LIBSUBDIR := thumb else export PATH := $(TOOLCHAIN)/bin:$(PATH) PREFIX := arm-none-eabi- OBJCOPY := $(PREFIX)objcopy export CC := $(PREFIX)gcc export AS := $(PREFIX)as -LIBSUBDIR := thumb/nofp endif export CPP := $(PREFIX)cpp export LD := $(PREFIX)ld From 44dc1a473c8a4ff1c73b776889f2002136c7787d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 7 May 2021 13:12:28 -0400 Subject: [PATCH 4/4] Replace -mtune/march with -mcpu\n\nI know, Shoo me(r) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a9b7e4e5d..7e40a375d 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,7 @@ override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex- LIBPATH := -L ../../tools/agbcc/lib else CC1 := $(shell $(CC) --print-prog-name=cc1) -quiet -override CFLAGS += -mthumb -mthumb-interwork -O2 -mtune=arm7tdmi -march=armv4t -mabi=apcs-gnu -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast +override CFLAGS += -mthumb -mthumb-interwork -O2 -mcpu=arm7tdmi -mabi=apcs-gnu -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast LIBPATH := -L $(shell dirname $(shell $(CC) --print-file-name=libgcc.a)) -L $(shell dirname $(shell $(CC) --print-file-name=libc.a)) endif