From owner-svn-src-all@freebsd.org Thu Nov 7 17:10:36 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FD991BA0F3; Thu, 7 Nov 2019 17:10:36 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4788zw0YsHz3y1V; Thu, 7 Nov 2019 17:10:36 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EACA718F35; Thu, 7 Nov 2019 17:10:35 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA7HAZXO023840; Thu, 7 Nov 2019 17:10:35 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA7HAYrU023832; Thu, 7 Nov 2019 17:10:34 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201911071710.xA7HAYrU023832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 7 Nov 2019 17:10:34 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head: . libexec libexec/rtld-elf libexec/rtld-elf32 share/mk usr.bin usr.bin/ldd32 X-SVN-Commit-Revision: 354449 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Nov 2019 17:10:36 -0000 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 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 ${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 + +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 + +PROG= ldd32 +MAN= + +.PATH: ${SRCTOP}/usr.bin/ldd +.include "${SRCTOP}/usr.bin/ldd/Makefile"