Add the ability to link programs against a compat ABI.
Linkage is controlled by two make knobs: WANT_COMPAT - Prefer to link against the compat ABI. NEED_COMPAT - Link against the compat ABI or fail to build. Supported values are "32", "soft", and "any". The latter meaning pick the first[0] supported compat ABI. This can be used to provide test binaries for compat ABIs or to link ABI-specific programs. [0] We currently support only one compat ABI at a time, but this may change in the future and some code in this commit is structured to ease that change. Reviewed by: bdrewery, jhb Obtained from: CheriBSD (in concept) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22023
This commit is contained in:
parent
bac060388f
commit
6b53d51078
@ -17,6 +17,7 @@ files. In most cases it is only interesting to include bsd.prog.mk or
|
||||
bsd.lib.mk.
|
||||
|
||||
bsd.arch.inc.mk - includes arch-specific Makefile.$arch
|
||||
bsd.compat.mk - definitions for building programs against compat ABIs
|
||||
bsd.compiler.mk - defined based on current compiler
|
||||
bsd.confs.mk - install of configuration files
|
||||
bsd.cpu.mk - sets CPU/arch-related variables (included from sys.mk)
|
||||
@ -378,6 +379,10 @@ LINKMODE Mode of links created with LINKS [${BINMODE}].
|
||||
MAN Manual pages. If no MAN variable is defined,
|
||||
"MAN=${PROG}.1" is assumed. See bsd.man.mk for more details.
|
||||
|
||||
NEED_COMPAT Build and link targeting a compatability ABI or fail if it
|
||||
is not available. Supported values are "32", "soft", and
|
||||
"any" being a wildcard.
|
||||
|
||||
PROG The name of the program to build. If not supplied, nothing
|
||||
is built.
|
||||
|
||||
@ -440,6 +445,9 @@ SUBDIR A list of subdirectories that should be built as well.
|
||||
Each of the targets will execute the same target in the
|
||||
subdirectories.
|
||||
|
||||
WANT_COMPAT Similar to NEED_COMPAT, but build with the base ABI if
|
||||
the specified ABI is not available.
|
||||
|
||||
The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
|
||||
if it exists, as well as the include file <bsd.man.mk>.
|
||||
|
||||
|
@ -3,18 +3,16 @@
|
||||
.if !targets(__<${_this:T}>__)
|
||||
__<${_this:T}>__:
|
||||
|
||||
# Makefile for the compatibility libraries.
|
||||
# - 32-bit compat libraries on MIPS, PowerPC, and AMD64.
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# 32 bit world
|
||||
.if ${TARGET_ARCH} == "amd64"
|
||||
HAS_COMPAT=32
|
||||
.if empty(TARGET_CPUTYPE)
|
||||
LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
|
||||
.else
|
||||
LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
|
||||
.endif
|
||||
.if ${WANT_COMPILER_TYPE} == gcc || \
|
||||
.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
|
||||
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
|
||||
.else
|
||||
LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.0
|
||||
@ -27,6 +25,7 @@ LIB32WMAKEFLAGS= \
|
||||
LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32"
|
||||
|
||||
.elif ${TARGET_ARCH} == "powerpc64"
|
||||
HAS_COMPAT=32
|
||||
.if empty(TARGET_CPUTYPE)
|
||||
LIB32CPUFLAGS= -mcpu=powerpc
|
||||
.else
|
||||
@ -38,6 +37,7 @@ LIB32WMAKEFLAGS= \
|
||||
LD="${XLD} -m elf32ppc_fbsd"
|
||||
|
||||
.elif ${TARGET_ARCH:Mmips64*} != ""
|
||||
HAS_COMPAT=32
|
||||
.if ${WANT_COMPILER_TYPE} == gcc || \
|
||||
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
|
||||
.if empty(TARGET_CPUTYPE)
|
||||
@ -71,12 +71,36 @@ LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
|
||||
# -------------------------------------------------------------------
|
||||
# soft-fp world
|
||||
.if ${TARGET_ARCH:Marmv[67]*} != ""
|
||||
HAS_COMPAT=SOFT
|
||||
LIBSOFTCFLAGS= -DCOMPAT_SOFTFP
|
||||
LIBSOFTCPUFLAGS= -mfloat-abi=softfp
|
||||
LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH}
|
||||
LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP
|
||||
.endif
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# In the program linking case, select LIBCOMPAT
|
||||
.if defined(NEED_COMPAT)
|
||||
.ifndef HAS_COMPAT
|
||||
.error NEED_COMPAT defined, but no LIBCOMPAT is available
|
||||
.elif !${HAS_COMPAT:M${NEED_COMPAT}} && ${NEED_COMPAT} != "any"
|
||||
.error NEED_COMPAT (${NEED_COMPAT}) defined, but not in HAS_COMPAT ($HAS_COMPAT)
|
||||
.elif ${NEED_COMPAT} == "any"
|
||||
.endif
|
||||
.ifdef WANT_COMPAT
|
||||
.error Both WANT_COMPAT and NEED_COMPAT defined
|
||||
.endif
|
||||
WANT_COMPAT:= ${NEED_COMPAT}
|
||||
.endif
|
||||
|
||||
.if defined(HAS_COMPAT) && defined(WANT_COMPAT)
|
||||
.if ${WANT_COMPAT} == "any"
|
||||
_LIBCOMPAT:= ${HAS_COMPAT:[1]}
|
||||
.else
|
||||
_LIBCOMPAT:= ${WANT_COMPAT}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Generic code for each type.
|
||||
@ -103,4 +127,10 @@ LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
|
||||
# Clang/GCC.
|
||||
LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat}
|
||||
|
||||
.if defined(WANT_COMPAT)
|
||||
LIBDIR_BASE:= /usr/lib${libcompat}
|
||||
_LIB_OBJTOP= ${LIBCOMPAT_OBJTOP}
|
||||
CFLAGS+= ${LIBCOMPATCFLAGS}
|
||||
.endif
|
||||
|
||||
.endif
|
||||
|
@ -2,6 +2,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.include <bsd.init.mk>
|
||||
.include <bsd.compat.mk>
|
||||
.include <bsd.compiler.mk>
|
||||
.include <bsd.linker.mk>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user