Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Nov 2019 17:10:34 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354449 - in head: . libexec libexec/rtld-elf libexec/rtld-elf32 share/mk usr.bin usr.bin/ldd32
Message-ID:  <201911071710.xA7HAYrU023832@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Thu Nov  7 17:10:33 2019
New Revision: 354449
URL: https://svnweb.freebsd.org/changeset/base/354449

Log:
  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.
  
  Reviewed by:	imp, kib
  Obtained from:	CheriBSD (conceptually)
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D22251

Added:
  head/libexec/rtld-elf32/
  head/libexec/rtld-elf32/Makefile   (contents, props changed)
  head/usr.bin/ldd32/
  head/usr.bin/ldd32/Makefile   (contents, props changed)
Modified:
  head/Makefile.inc1
  head/Makefile.libcompat
  head/libexec/Makefile
  head/libexec/rtld-elf/Makefile
  head/share/mk/bsd.compat.mk
  head/share/mk/src.opts.mk
  head/usr.bin/Makefile

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1	Thu Nov  7 17:00:20 2019	(r354448)
+++ head/Makefile.inc1	Thu Nov  7 17:10:33 2019	(r354449)
@@ -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

Modified: head/Makefile.libcompat
==============================================================================
--- head/Makefile.libcompat	Thu Nov  7 17:00:20 2019	(r354448)
+++ head/Makefile.libcompat	Thu Nov  7 17:10:33 2019	(r354449)
@@ -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}>__)

Modified: head/libexec/Makefile
==============================================================================
--- head/libexec/Makefile	Thu Nov  7 17:00:20 2019	(r354448)
+++ head/libexec/Makefile	Thu Nov  7 17:10:33 2019	(r354449)
@@ -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"

Modified: head/libexec/rtld-elf/Makefile
==============================================================================
--- head/libexec/rtld-elf/Makefile	Thu Nov  7 17:00:20 2019	(r354448)
+++ head/libexec/rtld-elf/Makefile	Thu Nov  7 17:10:33 2019	(r354449)
@@ -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}

Added: head/libexec/rtld-elf32/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/libexec/rtld-elf32/Makefile	Thu Nov  7 17:10:33 2019	(r354449)
@@ -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"

Modified: head/share/mk/bsd.compat.mk
==============================================================================
--- head/share/mk/bsd.compat.mk	Thu Nov  7 17:00:20 2019	(r354448)
+++ head/share/mk/bsd.compat.mk	Thu Nov  7 17:10:33 2019	(r354449)
@@ -26,8 +26,9 @@ LIB32CPUFLAGS=	-march=${COMPAT_CPUTYPE}
 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,7 +41,8 @@ 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"
 
@@ -61,7 +63,8 @@ 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"
 .else
@@ -82,7 +85,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 +119,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 \
+			_MACHINE _MACHINE_ARCH WMAKEENV WMAKEFLAGS WMAKE
 .for _var in ${_LIBCOMPAT_MAKEVARS}
 .if !empty(LIB${_LIBCOMPAT}${_var})
 LIBCOMPAT${_var}?=	${LIB${_LIBCOMPAT}${_var}}
@@ -131,6 +136,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 +147,8 @@ LIBCOMPATCFLAGS+=	-B${LIBCOMPATTMP}/usr/lib${libcompat
 LIBDIR_BASE:=	/usr/lib${libcompat}
 _LIB_OBJTOP=	${LIBCOMPAT_OBJTOP}
 CFLAGS+=	${LIBCOMPATCFLAGS}
+MACHINE=	${LIBCOMPAT_MACHINE}
+MACHINE_ARCH=	${LIBCOMPAT_MACHINE_ARCH}
 .endif
 
 .endif

Modified: head/share/mk/src.opts.mk
==============================================================================
--- head/share/mk/src.opts.mk	Thu Nov  7 17:00:20 2019	(r354448)
+++ head/share/mk/src.opts.mk	Thu Nov  7 17:10:33 2019	(r354449)
@@ -126,7 +126,6 @@ __DEFAULT_YES_OPTIONS = \
     LDNS \
     LDNS_UTILS \
     LEGACY_CONSOLE \
-    LIB32 \
     LIBPTHREAD \
     LIBTHR \
     LLVM_COV \
@@ -357,6 +356,13 @@ BROKEN_OPTIONS+=LLDB
 __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"

Modified: head/usr.bin/Makefile
==============================================================================
--- head/usr.bin/Makefile	Thu Nov  7 17:00:20 2019	(r354448)
+++ head/usr.bin/Makefile	Thu Nov  7 17:10:33 2019	(r354449)
@@ -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

Added: head/usr.bin/ldd32/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/usr.bin/ldd32/Makefile	Thu Nov  7 17:10:33 2019	(r354449)
@@ -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"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911071710.xA7HAYrU023832>