From nobody Sat Apr 22 19:03:04 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q3glF1t5Qz468YQ; Sat, 22 Apr 2023 19:03:05 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q3glF1LwTz3QrV; Sat, 22 Apr 2023 19:03:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682190185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cn+nCMHIES9yj4G7S2pYH2fcNTBdtz4ui6uPj5i4iv4=; b=uSJTE7+1LndPSAqAEEyeelvsro1SdZiLxMGuSLR8/HW895vs2WhslR22NFsOVEtHJeVpgG /5gB3y/TbQw1dYg+Z07FJ2bPhcwgkltZTzoz1bjNONPTUtiEqmEhB7c/sAP0IYeCPbDtwX uZdwRZOkL1w1pBB7wLcmdnf5/FPXRdDNhWDpL2s0EWbGfYW56o37SroSaHwpuOuP/wK+8U wciyOeCpkv3/Zge2N5ku2VOenmuVhoXo/BYeocjZxUKR2wH5UG9S9/gcSjEJrDeldKeNw/ ECgqwf+fk1BS82IVLFdaYI9gLR3t1NMCehdzYpCfa7NjnLZ6G53G+oWh0816Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682190185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cn+nCMHIES9yj4G7S2pYH2fcNTBdtz4ui6uPj5i4iv4=; b=Pwts4/q684tkxtSe4zBM2JJxKwJ263Wx1EFhPzD1s2oyB7rj5RsSgwgF21FjILexsNKlSb b2jc8Px7hitKZI26uiOa4EaYmqED4HXw5biTCtskxq7La6KKo+4HDhNZVlLEHkm+tuBZEm SMzGOlZLHdYwC4YOUPvguZiKwZXuRBqq5eRla9raLN7ZCrh1IDVurS7SqrWZ2kqFqUuSlf p8JeNTV5Bd09liYibmSRtu/N099JlM/40S+MAi35gUEaWFtZqGLRTQKMzz075dmG/2dgRl WMpY5ciPFc2iNAqTi/21gS9FXtznTMAAD5Xt/lq2AwZ2G5edtI4Y2Kw1KV/9SA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682190185; a=rsa-sha256; cv=none; b=ON8l3GrSIYBFsNgW8oN9FXpBjYETqnuSCt13G5rdS6omqpqe0iwQDP+9MpW2sthWYuBwWw aRCigVdfFDA+oaWlI/RGB8GFE+bI/yypnG3/qhRMt9dqfd1b4zXF44Yt4x5hRr9e/RCUag RsnAS7/DpNLHLLtkvC+GmGWhMJKz7AvsZ5gAWq3BndQXItKMC0KE0uWTAwqmk2lTCKOpiR E1xIDvsqRova25BTibFSLeQCPN/2M0edk9iOxzupYJbEHH7C4aThwzlGBTiEVnnYIt+rz1 lp6083kfWECG6KeV2fYSQmzQ8BjQkDlfpFNiKv9UdnzF+NgNOfYuux7c1YM/zw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q3glF0PMdz1CbH; Sat, 22 Apr 2023 19:03:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33MJ34Pe068166; Sat, 22 Apr 2023 19:03:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33MJ34Tj068165; Sat, 22 Apr 2023 19:03:04 GMT (envelope-from git) Date: Sat, 22 Apr 2023 19:03:04 GMT Message-Id: <202304221903.33MJ34Tj068165@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Simon J. Gerraty" Subject: git: 8561d0b2ec50 - main - Simplify building host tools during DIRDEPS_BUILD List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8561d0b2ec50eb127b58dee30bf49ef519947457 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8561d0b2ec50eb127b58dee30bf49ef519947457 commit 8561d0b2ec50eb127b58dee30bf49ef519947457 Author: Simon J. Gerraty AuthorDate: 2023-04-22 19:01:49 +0000 Commit: Simon J. Gerraty CommitDate: 2023-04-22 19:01:49 +0000 Simplify building host tools during DIRDEPS_BUILD The whole point of the DIRDEPS_BUILD is to avoid tree walks and basically build everything in a single pass. We use the pseudo MACHINE "host" to represent the build host. When the build host is not FreeBSD or is an older version of FreeBSD it may need some help to build host-tools. The directory tools/build does this - building libegacy. local.sys.mk: create a pseudo option MK_host_egacy to indicate if tools/build needs to be built for "host". local.dirdeps.mk: set MK_host_egacy.host to ${MK_host_egacy} all other DEP_MACHINES will get "no" This allows a Makefile.depend.options in makefs etc to cause tools/build to be built for host but only if necessary. local.init.mk: use ISYSTEM as arg to -isystem so that it can be overridden. The default remains ${STAGE_INCLUDEDIR} src.init.mk: if MACHINE is host and we are not FreeBSD set some MK_ flags the same as tools/build/mk/Makefile.boot.pre and include src.init.${.MAKE.OS:tl}.mk if it exists. For older versions of FreeBSD add libegacy when building PROGs for "host" Also instead of -isystem${STAGE_INCLUDEDIR} we want -I${STAGE_INCLUDEDIR} and -isystem/usr/include so we override ISYSTEM. This means any headers we stage for "host" will take precedence over system headers but #include_next will DTRT. src.init.linux.mk: add -I${SRCTOP}/tools/build/cross-build/include/linux and generally deal with building host tools on Linux. Eg. static linking does not work so set NO_SHARED= no Override some HAVE_ flags. src.sys.env.mk: on linux awk throws an warning about # in newvers.sh just send stderr to /dev/null Reviewed by: jrtc27, arichardson Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D39744 --- share/mk/local.dirdeps.mk | 11 ++++++++++- share/mk/local.init.mk | 5 ++++- share/mk/local.sys.mk | 8 ++++++++ share/mk/src.init.linux.mk | 15 +++++++++++++++ share/mk/src.init.mk | 31 +++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/share/mk/local.dirdeps.mk b/share/mk/local.dirdeps.mk index 246c9cdef114..d0ae1c0171cb 100644 --- a/share/mk/local.dirdeps.mk +++ b/share/mk/local.dirdeps.mk @@ -60,7 +60,15 @@ cleanup_worldtmp: .PHONY .NOMETA rm -rf ${OBJTOP}/tmp beforedirdeps: cleanup_worldtmp .endif -.endif + +# pseudo option for building host tools on old or non-FreeBSD host +# allows us to leverage Makefile.depend.options with +# DIRDEPS_OPTIONS = host_egacy +# dirdeps-options.mk will qualify with ${DEP_MACHINE} (and others) +# before looking at the bare option. +MK_host_egacy.host= ${MK_host_egacy} + +.endif # !target(_DIRDEP_USE) # reset this each time DIRDEPS_FILTER.xtras= @@ -69,6 +77,7 @@ DIRDEPS_FILTER.xtras+= Nusr.bin/clang/clang.host .endif .if ${DEP_MACHINE} != "host" +MK_host_egacy.${DEP_MACHINE}= no # this is how we can handle optional dependencies .if ${DEP_RELDIR} == "lib/libc" diff --git a/share/mk/local.init.mk b/share/mk/local.init.mk index c8072004697f..1d165c339ff0 100644 --- a/share/mk/local.init.mk +++ b/share/mk/local.init.mk @@ -19,7 +19,10 @@ CFLAGS_LAST+= --sysroot=${SYSROOT} CXXFLAGS_LAST+= --sysroot=${SYSROOT} LDADD+= --sysroot=${SYSROOT} .elif ${MK_STAGING} == "yes" -CFLAGS+= -isystem ${STAGE_INCLUDEDIR} +ISYSTEM?= ${STAGE_INCLUDEDIR} +# no space after -isystem makes it easier to +# grep the flag out of command lines (in meta files) to see its value. +CFLAGS+= -isystem${ISYSTEM} # XXX: May be needed for GCC to build with libc++ rather than libstdc++. See Makefile.inc1 #CXXFLAGS+= -std=gnu++11 #LDADD+= -L${STAGE_LIBDIR}/libc++ diff --git a/share/mk/local.sys.mk b/share/mk/local.sys.mk index 1817f6393949..1aac5014b737 100644 --- a/share/mk/local.sys.mk +++ b/share/mk/local.sys.mk @@ -79,6 +79,14 @@ JOB_MAX:= ${jm:R} .endif .endif +.if ${MK_DIRDEPS_BUILD} == "yes" +.if ${.MAKE.OS} != "FreeBSD" || ${_HOST_OSREL:R} < ${OS_REVISION:R} +# a pseudo option to indicate we need libegacy for host +MK_host_egacy= yes +.endif +.endif +MK_host_egacy?= no + .if ${.MAKE.MODE:Mmeta*} != "" # we can afford to use cookies to prevent some targets # re-running needlessly but only when using filemon. diff --git a/share/mk/src.init.linux.mk b/share/mk/src.init.linux.mk new file mode 100644 index 000000000000..1e351e1b41f6 --- /dev/null +++ b/share/mk/src.init.linux.mk @@ -0,0 +1,15 @@ +# We want to build some host tools (eg makefs, mkimg) for Linux +# This only gets included during DIRDEPS_BUILD when MACHINE is "host" + +CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux + +WARNS= 0 + +.ifdef PROG +LOCAL_LIBRARIES+= bsd egacy +LIBADD+= egacy m +.endif + +# Bring in the full GNU namespace +CFLAGS+= -D_GNU_SOURCE + diff --git a/share/mk/src.init.mk b/share/mk/src.init.mk index 2067dcdbbabc..148dc7a3e960 100644 --- a/share/mk/src.init.mk +++ b/share/mk/src.init.mk @@ -8,4 +8,35 @@ buildenv: .PHONY ${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} buildenv .endif +.if ${MACHINE:Nhost*} == "" +.if ${.MAKE.OS} != "FreeBSD" +# these won't work anyway - see tools/build/mk/Makefile.boot.pre +MK_DEBUG_FILES= no +MK_MAN= no +MK_PIE= no +MK_RETPOLINE= no +NO_SHARED= no +MK_TESTS= no + +.-include + +CFLAGS+= \ + -DHAVE_NBTOOL_CONFIG_H=1 \ + -I${SRCTOP}/tools/build/cross-build/include/common \ + +.endif + +.if ${MK_host_egacy} == "yes" +.ifdef PROG +LOCAL_LIBRARIES+= egacy +LIBADD+= egacy +.endif +.endif + +.if ${MK_STAGING} == "yes" +ISYSTEM= /usr/include +CFLAGS+= -I${STAGE_INCLUDEDIR} +.endif +.endif + .endif # !target(____)