Add support for powerpc, powerpc64 and powerpc64le on FreeBSD

powerpc64le is tested by self-hosted recompilation. powerpc64 and
powerpc currently untested.
This commit is contained in:
Piotr Kubaj 2026-01-05 12:00:14 +01:00 committed by Christophe Rhodes
parent 64fd961ef1
commit b5f29ccede
7 changed files with 111 additions and 5 deletions

View file

@ -398,7 +398,7 @@ case $uname_arch in
amd64) guessed_sbcl_arch=x86-64 ;;
sparc*) guessed_sbcl_arch=sparc ;;
sun*) guessed_sbcl_arch=sparc ;;
*ppc) guessed_sbcl_arch=ppc ;;
*powerpc|*ppc) guessed_sbcl_arch=ppc ;;
ppc64) guessed_sbcl_arch=ppc ;;
ppc64le) guessed_sbcl_arch=ppc64 ;; # is ok because there was never 32-bit LE
Power*Macintosh) guessed_sbcl_arch=ppc ;;
@ -433,6 +433,16 @@ if [ "$sbcl_os" = "netbsd" ] && [ `uname -p` = "aarch64" ]; then
guessed_sbcl_arch=arm64
fi
# Under FreeBSD, uname -m returns "powerpc" even if CPU is powerpc64.
if [ "$sbcl_os" = "freebsd" ] && [ `uname -p` = "powerpc64" ]; then
guessed_sbcl_arch=ppc64
fi
# Under FreeBSD, uname -m returns "powerpc" even if CPU is powerpc64le.
if [ "$sbcl_os" = "freebsd" ] && [ `uname -p` = "powerpc64le" ]; then
guessed_sbcl_arch=ppc64
fi
echo //setting up CPU-architecture-dependent information
if test -n "$SBCL_ARCH"
then

View file

@ -0,0 +1,39 @@
# -*- makefile -*- for the C-level run-time support for SBCL
# This software is part of the SBCL system. See the README file for
# more information.
#
# This software is derived from the CMU CL system, which was
# written at Carnegie Mellon University and released into the
# public domain. The software is in the public domain and is
# provided with absolutely no warranty. See the COPYING and CREDITS
# files for more information.
CFLAGS += -m32 -std=gnu99
LINKFLAGS += -m32 -Wl,--export-dynamic
ASSEM_SRC = ppc-assem.S
ARCH_SRC = ppc-arch.c
OS_SRC = bsd-os.c ppc-bsd-os.c
OS_LIBS = -ldl -Wl,-no-as-needed -lutil
ifdef LISP_FEATURE_GENCGC
GC_SRC = fullcgc.c gencgc.c traceroot.c
endif
# Until sbcl-0.6.7.3, we used "LINKFLAGS+=-static" here, which
# worked fine for most things, but LOAD-FOREIGN & friends require
# dlopen() etc., which in turn depend on dynamic linking of the
# runtime.
OS_LIBS += -lutil -L/usr/local/lib
CPPFLAGS += -isystem/usr/local/include
ifdef LISP_FEATURE_SB_THREAD
OS_LIBS += -lpthread
endif
ifdef LISP_FEATURE_SB_CORE_COMPRESSION
OS_LIBS += -lzstd
endif
SBCL_PAXCTL=elfctl -e +noaslr

View file

@ -0,0 +1,39 @@
# -*- makefile -*- for the C-level run-time support for SBCL
# This software is part of the SBCL system. See the README file for
# more information.
#
# This software is derived from the CMU CL system, which was
# written at Carnegie Mellon University and released into the
# public domain. The software is in the public domain and is
# provided with absolutely no warranty. See the COPYING and CREDITS
# files for more information.
CFLAGS += -m64 -std=gnu99
LINKFLAGS += -m64 -Wl,--export-dynamic
ASSEM_SRC = ppc64-assem.S
ARCH_SRC = ppc-arch.c
OS_SRC = bsd-os.c ppc-bsd-os.c
OS_LIBS = -ldl -Wl,-no-as-needed -lutil
ifdef LISP_FEATURE_GENCGC
GC_SRC = fullcgc.c gencgc.c traceroot.c
endif
# Until sbcl-0.6.7.3, we used "LINKFLAGS+=-static" here, which
# worked fine for most things, but LOAD-FOREIGN & friends require
# dlopen() etc., which in turn depend on dynamic linking of the
# runtime.
OS_LIBS += -lutil -L/usr/local/lib
CPPFLAGS += -isystem/usr/local/include
ifdef LISP_FEATURE_SB_THREAD
OS_LIBS += -lpthread
endif
ifdef LISP_FEATURE_SB_CORE_COMPRESSION
OS_LIBS += -lzstd
endif
SBCL_PAXCTL=elfctl -e +noaslr

View file

@ -60,7 +60,7 @@ arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *context)
{
os_vm_address_t addr;
#if defined(LISP_FEATURE_NETBSD) || defined(LISP_FEATURE_OPENBSD)
#if defined(LISP_FEATURE_NETBSD) || defined(LISP_FEATURE_OPENBSD) || defined(LISP_FEATURE_FREEBSD)
addr = (os_vm_address_t) (code->si_addr);
#else
addr = (os_vm_address_t) (*os_context_register_addr(context,PT_DAR));

View file

@ -7,33 +7,39 @@
#include "thread.h"
int *
os_context_register_t *
os_context_register_addr(os_context_t *context, int offset)
{
#if defined(LISP_FEATURE_NETBSD)
return &context->uc_mcontext.__gregs[offset];
#elif defined(LISP_FEATURE_OPENBSD)
return &context->sc_frame.fixreg[offset];
#elif defined(LISP_FEATURE_FREEBSD)
return &context->uc_mcontext.mc_frame[offset];
#endif
}
#if defined(ARCH_HAS_STACK_POINTER) /* It's not defined on PPC. */
int *
os_context_register_t *
os_context_sp_addr(os_context_t *context)
{
#if defined(LISP_FEATURE_NETBSD)
return &(_UC_MACHINE_SP(context));
#elif defined(LISP_FEATURE_FREEBSD)
return &context->uc_mcontext.mc_frame[1];
#endif
}
#endif
int *
os_context_register_t *
os_context_lr_addr(os_context_t *context)
{
#if defined(LISP_FEATURE_NETBSD)
return &context->uc_mcontext.__gregs[_REG_LR];
#elif defined(LISP_FEATURE_OPENBSD)
return &context->sc_frame.lr;
#elif defined(LISP_FEATURE_FREEBSD)
return &context->uc_mcontext.mc_lr;
#endif
}
@ -44,6 +50,8 @@ os_context_ctr_addr(os_context_t *context)
return &context->uc_mcontext.__gregs[_REG_CTR];
#elif defined(LISP_FEATURE_OPENBSD)
return &context->sc_frame.ctr;
#elif defined(LISP_FEATURE_FREEBSD)
return &context->uc_mcontext.mc_ctr;
#endif
}
@ -54,6 +62,8 @@ os_context_cr_addr(os_context_t *context)
return &context->uc_mcontext.__gregs[_REG_CR];
#elif defined(LISP_FEATURE_OPENBSD)
return &context->sc_frame.cr;
#elif defined(LISP_FEATURE_FREEBSD)
return &context->uc_mcontext.mc_cr;
#endif
}

View file

@ -1,12 +1,19 @@
#ifndef _PPC_BSD_OS_H
#define _PPC_BSD_OS_H
#ifdef __LP64__
typedef long os_context_register_t;
#else
typedef int os_context_register_t;
#endif
typedef ucontext_t os_context_t;
#ifdef LISP_FEATURE_NETBSD
# define OS_CONTEXT_PC(context) _UC_MACHINE_PC(context)
#elif defined LISP_FEATURE_OPENBSD
# define OS_CONTEXT_PC(context) context->sc_frame.srr0
#elif defined(LISP_FEATURE_FREEBSD)
# define OS_CONTEXT_PC(context) context->uc_mcontext.mc_srr0
#else
# error "Need a definition of OS_CONTEXT_PC"
#endif

View file

@ -0,0 +1 @@
#include <ppc-bsd-os.h>