From 049085c761424a69011c8fd2ccf6202ec671e37d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 3 Jul 2019 11:55:32 -0400 Subject: Implement debug info option --- INSTALL.md | 4 ++++ Makefile | 16 +++++++++++----- include/global.h | 1 + src/save.c | 3 ++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 4a5467cbe..0e5b29015 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -143,3 +143,7 @@ You can build Sapphire and other Ruby revisions by appending `_modern` to the ta Bear in mind that the resulting ROM will not match vanilla Ruby and may exhibit undefined, buggy behavior. We are trying to resolve this as much as possible, so please report anything you find. If you don't want to use devkitARM, you can install your own ARM toolchain consisting of GNU binutils, GCC, and newlib targeting arm-none-eabi. You can pass the root directory of your toolchain to the variable `TOOLCHAIN` when running `make` for any target. **If you opt to do this, the assumption is that you know what you are doing already!** + +# Debug symbols + +You can compile the ROM with helpful debug symbols by passing `DINFO=1` to make. Note that this WILL NOT result in a matching build even with the default compiler. You can suppress the `pokeruby.gba: FAILED` error by additionally passing `COMPARE=0`. diff --git a/Makefile b/Makefile index de45667f3..e852050fa 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ SHELL := /bin/bash -o pipefail ifeq ($(MODERN),0) CC1 := tools/agbcc/bin/agbcc$(EXE) else -CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) +CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -quiet endif CPP := $(PREFIX)cpp LD := $(PREFIX)ld @@ -38,13 +38,17 @@ GBAFIX := tools/gbafix/gbafix$(EXE) MAPJSON := tools/mapjson/mapjson$(EXE) ASFLAGS := -mcpu=arm7tdmi -I include --defsym $(GAME_VERSION)=1 --defsym REVISION=$(GAME_REVISION) --defsym $(GAME_LANGUAGE)=1 --defsym DEBUG=$(DEBUG) --defsym MODERN=$(MODERN) -CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef -Werror -Wno-trigraphs -D $(GAME_VERSION) -D REVISION=$(GAME_REVISION) -D $(GAME_LANGUAGE) -D DEBUG=$(DEBUG) -D MODERN=$(MODERN) +CPPFLAGS := -iquote include -Werror -Wno-trigraphs -D $(GAME_VERSION) -D REVISION=$(GAME_REVISION) -D $(GAME_LANGUAGE) -D DEBUG=$(DEBUG) -D MODERN=$(MODERN) ifeq ($(MODERN),0) +CPPFLAGS += -I tools/agbcc/include -I tools/agbcc -nostdinc -undef CC1FLAGS := -mthumb-interwork -Wimplicit -Wparentheses -Wunused -Werror -O2 -fhex-asm else -CC1FLAGS := -mthumb -mthumb-interwork -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -O2 -fno-toplevel-reorder -Wno-aggressive-loop-optimizations -Wno-pointer-to-int-cast +CC1FLAGS := -mthumb -mthumb-interwork -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -O2 -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast endif +ifneq (,$(DINFO)) +CC1FLAGS += -g +endif #### Files #### @@ -93,7 +97,7 @@ ALL_BUILDS := ruby ruby_rev1 ruby_rev2 sapphire sapphire_rev1 sapphire_rev2 ruby MODERN_BUILDS := $(ALL_BUILDS:%=%_modern) # Available targets -.PHONY: all clean tidy tools $(ALL_BUILDS) +.PHONY: all clean mostlyclean tidy tools $(ALL_BUILDS) infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line)))) @@ -131,13 +135,15 @@ ifeq ($(COMPARE),1) @$(SHA1SUM) $(BUILD_NAME).sha1 endif -clean: tidy +mostlyclean: tidy find sound/direct_sound_samples \( -iname '*.bin' \) -exec rm {} + $(RM) $(ALL_OBJECTS) find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' \) -exec rm {} + rm -f data/layouts/layouts.inc data/layouts/layouts_table.inc rm -f data/maps/connections.inc data/maps/events.inc data/maps/groups.inc data/maps/headers.inc find data/maps \( -iname 'connections.inc' -o -iname 'events.inc' -o -iname 'header.inc' \) -exec rm {} + + +clean: mostlyclean $(MAKE) clean -C tools/gbagfx $(MAKE) clean -C tools/scaninc $(MAKE) clean -C tools/preproc diff --git a/include/global.h b/include/global.h index d64cf987d..64abf8724 100644 --- a/include/global.h +++ b/include/global.h @@ -3,6 +3,7 @@ #include #include +#include #include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" diff --git a/src/save.c b/src/save.c index bc9546f52..3eeea88de 100644 --- a/src/save.c +++ b/src/save.c @@ -932,4 +932,5 @@ u8 unref_sub_8126080(u8 sector, u8 *data) } asm(".section .rodata\n" - "\t.align 2"); + "\t.align 2\n" + "\t.text"); -- cgit v1.2.3