diff --git a/.gitignore b/.gitignore index 88471e55..0fbd6c8a 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,10 @@ build/* !/lib/*.a lib/libs2d_engine.a +!/lib/gcclib/*.a +!/lib/gcclib/divbreak/*.a +!/lib/gcclib/nocheck/*.a +!/lib/gcclib/trap/*.a !/lib/n64/*.a !/lib/ique/*.a diff --git a/Makefile b/Makefile index f56ac6bc..484b2c28 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,14 @@ COMPILER ?= gcc $(eval $(call validate-option,COMPILER,gcc)) +# LIBGCCDIR - selects the libgcc configuration for checking for dividing by zero +# trap - GCC default behavior, uses teq instructions which some emulators don't like +# divbreak - this is similar to IDO behavior, and is default. +# nocheck - never checks for dividing by 0. Technically fastest, but also UB so not recommended +LIBGCCDIR ?= divbreak +$(eval $(call validate-option,LIBGCCDIR,trap divbreak nocheck)) + + # SAVETYPE - selects the save type # eep4k - uses EEPROM 4kbit # eep16k - uses EEPROM 16kbit (There aren't any differences in syntax, but this is provided just in case) @@ -128,7 +136,7 @@ else ifeq ($(GRUCODE),super3d) # Super3D DEFINES += SUPER3D_GBI=1 F3D_NEW=1 endif -LIBRARIES := gcc nustd hvqm2 z goddard +LIBRARIES := nustd hvqm2 z goddard # TEXT ENGINES # s2dex_text_engine - Text Engine by someone2639 @@ -409,7 +417,7 @@ DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES) # C compiler options CFLAGS = -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) $(MIPSISET) $(DEF_INC_CFLAGS) ifeq ($(COMPILER),gcc) - CFLAGS += -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra + CFLAGS += -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra -Wno-missing-braces else CFLAGS += -non_shared -Wab,-r4300_mul -Xcpluscomm -Xfullwarn -signed -32 endif @@ -757,7 +765,7 @@ $(BUILD_DIR)/libz.a: $(LIBZ_O_FILES) # Link SM64 ELF file $(ELF): $(O_FILES) $(YAY0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) undefined_syms.txt $(BUILD_DIR)/libz.a $(BUILD_DIR)/libgoddard.a @$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n" - $(V)$(LD) --gc-sections -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -l$(ULTRALIB) -Llib $(LINK_LIBRARIES) -u sprintf -u osMapTLB + $(V)$(LD) --gc-sections -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -l$(ULTRALIB) -Llib $(LINK_LIBRARIES) -u sprintf -u osMapTLB -Llib/gcclib/$(LIBGCCDIR) -lgcc # Build ROM $(ROM): $(ELF) diff --git a/lib/gcclib/divbreak/libgcc.a b/lib/gcclib/divbreak/libgcc.a new file mode 100644 index 00000000..2cdcc913 Binary files /dev/null and b/lib/gcclib/divbreak/libgcc.a differ diff --git a/lib/libgcc.a b/lib/gcclib/nocheck/libgcc.a similarity index 63% rename from lib/libgcc.a rename to lib/gcclib/nocheck/libgcc.a index b15f2361..a30911b4 100644 Binary files a/lib/libgcc.a and b/lib/gcclib/nocheck/libgcc.a differ diff --git a/lib/gcclib/trap/libgcc.a b/lib/gcclib/trap/libgcc.a new file mode 100644 index 00000000..158a7955 Binary files /dev/null and b/lib/gcclib/trap/libgcc.a differ