aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2019-11-07 22:58:10 +0000
committerBrooks Davis <brooks@FreeBSD.org>2019-11-07 22:58:10 +0000
commita4330302f22d45d4158204b2d5d7c6738100f3a5 (patch)
tree9cb152bfad3e48051a626a02a237af9104e6929c
parent273b2e4c55f5de86ed5d2fea0a00677f944cbd9d (diff)
downloadsrc-a4330302f22d45d4158204b2d5d7c6738100f3a5.tar.gz
src-a4330302f22d45d4158204b2d5d7c6738100f3a5.zip
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
Notes
Notes: svn path=/head/; revision=354491
-rw-r--r--Makefile.inc15
-rw-r--r--Makefile.libcompat20
-rw-r--r--lib/msun/src/k_sincosl.h4
-rw-r--r--libexec/Makefile1
-rw-r--r--libexec/rtld-elf/Makefile20
-rw-r--r--libexec/rtld-elf32/Makefile10
-rw-r--r--share/mk/bsd.compat.mk45
-rw-r--r--share/mk/src.opts.mk8
-rw-r--r--usr.bin/Makefile1
-rw-r--r--usr.bin/ldd32/Makefile10
10 files changed, 78 insertions, 46 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index 9f75dba90bb2..6a858c0f1bc2 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -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
diff --git a/Makefile.libcompat b/Makefile.libcompat
index 6481ba73ddd1..21e5fb4296a6 100644
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -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}>__)
diff --git a/lib/msun/src/k_sincosl.h b/lib/msun/src/k_sincosl.h
index 4d4dc69f7820..3a609bc90bf1 100644
--- a/lib/msun/src/k_sincosl.h
+++ b/lib/msun/src/k_sincosl.h
@@ -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
diff --git a/libexec/Makefile b/libexec/Makefile
index 89688daafb59..4ac65066619d 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -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"
diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index 0bbfbb89301e..67ec1eb35cb0 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -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}
diff --git a/libexec/rtld-elf32/Makefile b/libexec/rtld-elf32/Makefile
new file mode 100644
index 000000000000..5b4c2e9c4007
--- /dev/null
+++ b/libexec/rtld-elf32/Makefile
@@ -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"
diff --git a/share/mk/bsd.compat.mk b/share/mk/bsd.compat.mk
index 4d6c8aac56f1..c50cd79c306c 100644
--- a/share/mk/bsd.compat.mk
+++ b/share/mk/bsd.compat.mk
@@ -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
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 171676dd52d3..d1558df0f6c4 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -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
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index c743cc8e15bf..b41385e253e8 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -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
diff --git a/usr.bin/ldd32/Makefile b/usr.bin/ldd32/Makefile
new file mode 100644
index 000000000000..633947adeaa0
--- /dev/null
+++ b/usr.bin/ldd32/Makefile
@@ -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"