libcompat: build 32-bit rtld and ldd as part of "everything"
Alter bsd.compat.mk to set MACHINE and MACHINE_ARCH when included directly so MD paths in Makefiles work. In the process centralize setting them in LIBCOMPATWMAKEENV. Alter .PATH and CFLAGS settings in work when the Makefile is included. While here only support LIB32 on supported platforms rather than always enabling it and requiring users of MK_LIB32 to filter based TARGET/MACHINE_ARCH. The net effect of this change is to make Makefile.libcompat only build compatability libraries. Changes relative to r354449: Correct detection of the compiler type when bsd.compat.mk is used outside Makefile.libcompat. Previously it always matched the clang case. Set LDFLAGS including the linker emulation for mips where -m32 seems to be insufficent. Reviewed by: imp, kib (origional version in r354449) Obtained from: CheriBSD (conceptually) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22251
This commit is contained in:
parent
92dda61f13
commit
26f578ac5b
@ -802,11 +802,10 @@ XCFLAGS+= --sysroot=${WORLDTMP}
|
||||
XCFLAGS+= ${BFLAGS}
|
||||
.endif
|
||||
|
||||
.if ${MK_LIB32} != "no" && (${TARGET_ARCH} == "amd64" || \
|
||||
${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH:Mmips64*} != "")
|
||||
.if ${MK_LIB32} == "yes"
|
||||
_LIBCOMPAT= 32
|
||||
.include "Makefile.libcompat"
|
||||
.elif ${MK_LIBSOFT} != "no" && ${TARGET_ARCH:Marmv[67]*} != ""
|
||||
.elif ${MK_LIBSOFT} == "yes"
|
||||
_LIBCOMPAT= SOFT
|
||||
.include "Makefile.libcompat"
|
||||
.endif
|
||||
|
@ -111,28 +111,10 @@ build${libcompat}: .PHONY
|
||||
.endfor
|
||||
${_+_}cd ${.CURDIR}; \
|
||||
${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
|
||||
.if ${libcompat} == "32"
|
||||
.for _t in ${_obj} all
|
||||
.if !defined(NO_RTLD)
|
||||
${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \
|
||||
-DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
|
||||
.endif
|
||||
${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \
|
||||
DIRPRFX=usr.bin/ldd ${_t}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
distribute${libcompat} install${libcompat}: .PHONY
|
||||
.for _dir in ${_LC_LIBDIRS.yes}
|
||||
${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
|
||||
.endfor
|
||||
.if ${libcompat} == "32"
|
||||
.if !defined(NO_RTLD)
|
||||
${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
|
||||
PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//}
|
||||
.endif
|
||||
${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \
|
||||
${.TARGET:S/32$//}
|
||||
.endif
|
||||
|
||||
.endif
|
||||
.endif # !targets(__<${_this:T}>__)
|
||||
|
@ -28,8 +28,8 @@ S1lo = -9.2563760475949941e-18; /* -0x15580000000000.0p-109 */
|
||||
#define C1 ((long double)C1hi + C1lo)
|
||||
#else
|
||||
static const long double
|
||||
C1 = 0.0416666666666666666136L, /* 0xaaaaaaaaaaaaaa9b.0p-68 */
|
||||
S1 = -0.166666666666666666671L; /* -0xaaaaaaaaaaaaaaab.0p-66 */
|
||||
C1 = 0.0416666666666666666136L; /* 0xaaaaaaaaaaaaaa9b.0p-68 */
|
||||
S1 = -0.166666666666666666671L, /* -0xaaaaaaaaaaaaaaab.0p-66 */
|
||||
#endif
|
||||
|
||||
static const double
|
||||
|
@ -74,6 +74,7 @@ _tftp-proxy= tftp-proxy
|
||||
|
||||
.if !defined(NO_PIC) && !defined(NO_RTLD)
|
||||
_rtld-elf= rtld-elf
|
||||
SUBDIR.${MK_LIB32}+= rtld-elf32
|
||||
.endif
|
||||
|
||||
.if ${MK_RBOOTD} != "no"
|
||||
|
@ -4,6 +4,8 @@
|
||||
# linker:
|
||||
# make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all
|
||||
|
||||
RTLD_ELF_DIR:= ${.PARSEDIR}
|
||||
|
||||
.include <src.opts.mk>
|
||||
PACKAGE= clibs
|
||||
MK_PIE= no # Always position independent using local rules
|
||||
@ -25,16 +27,16 @@ SRCS= \
|
||||
xmalloc.c \
|
||||
debug.c \
|
||||
libmap.c
|
||||
MAN= rtld.1
|
||||
MAN?= rtld.1
|
||||
CSTD?= gnu99
|
||||
CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
|
||||
CFLAGS+= -I${SRCTOP}/lib/csu/common
|
||||
.if exists(${.CURDIR}/${MACHINE_ARCH})
|
||||
.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH})
|
||||
RTLD_ARCH= ${MACHINE_ARCH}
|
||||
.else
|
||||
RTLD_ARCH= ${MACHINE_CPUARCH}
|
||||
.endif
|
||||
CFLAGS+= -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
|
||||
CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR}
|
||||
.if ${MACHINE_ARCH} == "powerpc64"
|
||||
LDFLAGS+= -nostdlib -e _rtld_start
|
||||
.else
|
||||
@ -81,16 +83,16 @@ LIBADD+= compiler_rt
|
||||
|
||||
.if ${MK_SYMVER} == "yes"
|
||||
VERSION_DEF= ${LIBCSRCDIR}/Versions.def
|
||||
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
|
||||
SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map
|
||||
VERSION_MAP= Version.map
|
||||
LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
|
||||
|
||||
.if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
|
||||
SYMBOL_MAPS+= ${.CURDIR}/${RTLD_ARCH}/Symbol.map
|
||||
.if exists(${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map)
|
||||
SYMBOL_MAPS+= ${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
|
||||
.sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc"
|
||||
|
||||
# Since moving rtld-elf to /libexec, we need to create a symlink.
|
||||
# Fixup the existing binary that's there so we can symlink over it.
|
||||
@ -99,10 +101,12 @@ beforeinstall:
|
||||
-chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
|
||||
.endif
|
||||
|
||||
.PATH: ${.CURDIR}/${RTLD_ARCH}
|
||||
.PATH: ${RTLD_ELF_DIR}/${RTLD_ARCH}
|
||||
|
||||
.if ${.CURDIR} == ${RTLD_ELF_DIR}
|
||||
HAS_TESTS=
|
||||
SUBDIR.${MK_TESTS}+= tests
|
||||
.endif
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
${PROG_FULL}: ${VERSION_MAP}
|
||||
|
10
libexec/rtld-elf32/Makefile
Normal file
10
libexec/rtld-elf32/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NEED_COMPAT= 32
|
||||
.include <bsd.compat.mk>
|
||||
|
||||
PROG= ld-elf32.so.1
|
||||
MAN=
|
||||
|
||||
.PATH: ${SRCTOP}/libexec/rtld-elf
|
||||
.include "${SRCTOP}/libexec/rtld-elf/Makefile"
|
@ -6,9 +6,17 @@ __<${_this:T}>__:
|
||||
.if defined(_LIBCOMPAT)
|
||||
COMPAT_ARCH= ${TARGET_ARCH}
|
||||
COMPAT_CPUTYPE= ${TARGET_CPUTYPE}
|
||||
.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
|
||||
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
|
||||
COMPAT_COMPILER_TYPE= gcc
|
||||
.else
|
||||
COMPAT_COMPILER_TYPE= clang
|
||||
.endif
|
||||
.else
|
||||
COMPAT_ARCH= ${MACHINE_ARCH}
|
||||
COMPAT_CPUTYPE= ${CPUTYPE}
|
||||
.include <bsd.compiler.mk>
|
||||
COMPAT_COMPILER_TYPE=${COMPILER_TYPE}
|
||||
.endif
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
@ -20,14 +28,14 @@ LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
|
||||
.else
|
||||
LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
|
||||
.endif
|
||||
.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
|
||||
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
|
||||
.if ${COMPAT_COMPILER_TYPE} == gcc
|
||||
.else
|
||||
LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.0
|
||||
.endif
|
||||
LIB32CPUFLAGS+= -m32
|
||||
LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
|
||||
MACHINE_CPU="i686 mmx sse sse2"
|
||||
LIB32_MACHINE= i386
|
||||
LIB32_MACHINE_ARCH= i386
|
||||
LIB32WMAKEENV= MACHINE_CPU="i686 mmx sse sse2"
|
||||
LIB32WMAKEFLAGS= \
|
||||
AS="${XAS} --32" \
|
||||
LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32"
|
||||
@ -40,14 +48,14 @@ LIB32CPUFLAGS= -mcpu=powerpc
|
||||
LIB32CPUFLAGS= -mcpu=${COMPAT_CPUTYPE}
|
||||
.endif
|
||||
LIB32CPUFLAGS+= -m32
|
||||
LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
|
||||
LIB32_MACHINE= powerpc
|
||||
LIB32_MACHINE_ARCH= powerpc
|
||||
LIB32WMAKEFLAGS= \
|
||||
LD="${XLD} -m elf32ppc_fbsd"
|
||||
|
||||
.elif ${COMPAT_ARCH:Mmips64*} != ""
|
||||
HAS_COMPAT=32
|
||||
.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
|
||||
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
|
||||
.if ${COMPAT_COMPILER_TYPE} == gcc
|
||||
.if empty(COMPAT_CPUTYPE)
|
||||
LIB32CPUFLAGS= -march=mips3
|
||||
.else
|
||||
@ -61,12 +69,15 @@ LIB32CPUFLAGS= -target mips-unknown-freebsd13.0
|
||||
.endif
|
||||
.endif
|
||||
LIB32CPUFLAGS+= -mabi=32
|
||||
LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips
|
||||
LIB32_MACHINE= mips
|
||||
LIB32_MACHINE_ARCH= mips
|
||||
.if ${COMPAT_ARCH:Mmips64el*} != ""
|
||||
LIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd"
|
||||
_EMULATION= elf32ltsmip_fbsd
|
||||
.else
|
||||
LIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd"
|
||||
_EMULATION= elf32btsmip_fbsd
|
||||
.endif
|
||||
LIB32WMAKEFLAGS= LD="${XLD} -m ${_EMULATION}"
|
||||
LIB32LDFLAGS= -Wl,-m${_EMULATION}
|
||||
.endif
|
||||
|
||||
LIB32WMAKEFLAGS+= NM="${XNM}"
|
||||
@ -82,7 +93,9 @@ LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
|
||||
HAS_COMPAT=SOFT
|
||||
LIBSOFTCFLAGS= -DCOMPAT_SOFTFP
|
||||
LIBSOFTCPUFLAGS= -mfloat-abi=softfp
|
||||
LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${COMPAT_ARCH}
|
||||
LIBSOFT_MACHINE= arm
|
||||
LIBSOFT_MACHINE_ARCH= ${COMPAT_ARCH}
|
||||
LIBSOFTWMAKEENV= CPUTYPE=soft
|
||||
LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP
|
||||
.endif
|
||||
|
||||
@ -114,8 +127,8 @@ _LIBCOMPAT:= ${WANT_COMPAT}
|
||||
# Generic code for each type.
|
||||
# Set defaults based on type.
|
||||
libcompat= ${_LIBCOMPAT:tl}
|
||||
_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \
|
||||
WMAKEFLAGS WMAKE
|
||||
_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS LDFLAGS \
|
||||
_MACHINE _MACHINE_ARCH WMAKEENV WMAKEFLAGS WMAKE
|
||||
.for _var in ${_LIBCOMPAT_MAKEVARS}
|
||||
.if !empty(LIB${_LIBCOMPAT}${_var})
|
||||
LIBCOMPAT${_var}?= ${LIB${_LIBCOMPAT}${_var}}
|
||||
@ -131,6 +144,9 @@ LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
|
||||
--sysroot=${LIBCOMPATTMP} \
|
||||
${BFLAGS}
|
||||
|
||||
LIBCOMPATWMAKEENV+= MACHINE=${LIBCOMPAT_MACHINE}
|
||||
LIBCOMPATWMAKEENV+= MACHINE_ARCH=${LIBCOMPAT_MACHINE_ARCH}
|
||||
|
||||
# -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}
|
||||
@ -139,6 +155,9 @@ LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat}
|
||||
LIBDIR_BASE:= /usr/lib${libcompat}
|
||||
_LIB_OBJTOP= ${LIBCOMPAT_OBJTOP}
|
||||
CFLAGS+= ${LIBCOMPATCFLAGS}
|
||||
LDFLAGS+= ${CFLAGS} ${LIBCOMPATLDFLAGS}
|
||||
MACHINE= ${LIBCOMPAT_MACHINE}
|
||||
MACHINE_ARCH= ${LIBCOMPAT_MACHINE_ARCH}
|
||||
.endif
|
||||
|
||||
.endif
|
||||
|
@ -126,7 +126,6 @@ __DEFAULT_YES_OPTIONS = \
|
||||
LDNS \
|
||||
LDNS_UTILS \
|
||||
LEGACY_CONSOLE \
|
||||
LIB32 \
|
||||
LIBPTHREAD \
|
||||
LIBTHR \
|
||||
LLVM_COV \
|
||||
@ -358,6 +357,13 @@ __DEFAULT_NO_OPTIONS+=GDB_LIBEXEC
|
||||
.else
|
||||
__DEFAULT_YES_OPTIONS+=GDB_LIBEXEC
|
||||
.endif
|
||||
# LIB32 is supported on amd64, mips64, and powerpc64
|
||||
.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH:Mmips64*} || \
|
||||
${MACHINE_ARCH} == "powerpc64")
|
||||
__DEFAULT_YES_OPTIONS+=LIB32
|
||||
.else
|
||||
BROKEN_OPTIONS+=LIB32
|
||||
.endif
|
||||
# Only doing soft float API stuff on armv6 and armv7
|
||||
.if ${__T} != "armv6" && ${__T} != "armv7"
|
||||
BROKEN_OPTIONS+=LIBSOFT
|
||||
|
@ -226,6 +226,7 @@ SUBDIR.${MK_KDUMP}+= truss
|
||||
SUBDIR.${MK_KERBEROS_SUPPORT}+= compile_et
|
||||
SUBDIR.${MK_LDNS_UTILS}+= drill
|
||||
SUBDIR.${MK_LDNS_UTILS}+= host
|
||||
SUBDIR.${MK_LIB32}+= ldd32
|
||||
SUBDIR.${MK_LOCATE}+= locate
|
||||
# XXX msgs?
|
||||
SUBDIR.${MK_MAIL}+= biff
|
||||
|
10
usr.bin/ldd32/Makefile
Normal file
10
usr.bin/ldd32/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
NEED_COMPAT= 32
|
||||
.include <bsd.compat.mk>
|
||||
|
||||
PROG= ldd32
|
||||
MAN=
|
||||
|
||||
.PATH: ${SRCTOP}/usr.bin/ldd
|
||||
.include "${SRCTOP}/usr.bin/ldd/Makefile"
|
Loading…
Reference in New Issue
Block a user