svn commit: r353597 - head/share/mk
Brooks Davis
brooks at FreeBSD.org
Tue Oct 15 21:27:08 UTC 2019
Author: brooks
Date: Tue Oct 15 21:27:06 2019
New Revision: 353597
URL: https://svnweb.freebsd.org/changeset/base/353597
Log:
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
Modified:
head/share/mk/bsd.README
head/share/mk/bsd.compat.mk
head/share/mk/bsd.prog.mk
Modified: head/share/mk/bsd.README
==============================================================================
--- head/share/mk/bsd.README Tue Oct 15 21:24:25 2019 (r353596)
+++ head/share/mk/bsd.README Tue Oct 15 21:27:06 2019 (r353597)
@@ -17,6 +17,7 @@ files. In most cases it is only interesting to includ
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.
@@ -439,6 +444,9 @@ STRIP The flag passed to the install program to cause
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>.
Modified: head/share/mk/bsd.compat.mk
==============================================================================
--- head/share/mk/bsd.compat.mk Tue Oct 15 21:24:25 2019 (r353596)
+++ head/share/mk/bsd.compat.mk Tue Oct 15 21:27:06 2019 (r353597)
@@ -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,13 +71,37 @@ 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.
# Set defaults based on type.
@@ -102,5 +126,11 @@ LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
# 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
Modified: head/share/mk/bsd.prog.mk
==============================================================================
--- head/share/mk/bsd.prog.mk Tue Oct 15 21:24:25 2019 (r353596)
+++ head/share/mk/bsd.prog.mk Tue Oct 15 21:27:06 2019 (r353597)
@@ -2,6 +2,7 @@
# $FreeBSD$
.include <bsd.init.mk>
+.include <bsd.compat.mk>
.include <bsd.compiler.mk>
.include <bsd.linker.mk>
More information about the svn-src-all
mailing list