From 13ac873c4d04d8469235923730005235c7a96b66 Mon Sep 17 00:00:00 2001 From: Iori Yanokura Date: Fri, 27 Jun 2025 22:49:22 +0900 Subject: [PATCH 1/3] Support apple silicon arm architecture --- lisp/Makefile.Darwin | 10 ++++++++-- lisp/c/eus.c | 2 +- lisp/c/eval.c | 24 ++++++++++++++++-------- lisp/c/printer.c | 6 +++--- lisp/image/jpeg/makefile | 4 ++-- lisp/opengl/src/oglforeign.c.c | 6 +++--- lisp/xwindow/xforeign.c.c | 4 ++-- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/lisp/Makefile.Darwin b/lisp/Makefile.Darwin index df7814f41..841a9e20e 100644 --- a/lisp/Makefile.Darwin +++ b/lisp/Makefile.Darwin @@ -42,11 +42,17 @@ endif # Pentium's arch returns 'i586', which is ignored by conditionals in c/*.[ch]. OS_VERSION=$(shell sw_vers -productVersion | sed s/\.[^.]*$$//) +UNAME_MACHINE=$(shell uname -m) ifeq ($(OS_VERSION), 10.5) MACHINE=i386 else - MACHINE=x86_64 - ALIGN_FUNCTIONS=-falign-functions=8 -fPIC + ifeq ($(UNAME_MACHINE), arm64) + MACHINE=aarch64 + ALIGN_FUNCTIONS=-falign-functions=8 -fPIC + else + MACHINE=x86_64 + ALIGN_FUNCTIONS=-falign-functions=8 -fPIC + endif endif DEBUG= -g diff --git a/lisp/c/eus.c b/lisp/c/eus.c index 29df26802..1390dca7e 100644 --- a/lisp/c/eus.c +++ b/lisp/c/eus.c @@ -1302,7 +1302,7 @@ char *argv[]; unsigned char *m; #ifdef Darwin - _end = sbrk(0); + _end = (int)(intptr_t)sbrk(0); #endif mypid=getpid(); diff --git a/lisp/c/eval.c b/lisp/c/eval.c index 06080e143..94cb3d662 100644 --- a/lisp/c/eval.c +++ b/lisp/c/eval.c @@ -714,7 +714,11 @@ __asm__ (".align 8\n" #if aarch64 __asm__ (".align 8\n" +#if Darwin + "_exec_function_i:\n\t" +#else "exec_function_i:\n\t" +#endif "sub sp, sp, #192\n\t" // 128(8x16) + 64 "stp x29, x30, [sp, 128]\n\t" "add x29, sp, 128\n\t" @@ -726,18 +730,18 @@ __asm__ (".align 8\n" // vargv -> stack "mov x1, 0\n\t" "ldr x2, [x29, 24]\n\t" - "b .FUNCII_LPCK\n\t" - ".FUNCII_LP:\n\t" + "b 1f\n\t" + "2:\n\t" "lsl x0, x1, 3\n\t" "add x3, x2, x0\n\t" // vargv[i] "add x4, sp, x0\n\t" // stack[i] "ldr x0, [x3]\n\t" "str x0, [x4]\n\t" // push stack "add x1, x1, 1\n\t" - ".FUNCII_LPCK:\n\t" + "1:\n\t" "ldr x5, [x29, 32]\n\t" "cmp x1, x5\n\t" - "blt .FUNCII_LP\n\t" + "blt 2b\n\t" // fargv -> register "ldr x0, [x29, 40]\n\t" // fargv "ldr d0, [x0]\n\t" @@ -782,7 +786,11 @@ __asm__ (".align 8\n" ); __asm__ (".align 8\n" +#if Darwin + "_exec_function_f:\n\t" +#else "exec_function_f:\n\t" +#endif "sub sp, sp, #192\n\t" // 128(8x16) + 64 "stp x29, x30, [sp, 128]\n\t" "add x29, sp, 128\n\t" @@ -794,18 +802,18 @@ __asm__ (".align 8\n" // vargv -> stack "mov x1, 0\n\t" "ldr x2, [x29, 24]\n\t" - "b .FUNCFF_LPCK\n\t" - ".FUNCFF_LP:\n\t" + "b 3f\n\t" + "4:\n\t" "lsl x0, x1, 3\n\t" "add x3, x2, x0\n\t" // vargv[i] "add x4, sp, x0\n\t" // stack[i] "ldr x0, [x3]\n\t" "str x0, [x4]\n\t" // push stack "add x1, x1, 1\n\t" - ".FUNCFF_LPCK:\n\t" + "3:\n\t" "ldr x5, [x29, 32]\n\t" "cmp x1, x5\n\t" - "blt .FUNCFF_LP\n\t" + "blt 4b\n\t" // fargv -> register "ldr x0, [x29, 40]\n\t" // fargv "ldr d0, [x0]\n\t" diff --git a/lisp/c/printer.c b/lisp/c/printer.c index 67335c58b..82415c695 100644 --- a/lisp/c/printer.c +++ b/lisp/c/printer.c @@ -296,7 +296,7 @@ context *ctx; writestr(f,(byte *)"#<",2); printsym(ctx,class->c.cls.name,f); writech(f,' '); - printhex(obj,f); + printhex((int)(intptr_t)obj,f); writech(f,'>');} static void printpkg(p,f) @@ -359,7 +359,7 @@ int prlevel; break; case ELM_BYTE: writestr(f,(byte *)"#'); break; case ELM_CHAR: @@ -385,7 +385,7 @@ int prlevel; break; case ELM_FOREIGN: writestr(f,(byte *)"#u",2); - printstr(ctx,vecsize(vec),vec->c.ivec.iv[0],f); + printstr(ctx,vecsize(vec),(byte *)vec->c.ivec.iv[0],f); break; default: if (classof(vec)==C_VECTOR) writestr(f,(byte *)"#(",2); diff --git a/lisp/image/jpeg/makefile b/lisp/image/jpeg/makefile index 231d58764..0f353667b 100644 --- a/lisp/image/jpeg/makefile +++ b/lisp/image/jpeg/makefile @@ -38,8 +38,8 @@ else CC += -fPIC endif ifeq ($(ARCHDIR), Darwin) -CC += -I/opt/local/lib/jpeg6b/include -I/opt/local/include -LD += -L/opt/local/lib/jpeg6b/lib -L/opt/local/lib +CC += -I/opt/local/lib/jpeg6b/include -I/opt/local/include -I/opt/homebrew/include +LD += -L/opt/local/lib/jpeg6b/lib -L/opt/local/lib -L/opt/homebrew/lib endif ifeq ($(ARCHDIR), LinuxARM) CC += -fPIC diff --git a/lisp/opengl/src/oglforeign.c.c b/lisp/opengl/src/oglforeign.c.c index 45aee3959..f923df337 100644 --- a/lisp/opengl/src/oglforeign.c.c +++ b/lisp/opengl/src/oglforeign.c.c @@ -32,14 +32,14 @@ char *xentry; entry=(eusinteger_t)dlsym((eusinteger_t)dlhandle, xentry); if ( !entry ) { dlhandle=(eusinteger_t)dlopen("cygGLU-1.dll", RTLD_LAZY); - entry=(eusinteger_t)dlsym(dlhandle, xentry);} + entry=(eusinteger_t)dlsym((void *)dlhandle, xentry);} if ( !entry ) { dlhandle=(eusinteger_t)dlopen(0, RTLD_LAZY); - entry=(eusinteger_t)dlsym(dlhandle, xentry);} + entry=(eusinteger_t)dlsym((void *)dlhandle, xentry);} #elif Darwin eusinteger_t dlhandle; dlhandle=(eusinteger_t)dlopen(0, RTLD_LAZY); - entry=(eusinteger_t)dlsym(dlhandle, xentry); + entry=(eusinteger_t)dlsym((void *)dlhandle, xentry); #else #if (WORD_SIZE == 64) entry=(eusinteger_t)dlsym((void *)((eusinteger_t)(sysmod->c.ldmod.handle) & ~3L), xentry); diff --git a/lisp/xwindow/xforeign.c.c b/lisp/xwindow/xforeign.c.c index 913c68138..aa9a2e581 100644 --- a/lisp/xwindow/xforeign.c.c +++ b/lisp/xwindow/xforeign.c.c @@ -423,7 +423,7 @@ char *xentry; dlhandle=(eusinteger_t)dlopen("/usr/bin/cygX11-6.dll", RTLD_LAZY); if( dlhandle==0 ) dlhandle=(eusinteger_t)dlopen("libX11.dll", RTLD_LAZY); - entry=(eusinteger_t)dlsym(dlhandle, xentry); + entry=(eusinteger_t)dlsym((void *)dlhandle, xentry); #elif Darwin eusinteger_t dlhandle; dlhandle=(eusinteger_t)dlopen("/opt/X11/lib/libX11.dylib", RTLD_LAZY); @@ -431,7 +431,7 @@ char *xentry; dlhandle=(eusinteger_t)dlopen("/usr/local/lib/libX11.dylib", RTLD_LAZY); if( dlhandle==0 ) dlhandle=(eusinteger_t)dlopen("libX11.dylib", RTLD_LAZY); - entry=(eusinteger_t)dlsym(dlhandle, xentry); + entry=(eusinteger_t)dlsym((void *)dlhandle, xentry); #else entry=(eusinteger_t)dlsym((void *)((eusinteger_t)(sysmod->c.ldmod.handle) & ~3), xentry); #endif From f6d3fa20ee1036e35bf8b9d1e6b327b384547410 Mon Sep 17 00:00:00 2001 From: Iori Yanokura Date: Fri, 27 Jun 2025 23:09:12 +0900 Subject: [PATCH 2/3] Add github action test for macos-x and macos-x-arm64 (Apple Silicon) --- .github/workflows/config.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index c2e179e09..5af63167c 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -196,7 +196,18 @@ jobs: exit 0" osx: - runs-on: macos-13 # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md + strategy: + matrix: + include: + # https://github.com/actions/runner-images/tree/main/images/macos + # Note: To test macOS-x with Intel architecture, + # you need to use the paid macOS-x-large runner, as macOS-x is grouped with ARM-based runners. + # https://docs.github.com/en/actions/concepts/runners/about-larger-runners + - runs-on: macos-13 # Intel (x64) + - runs-on: macos-14 # ARM64 (Apple Silicon) + - runs-on: macos-15 # ARM64 (Apple Silicon) + fail-fast: false + runs-on: ${{ matrix.runs-on }} timeout-minutes: 60 steps: - name: Checkout From e338deabbd73ac63a2c7fd64a5f61c0b12e8c04d Mon Sep 17 00:00:00 2001 From: Iori Yanokura Date: Mon, 30 Jun 2025 22:41:02 +0900 Subject: [PATCH 3/3] Install xquartz for macos-14 and macos-15 --- .travis.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.sh b/.travis.sh index 1bf15755b..6b0d6e5ad 100755 --- a/.travis.sh +++ b/.travis.sh @@ -84,6 +84,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew list mesalib-glw &>/dev/null || HOMEBREW_NO_AUTO_UPDATE=1 brew install mesalib-glw brew list mesa-glu &>/dev/null || HOMEBREW_NO_AUTO_UPDATE=1 brew install mesa-glu brew list bullet &>/dev/null || HOMEBREW_NO_AUTO_UPDATE=1 brew install bullet + brew list xquartz &>/dev/null || HOMEBREW_NO_AUTO_UPDATE=1 brew install xquartz travis_time_end fi