Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building on ARM64 MacOS #854

Open
wants to merge 12 commits into
base: develop/2.4.0
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2152,3 +2152,4 @@ lib/libs2d_engine.a

# user-specific config file
include/config/config_local.h
.DS_Store
42 changes: 31 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,18 @@ else ifeq ($(COMPILER),clang)
CC := clang
CXX := clang++
endif
# Prefer gcc's cpp if installed on the system
ifneq (,$(call find-command,cpp-10))
CPP := cpp-10
else
CPP := cpp
endif
ifneq ($(call find-command,mips-n64-ld),)
LD := mips-n64-ld

ARCH := $(shell uname -p)

# Check processor architecture. ARM users need a different binutils package.
ifeq ($(ARCH), arm)
LD := tools/mips64-elf-ld-arm
else
LD := tools/mips64-elf-ld
ifneq ($(call find-command,mips-n64-ld),)
LD := mips-n64-ld
else
LD := tools/mips64-elf-ld
endif
endif
AR := $(CROSS)ar
OBJDUMP := $(CROSS)objdump
Expand All @@ -507,6 +509,18 @@ endif
C_DEFINES := $(foreach d,$(DEFINES),-D$(d))
DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES)

# Prefer gcc's cpp if installed on the system
ifneq (,$(call find-command,clang))
CPP := clang
CPPFLAGS := -E -P -x c -Wno-trigraphs $(DEF_INC_CFLAGS)
else ifneq (,$(call find-command,cpp-10))
CPP := cpp-10
CPPFLAGS := -P -Wno-trigraphs $(DEF_INC_CFLAGS)
else
CPP := cpp
CPPFLAGS := -P -Wno-trigraphs $(DEF_INC_CFLAGS)
endif

# C compiler options
CFLAGS = -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) $(MIPSISET) $(DEF_INC_CFLAGS)
ifeq ($(COMPILER),gcc)
Expand All @@ -524,7 +538,6 @@ ASFLAGS := -march=vr4300 -mabi=32 $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(fore
RSPASMFLAGS := $(foreach d,$(DEFINES),-definelabel $(subst =, ,$(d)))

# C preprocessor flags
CPPFLAGS := -P -Wno-trigraphs $(DEF_INC_CFLAGS)

#==============================================================================#
# Miscellaneous Tools #
Expand Down Expand Up @@ -650,7 +663,14 @@ unf: $(ROM) $(LOADER_EXEC)
libultra: $(BUILD_DIR)/libultra.a

patch: $(ROM)
$(FLIPS) --create --bps $(shell python3 tools/detect_baseroms.py $(VERSION)) $(ROM) $(BUILD_DIR)/$(TARGET_STRING).bps
ifeq ($(shell uname), Darwin)
ifeq ($(MAKECMDGOALS), patch)
$(error "The 'make patch' command is not supported on macOS.")
endif
else
$(FLIPS) --create --bps $(shell python3 tools/detect_baseroms.py $(VERSION)) $(ROM) $(BUILD_DIR)/$(TARGET_STRING).bps
endif


# Extra object file dependencies
$(BUILD_DIR)/asm/ipl3.o: $(IPL3_RAW_FILES)
Expand Down
4 changes: 2 additions & 2 deletions sm64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ OUTPUT_ARCH (mips)

#define LINKER /* Removes externs from preprocessed script */
#define TARGET_N64
#include "segments.h"
#include "config.h"
#include "include/segments.h"
#include "include/config.h"
#undef LINKER

#define BEGIN_SEG(name, addr) \
Expand Down
8 changes: 7 additions & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ CC := gcc
CXX := g++
CFLAGS := -I. -O2 -s
LDFLAGS := -lm
ALL_PROGRAMS := armips filesizer lz4tpack rncpack n64graphics n64graphics_ci mio0 slienc n64cksum textconv aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv flips
ALL_PROGRAMS := armips filesizer lz4tpack rncpack n64graphics n64graphics_ci mio0 slienc n64cksum textconv aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv
LIBAUDIOFILE := audiofile/libaudiofile.a

OS := $(shell uname)

ifneq ($(OS), Darwin)
ALL_PROGRAMS += flips
endif

ifeq ($(OS),Windows_NT)
EXT := .exe
OUTPUTS := $(ALL_PROGRAMS:=.exe)
Expand Down
2 changes: 1 addition & 1 deletion tools/filesizer.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef _WIN32
#if !defined(_WIN32) && !defined(__APPLE__)
#include <byteswap.h>
#else
#define __bswap_constant_32(x) \
Expand Down
16 changes: 9 additions & 7 deletions tools/lz4hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,15 @@ LZ4HC_FindLongerMatch(LZ4HC_CCtx_internal* const ctx,
return md;
}

#ifdef LZ4T
int LZ4T_lastLiterals (
const BYTE** _ip,
BYTE** _op,
const BYTE** _anchor,
limitedOutput_directive limit,
BYTE* oend,
size_t length);
#endif

static int LZ4HC_compress_optimal ( LZ4HC_CCtx_internal* ctx,
const char* const source,
Expand Down Expand Up @@ -2027,13 +2036,6 @@ static int LZ4HC_compress_optimal ( LZ4HC_CCtx_internal* ctx,
op += lastRunSize;
}
#else
int LZ4T_lastLiterals (
const BYTE** _ip,
BYTE** _op,
const BYTE** _anchor,
limitedOutput_directive limit,
BYTE* oend,
size_t length);
LZ4T_lastLiterals(UPDATABLE(ip, op, anchor), limit, oend, (size_t)(iend - anchor));
#endif

Expand Down
Binary file added tools/mips64-elf-ld-arm
Binary file not shown.