bsd.cpu.mk: Introduce MACHINE_ABI

MACHINE_ABI is a list of properties of the ABI used for MACHINE_ARCH.
It should be used in place of long conditionals on MACHINE_ARCH where
practical.

The following properties are indicated with one of the follow values:

Byte order:                  big-endian, little-endian
Floating point ABI:          soft-float, hard-float
Size of long (size_t, etc):  long32, long64
Pointer type:                ptr32, ptr64
Size of time_t:              time32, time64

For example, i386 targets will be:
MACHINE_ABI=	big-endian hard-float long32 ptr32 time32

Reviewed by:	imp
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36421
This commit is contained in:
Brooks Davis 2022-10-05 17:26:30 +01:00
parent 77becb9325
commit 426fc376af
2 changed files with 45 additions and 1 deletions

View File

@ -66,6 +66,12 @@ LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}"
LIB32CFLAGS= -DCOMPAT_32BIT
LIB32DTRACE= ${DTRACE} -32
LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
LIB32_MACHINE_ABI= ${MACHINE_ABI:N*64} long32 ptr32
.if ${COMPAT_ARCH} == "amd64"
LIB32_MACHINE_ABI+= time32
.else
LIB32_MACHINE_ABI+= time64
.endif
# -------------------------------------------------------------------
# In the program linking case, select LIBCOMPAT
@ -95,7 +101,7 @@ _LIBCOMPAT:= ${WANT_COMPAT}
# Set defaults based on type.
libcompat= ${_LIBCOMPAT:tl}
_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS LDFLAGS \
_MACHINE _MACHINE_ARCH \
_MACHINE _MACHINE_ARCH _MACHINE_ABI \
WMAKEENV WMAKEFLAGS WMAKE WORLDTMP
.for _var in ${_LIBCOMPAT_MAKEVARS}
.if !empty(LIB${_LIBCOMPAT}${_var})

View File

@ -362,3 +362,41 @@ CFLAGS_NO_SIMD += ${CFLAGS_NO_SIMD.${COMPILER_TYPE}}
CFLAGS += ${CFLAGS.${MACHINE_ARCH}}
CXXFLAGS += ${CXXFLAGS.${MACHINE_ARCH}}
#
# MACHINE_ABI is a list of properties about the ABI used for MACHINE_ARCH.
# The following properties are indicated with one of the follow values:
#
# Byte order: big-endian, little-endian
# Floating point ABI: soft-float, hard-float
# Size of long (size_t, etc): long32, long64
# Pointer type: ptr32, ptr64
# Size of time_t: time32, time64
#
.if (${MACHINE} == "arm" && (defined(CPUTYPE) && ${CPUTYPE:M*soft*})) || \
(${MACHINE_ARCH} == "powerpc" && (defined(CPUTYPE) && ${CPUTYPE} == "e500")) || \
${MACHINE_ARCH:Mriscv*sf*}
MACHINE_ABI+= soft-float
.else
MACHINE_ABI+= hard-float
.endif
# Currently all 64-bit architectures include 64 in their name (see arch(7)).
.if ${MACHINE_ARCH:M*64*}
MACHINE_ABI+= long64
.else
MACHINE_ABI+= long32
.endif
.if ${MACHINE_ABI:Mlong64}
MACHINE_ABI+= ptr64
.else
MACHINE_ABI+= ptr32
.endif
.if ${MACHINE_ARCH} == "i386"
MACHINE_ABI+= time32
.else
MACHINE_ABI+= time64
.endif
.if ${MACHINE_ARCH:Mpowerpc*} && !${MACHINE_ARCH:M*le}
MACHINE_ABI+= big-endian
.else
MACHINE_ABI+= little-endian
.endif