Native Arm Support for macOS (#492)
Remove the need to use rosetta 2, and now use arm instead. Intel macs should still work, although have not been tested (I don't have a intel mac). Coopnet and lua have both been tested, and both work. I ended up removing the logfile stuff, as 1, it was only used once for mario action hang, and 2, it was causing pointer misalignment on macos arm. Discord integration is disabled on arm. Compilation now takes 25 seconds instead of a minute and 20
This commit is contained in:
parent
c2f1ed69a0
commit
139fcc1dd2
20
Makefile
20
Makefile
|
@ -408,6 +408,8 @@ $(eval $(call validate-option,COMPARE,0 1))
|
|||
|
||||
ifeq ($(OSX_BUILD),0)
|
||||
USE_APP := 0
|
||||
else ifeq ($(shell uname -m),arm64)
|
||||
DISCORD_SDK := 0
|
||||
endif
|
||||
|
||||
TARGET_STRING := sm64.$(VERSION).$(GRUCODE)
|
||||
|
@ -959,7 +961,11 @@ ifeq ($(WINDOWS_BUILD),1)
|
|||
LDFLAGS += -Llib/lua/win64 -l:liblua53.a
|
||||
endif
|
||||
else ifeq ($(OSX_BUILD),1)
|
||||
LDFLAGS += -L./lib/lua/mac/ -l lua53
|
||||
ifeq ($(shell uname -m),arm64)
|
||||
LDFLAGS += -L./lib/lua/mac_arm/ -l lua53
|
||||
else
|
||||
LDFLAGS += -L./lib/lua/mac_intel/ -l lua53
|
||||
endif
|
||||
else ifeq ($(TARGET_RPI),1)
|
||||
ifneq (,$(findstring aarch64,$(machine)))
|
||||
LDFLAGS += -Llib/lua/linux -l:liblua53-arm64.a
|
||||
|
@ -980,9 +986,15 @@ ifeq ($(COOPNET),1)
|
|||
LDFLAGS += -Llib/coopnet/win64 -l:libcoopnet.a -l:libjuice.a -lbcrypt -lws2_32 -liphlpapi
|
||||
endif
|
||||
else ifeq ($(OSX_BUILD),1)
|
||||
LDFLAGS += -Wl,-rpath,@loader_path -L./lib/coopnet/mac/ -l coopnet
|
||||
COOPNET_LIBS += ./lib/coopnet/mac/libcoopnet.dylib
|
||||
COOPNET_LIBS += ./lib/coopnet/mac/libjuice.1.2.2.dylib
|
||||
ifeq ($(shell uname -m),arm64)
|
||||
LDFLAGS += -Wl,-rpath,@loader_path -L./lib/coopnet/mac_arm/ -l coopnet
|
||||
COOPNET_LIBS += ./lib/coopnet/mac_arm/libcoopnet.dylib
|
||||
COOPNET_LIBS += ./lib/coopnet/mac_arm/libjuice.1.2.2.dylib
|
||||
else
|
||||
LDFLAGS += -Wl,-rpath,@loader_path -L./lib/coopnet/mac_intel/ -l coopnet
|
||||
COOPNET_LIBS += ./lib/coopnet/mac_intel/libcoopnet.dylib
|
||||
COOPNET_LIBS += ./lib/coopnet/mac_intel/libjuice.1.2.2.dylib
|
||||
endif
|
||||
else ifeq ($(TARGET_RPI),1)
|
||||
ifneq (,$(findstring aarch64,$(machine)))
|
||||
LDFLAGS += -Llib/coopnet/linux -l:libcoopnet-arm64.a -l:libjuice.a
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -43,7 +43,6 @@
|
|||
#include "pc/network/network.h"
|
||||
#include "pc/lua/smlua.h"
|
||||
#include "pc/network/socket/socket.h"
|
||||
#include "pc/logfile.h"
|
||||
#ifdef BETTERCAMERA
|
||||
#include "bettercamera.h"
|
||||
#endif
|
||||
|
@ -2056,31 +2055,13 @@ static u8 prevent_hang(u32 hangPreventionActions[], u8* hangPreventionIndex) {
|
|||
hangPreventionActions[*hangPreventionIndex] = gMarioState->action;
|
||||
*hangPreventionIndex = *hangPreventionIndex + 1;
|
||||
if (*hangPreventionIndex < MAX_HANG_PREVENTION) { return FALSE; }
|
||||
|
||||
// only dump the log once
|
||||
static u8 dumped = FALSE;
|
||||
if (dumped) { return TRUE; }
|
||||
dumped = TRUE;
|
||||
|
||||
// open the log
|
||||
FILE* f = logfile_open(LFT_HANG);
|
||||
if (f == NULL) { return TRUE; }
|
||||
|
||||
|
||||
// complain to console
|
||||
printf("#######################################\n");
|
||||
printf("# HANG PREVENTED #\n");
|
||||
printf("# Send the error log to the developer #\n");
|
||||
printf("#######################################\n");
|
||||
|
||||
// save to log
|
||||
fprintf(f, "(gMarioState->action: hang prevention begin)\n");
|
||||
for (s32 i = 0; i < MAX_HANG_PREVENTION; i++) {
|
||||
fprintf(f, "%08X\n", hangPreventionActions[i]);
|
||||
}
|
||||
fprintf(f, "(gMarioState->action: hang prevention end)\n");
|
||||
|
||||
logfile_close(LFT_HANG);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
// logfile.c - handles opening and closing of the log file
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include "pc/fs/fs.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "logfile.h"
|
||||
|
||||
struct LogFile gLogFiles[LFT_MAX] = {
|
||||
{ .fileName = "hanglog.txt", .active = false, .firstOpen = true, .file = NULL },
|
||||
{ .fileName = "discordlog.txt", .active = false, .firstOpen = true, .file = NULL }
|
||||
};
|
||||
|
||||
FILE* logfile_open(enum LogFileType logFileType) {
|
||||
struct LogFile* logfile = &gLogFiles[logFileType];
|
||||
if (logfile->active) {
|
||||
return logfile->file;
|
||||
}
|
||||
|
||||
LOG_INFO("opening log file '%s'", logfile->fileName);
|
||||
logfile->file = fopen(fs_get_write_path(logfile->fileName), logfile->firstOpen ? "w+" : "a");
|
||||
logfile->firstOpen = false;
|
||||
|
||||
if (logfile->file == NULL) { return NULL; }
|
||||
|
||||
logfile->active = true;
|
||||
return logfile->file;
|
||||
}
|
||||
|
||||
void logfile_close(enum LogFileType logFileType) {
|
||||
struct LogFile* logfile = &gLogFiles[logFileType];
|
||||
if (!logfile->active) { return; }
|
||||
|
||||
fflush(logfile->file);
|
||||
fclose(logfile->file);
|
||||
|
||||
logfile->file = NULL;
|
||||
logfile->active = false;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
#ifndef LOGFILE_H
|
||||
#define LOGFILE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
#pragma pack(1)
|
||||
struct LogFile {
|
||||
const char* fileName;
|
||||
bool active;
|
||||
bool firstOpen;
|
||||
FILE* file;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
enum LogFileType {
|
||||
LFT_HANG,
|
||||
LFT_DISCORD,
|
||||
LFT_MAX
|
||||
};
|
||||
|
||||
extern struct LogFile gLogFiles[];
|
||||
|
||||
FILE* logfile_open(enum LogFileType logFileType);
|
||||
void logfile_close(enum LogFileType logFileType);
|
||||
|
||||
static void _logfile_print_timestamp(enum LogFileType logFileType) {
|
||||
FILE* f = gLogFiles[logFileType].file;
|
||||
time_t ltime = time(NULL);
|
||||
#if defined(_WIN32)
|
||||
char* str = asctime(localtime(<ime));
|
||||
#else
|
||||
struct tm ltime2 = { 0 };
|
||||
localtime_r(<ime, <ime2);
|
||||
char* str = asctime(<ime2);
|
||||
#endif
|
||||
fprintf(f, "%.*s", (int)strlen(str) - 1, str);
|
||||
}
|
||||
|
||||
static void _logfile_print_log_type(enum LogFileType logFileType, char* logType) {
|
||||
FILE* f = gLogFiles[logFileType].file;
|
||||
fprintf(f, "\t[%s]\t", logType);
|
||||
}
|
||||
|
||||
static void _logfile_print_short_filename(enum LogFileType logFileType, char* filename, int fileLine) {
|
||||
FILE* f = gLogFiles[logFileType].file;
|
||||
char* last = strrchr(filename, '/');
|
||||
if (last != NULL) {
|
||||
fprintf(f, "%s:%d\t\t", last + 1, fileLine);
|
||||
} else {
|
||||
fprintf(f, "???:%d\t\t", fileLine);
|
||||
}
|
||||
}
|
||||
|
||||
static void _logfile_print_log(enum LogFileType logFileType, char* logType, char* filename, int fileLine) {
|
||||
logfile_open(logFileType);
|
||||
_logfile_print_timestamp(logFileType);
|
||||
_logfile_print_log_type(logFileType, logType);
|
||||
_logfile_print_short_filename(logFileType, filename, fileLine);
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(DISABLE_MODULE_LOG)
|
||||
#define LOGFILE_DEBUG(_LFT, ...)
|
||||
#define LOGFILE_INFO(_LFT, ...)
|
||||
#define LOGFILE_ERROR(_LFT, ...)
|
||||
#elif defined(DEBUG) && !defined(DISABLE_MODULE_LOG)
|
||||
#define LOGFILE_DEBUG(_LFT, ...) ( _logfile_print_log(_LFT, "DEBUG", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_DEBUG(__VA_ARGS__))
|
||||
#define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_INFO (__VA_ARGS__))
|
||||
#define LOGFILE_ERROR(_LFT, ...) ( _logfile_print_log(_LFT, "ERROR", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_ERROR(__VA_ARGS__))
|
||||
#else
|
||||
#define LOGFILE_DEBUG(_LFT, ...) ( _logfile_print_log(_LFT, "DEBUG", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"))
|
||||
#define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"))
|
||||
#define LOGFILE_ERROR(_LFT, ...) ( _logfile_print_log(_LFT, "ERROR", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"))
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue