diff --git a/.gitignore b/.gitignore index 1193e995..a2e9d718 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ build/ expected/ notes/ tools/gcc +tools/egcs +tools/egcs_original tools/ido *.elf *.o @@ -25,5 +27,6 @@ tools/ido # Tool artifacts ctx.c +ctx.c.m2c libultra_collection/ diff --git a/Makefile b/Makefile index 401c3d4c..8a2f092b 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,12 @@ ifeq ($(findstring _rom,$(TARGET)),_rom) CPPFLAGS += -D_FINALROM endif +ifneq ($(COMPILER),ido) + ifeq ($(COMPARE),0) + CPPFLAGS += -D ASM_FIXUPS=1 + endif +endif + SRC_DIRS := $(shell find src -type d) C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) S_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.s)) diff --git a/include/sys/asm.h b/include/sys/asm.h index 60e6ccd2..be0b5c3a 100644 --- a/include/sys/asm.h +++ b/include/sys/asm.h @@ -34,7 +34,7 @@ extern "C" { /* libgultra doesn't match with the .type directive but iQue sdk asm.h uses it */ -#ifdef BBPLAYER +#if defined(BBPLAYER) || (defined(ASM_FIXUPS) && !defined(__sgi)) #define ASM_TYPE_FUNC(x) .type x, @function #else #define ASM_TYPE_FUNC(x) @@ -48,7 +48,7 @@ extern "C" { x: ;\ .frame sp,0,ra -#if defined(BBPLAYER) || defined(__sgi) +#if defined(BBPLAYER) || defined(__sgi) || defined(ASM_FIXUPS) #define XLEAF(x) \ .globl x ;\ .aent x,0 ;\ @@ -58,7 +58,7 @@ extern "C" { .globl x #endif -#ifdef BBPLAYER +#if defined(BBPLAYER) || (defined(ASM_FIXUPS) && !defined(__sgi)) #define END(proc) \ .end proc ;\ .size proc, . - proc @@ -67,6 +67,18 @@ extern "C" { .end proc #endif +/* Some specific asm functions (guMtxCatF, _bcmp, _bcopy, _bzero) do not use a .size directive + in any known libultra version, so this macro is used to allow using said directive on those + functions without breaking matching the archives. */ +#if (defined(ASM_FIXUPS) && !defined(__sgi)) +#define END2(proc) \ + .end proc ;\ + .size proc, . - proc +#else +#define END2(proc) \ + .end proc +#endif + #define ABS(x, y) \ .globl x ;\ x = y @@ -75,7 +87,7 @@ extern "C" { .globl x ;\ x: -#if defined(BBPLAYER) || defined(__sgi) +#if defined(BBPLAYER) || defined(__sgi) || defined(ASM_FIXUPS) #define WEAK(x, y) \ .weakext x, y #else diff --git a/makefiles/modern_gcc.mk b/makefiles/modern_gcc.mk index a914d78e..48dbfc95 100644 --- a/makefiles/modern_gcc.mk +++ b/makefiles/modern_gcc.mk @@ -9,7 +9,7 @@ WARNINGS += -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-implicit-fu CFLAGS := -G 0 -c -nostdinc -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -mdivide-breaks -fno-PIC -fno-common -ffreestanding -fbuiltin -fno-builtin-sinf -fno-builtin-cosf -funsigned-char $(WARNINGS) CFLAGS += -fno-strict-aliasing # TODO: Try adjusting code to remove this ASFLAGS := -w -nostdinc -c -G 0 -march=vr4300 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64 -CPPFLAGS = -DMODERN_CC -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE) $(DEBUGFLAG) +CPPFLAGS = -DMODERN_CC -D ASM_FIXUPS=1 -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE) $(DEBUGFLAG) IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/compiler/modern_gcc -I $(WORKING_DIR)/include/PR MIPS_VERSION := -mips3 ASOPTFLAGS := diff --git a/src/libc/bcmp.s b/src/libc/bcmp.s index def32355..6bee1012 100644 --- a/src/libc/bcmp.s +++ b/src/libc/bcmp.s @@ -93,4 +93,4 @@ cmpne: li v0, 1 jr ra -.end _bcmp +END2(_bcmp) diff --git a/src/libc/bcopy.s b/src/libc/bcopy.s index 08757413..7dae5cf8 100644 --- a/src/libc/bcopy.s +++ b/src/libc/bcopy.s @@ -217,4 +217,4 @@ backwards_4: addiu a2, a2, -4 b backwards_4 -.end _bcopy +END2(_bcopy) diff --git a/src/libc/bzero.s b/src/libc/bzero.s index c3deec0a..91ad302a 100644 --- a/src/libc/bzero.s +++ b/src/libc/bzero.s @@ -69,4 +69,4 @@ bytezero: zerodone: jr ra -.end _bzero +END2(_bzero) diff --git a/src/mgu/asm.h b/src/mgu/asm.h index 0c417fae..099fa417 100644 --- a/src/mgu/asm.h +++ b/src/mgu/asm.h @@ -32,14 +32,27 @@ extern "C" { /* NABI32 is 64bit calling convention but 32bit type sizes) */ #define _MIPS_SIM_ABI64 3 /* MIPS 64 calling convention */ +#if (defined(ASM_FIXUPS) && !defined(__sgi)) +#define ASM_TYPE_FUNC(x) .type x, @function +#else +#define ASM_TYPE_FUNC(x) +#endif + #define LEAF(x) \ .globl x; \ + ASM_TYPE_FUNC(x) ;\ .ent x,0; \ x:; \ .frame sp,0,ra +#if (defined(ASM_FIXUPS) && !defined(__sgi)) +#define END(proc) \ + .end proc ;\ + .size proc, . - proc +#else #define END(proc) \ .end proc +#endif #ifdef __cplusplus diff --git a/src/mgu/mtxcatf.s b/src/mgu/mtxcatf.s index 4b96124b..48a1c82d 100644 --- a/src/mgu/mtxcatf.s +++ b/src/mgu/mtxcatf.s @@ -98,6 +98,6 @@ label_loop_j: addu sp , FRAME_SIZE j ra - .end guMtxCatF + END(guMtxCatF) /* end of file */