From nobody Sat Sep 23 06:28:23 2023 X-Original-To: dev-commits-src-all@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 4RszjN1prxz4v7TQ; Sat, 23 Sep 2023 06:28:24 +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 4RszjN19DPz4Hm4; Sat, 23 Sep 2023 06:28:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695450504; 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=3ItnTaFUjfRK1HkSBl9i/psjmwk5t1K6QwqHHhBfZJM=; b=peByTxCMUafvFsatd7HwBcZhaH9g4EMMAFI0yJuy75u+qp1GV5ZYWnT+AbqtmYB62DnZgR Nkq2x/sbQAHoItvcDJi/aUVQzwbHtQBNTo0D2y2U93pq/pvu15Mud/3j4fEWpta7bZAp5O 7w8Rmz9+dch1ntM9W9oKYO6e7X361slHkoov2bo9ihio/NFP1F1WBHQAPvFfoZ0kupWig8 YuE3qDneuLSh1U9xJB1AgIVpl++s9klKSq2Lahc1TlGTyBEfofkewj9bvm6TfINYjmMRDh OPvSmSVm+FRxHbd2Mdd34mvm1VIHVYTLFd/OiFBDuJHLjUqGGhKJu8A2MU2cXQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695450504; a=rsa-sha256; cv=none; b=miGthH1iYWzEXGJBtiX0Iz24EROM0mpHvaJpduul2algWQa15PrfXeSC/1utPoUt3bKaEW 2FykOi+RobZ2PBGGKCFmqbVBWckObaKxccG6hqjTtSPO0mGrNl4V4ZPN8Ru8+iw02o88p4 exSUIZErAn92ArPA5d9K9dQ7bkNjvny3yyh5n9o8orbdbLDgG4kbMrkYEojU9fpa2bQJc1 2EzxWvPU1NzfA8t54/PJirXXtJhEdimVivCqBt+kean8UVWntrJWewWYEJs9AE+7ER4GBg OxXJaPbvYX5dmWy+Q2K9ITovQ6Z4Z/ZxjUVbKieyNt0LyBHuSK0SfbA3AdzQjw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695450504; 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=3ItnTaFUjfRK1HkSBl9i/psjmwk5t1K6QwqHHhBfZJM=; b=m8TE7juA4rZVzu+Z/AUPYljDv8Awr8Cy0t/5sGJXjVMExvDaUAZensqYbOUj4NepahZ6PO Ok9W+vSKQ1UxhE/C24NKGqwDcZTKyfqQK+mDuHDxe/4YhnT0g6K6yyqhFA0q/Y8h8EPgdH TnzKNreZFBi4yps2VYRghS8K9DwaPNH+4k1WWoKgEZKCN50m5BAOU/2e+qN+pcDOwWNMyW vz2EZis+ReNvAYKG8N90IoGcP5zJhXWFH3EV+47Pp4xlxN43idYlsoYG0LwiOFrbZunbcN jQG3VJTyLDCzQqjJtKp70PVNQxL+YQamyJ2m57UkE0+DbBxc4ui69MD16eluag== 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 4RszjN0C1Dzt5B; Sat, 23 Sep 2023 06:28:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38N6SNCg008193; Sat, 23 Sep 2023 06:28:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38N6SNw8008190; Sat, 23 Sep 2023 06:28:23 GMT (envelope-from git) Date: Sat, 23 Sep 2023 06:28:23 GMT Message-Id: <202309230628.38N6SNw8008190@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: f9df60975087 - main - Add support for host32 for DIRDEPS_BUILD List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: f9df609750876be2c054dfac953316f513ccffce Auto-Submitted: auto-generated The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f9df609750876be2c054dfac953316f513ccffce commit f9df609750876be2c054dfac953316f513ccffce Author: Simon J. Gerraty AuthorDate: 2023-09-23 06:27:37 +0000 Commit: Simon J. Gerraty CommitDate: 2023-09-23 06:27:37 +0000 Add support for host32 for DIRDEPS_BUILD Allow building 32bit libs for host. Move CFLAGS additions from local.sys.dirdeps.mk (which is too early and impacts CFLAGS defaults) to local.sys.mk Reviewed by: stevek Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D41946 --- share/mk/host-target.mk | 44 ++++++++++++++++++++++++++++----------- share/mk/local.dirdeps.mk | 6 ++++++ share/mk/local.init.mk | 6 +++--- share/mk/local.sys.dirdeps.env.mk | 15 +++++++++++-- share/mk/local.sys.dirdeps.mk | 10 ++------- share/mk/local.sys.machine.mk | 3 ++- share/mk/local.sys.mk | 7 +++++++ share/mk/src.init.linux.mk | 3 +++ share/mk/src.opts.mk | 2 +- tools/build/Makefile | 2 ++ 10 files changed, 71 insertions(+), 27 deletions(-) diff --git a/share/mk/host-target.mk b/share/mk/host-target.mk index f528db9c6d24..d8abea17fdac 100644 --- a/share/mk/host-target.mk +++ b/share/mk/host-target.mk @@ -1,32 +1,40 @@ # RCSid: -# $Id: host-target.mk,v 1.11 2015/10/25 00:07:20 sjg Exp $ +# $Id: host-target.mk,v 1.19 2023/09/21 06:44:53 sjg Exp $ # Host platform information; may be overridden +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: .NOTMAIN + .if !defined(_HOST_OSNAME) -_HOST_OSNAME != uname -s +# use .MAKE.OS if available +_HOST_OSNAME := ${.MAKE.OS:U${uname -s:L:sh}} .export _HOST_OSNAME .endif .if !defined(_HOST_OSREL) _HOST_OSREL != uname -r .export _HOST_OSREL .endif -.if !defined(_HOST_MACHINE) -_HOST_MACHINE != uname -m -.export _HOST_MACHINE -.endif .if !defined(_HOST_ARCH) -# for NetBSD prefer $MACHINE (amd64 rather than x86_64) -.if ${_HOST_OSNAME:NNetBSD} == "" -_HOST_ARCH := ${_HOST_MACHINE} -.else _HOST_ARCH != uname -p 2> /dev/null || uname -m # uname -p may produce garbage on linux .if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == "" -_HOST_ARCH := ${_HOST_MACHINE} -.endif +_HOST_ARCH = ${_HOST_MACHINE} +.elif ${_HOST_OSNAME:NDarwin} == "" && ${_HOST_ARCH:Narm:Ni386} == "" +# _HOST_MACHINE is more explicit/useful +_HOST_ARCH = ${_HOST_MACHINE} .endif .export _HOST_ARCH .endif +.if !defined(_HOST_MACHINE) +_HOST_MACHINE != uname -m +# just in case +_HOST_ARCH := ${_HOST_ARCH} +# uname -m may produce garbage on darwin ppc +.if ${_HOST_MACHINE:[\#]} > 1 +_HOST_MACHINE := ${_HOST_ARCH} +.endif +.export _HOST_MACHINE +.endif .if !defined(HOST_MACHINE) HOST_MACHINE := ${_HOST_MACHINE} .export HOST_MACHINE @@ -37,8 +45,20 @@ HOST_OSTYPE := ${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARC HOST_OS := ${_HOST_OSNAME} host_os := ${_HOST_OSNAME:tl} HOST_TARGET := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH} +# sometimes we want HOST_TARGET32 +MACHINE32.amd64 = i386 +MACHINE32.x86_64 = i386 +.if !defined(_HOST_ARCH32) +_HOST_ARCH32 := ${MACHINE32.${_HOST_ARCH}:U${_HOST_ARCH:S,64$,,}} +.export _HOST_ARCH32 +.endif +HOST_TARGET32 := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH32} + +.export HOST_TARGET HOST_TARGET32 # tr is insanely non-portable, accommodate the lowest common denominator TR ?= tr toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + +.endif diff --git a/share/mk/local.dirdeps.mk b/share/mk/local.dirdeps.mk index 7b4a1fdf426d..99782b856d41 100644 --- a/share/mk/local.dirdeps.mk +++ b/share/mk/local.dirdeps.mk @@ -22,7 +22,9 @@ DIRDEPS_FILTER.host = \ Ninclude* \ Nlib/csu* \ Nlib/libc \ + Nlib/libcompiler_rt \ Nlib/[mn]* \ + Nlib/lib[t]* \ Ngnu/lib/lib[a-r]* \ Nsecure/lib* \ Nusr.bin/xinstall* \ @@ -50,6 +52,8 @@ N_host_libs:= ${cd ${SRCTOP} && echo lib/lib*:L:sh:${_need_host_libs:${M_ListToS DIRDEPS_FILTER.host+= ${N_host_libs} .endif +DIRDEPS_FILTER.host32 = ${DIRDEPS_FILTER.host} + DIRDEPS_FILTER+= \ Nbin/cat.host \ ${DIRDEPS_FILTER.xtras:U} @@ -107,6 +111,7 @@ DIRDEPS += \ cddl/usr.bin/ctfmerge.host .endif +.if ${DEP_MACHINE:Nhost*} != "" # Add in proper libgcc (gnu or LLVM) if not building libcc and libc is needed. # Add both gcc_s and gcc_eh as dependencies as the decision to build # -static or not is not known here. @@ -115,6 +120,7 @@ DIRDEPS+= \ lib/libgcc_eh \ lib/libgcc_s .endif +.endif # Bootstrap support. Give hints to DIRDEPS if there is no Makefile.depend* # generated yet. This can be based on things such as SRC files and LIBADD. diff --git a/share/mk/local.init.mk b/share/mk/local.init.mk index d9477fd22827..758a3604d73a 100644 --- a/share/mk/local.init.mk +++ b/share/mk/local.init.mk @@ -13,7 +13,7 @@ __${_this}__: # XXX: This should be combined with external compiler support in Makefile.inc1 # and local.meta.sys.mk (CROSS_TARGET_FLAGS) -.if ${MK_SYSROOT} == "yes" && !empty(SYSROOT) && ${MACHINE} != "host" +.if ${MK_SYSROOT} == "yes" && !empty(SYSROOT) && ${MACHINE:Nhost*} != "" CFLAGS_LAST+= --sysroot=${SYSROOT} CXXFLAGS_LAST+= --sysroot=${SYSROOT} LDADD+= --sysroot=${SYSROOT} @@ -29,8 +29,8 @@ CFLAGS+= -isystem${ISYSTEM} LDADD+= -L${STAGE_LIBDIR} .endif -.if ${MACHINE} == "host" -.if ${.MAKE.DEPENDFILE:E} != "host" +.if ${MACHINE:Nhost*} == "" +.if ${.MAKE.DEPENDFILE:E:Nhost*} != "" UPDATE_DEPENDFILE?= no .endif HOST_CFLAGS+= -DHOSTPROG diff --git a/share/mk/local.sys.dirdeps.env.mk b/share/mk/local.sys.dirdeps.env.mk index bbac39935ad8..fdcb25b67e31 100644 --- a/share/mk/local.sys.dirdeps.env.mk +++ b/share/mk/local.sys.dirdeps.env.mk @@ -24,17 +24,28 @@ BOOT_MACHINE_DIR.$m ?= stand/$m .endfor HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET} +HOST_OBJTOP32 ?= ${OBJROOT}${HOST_TARGET32} +.if ${.MAKE.LEVEL} == 0 .if ${REQUESTED_MACHINE:U${MACHINE}} == "host" MACHINE= host .if ${TARGET_MACHINE:Uno} == ${HOST_TARGET} # not what we want TARGET_MACHINE= host .endif +.elif ${REQUESTED_MACHINE:U${MACHINE}} == "host32" +MACHINE= host32 .endif -.if ${MACHINE} == "host" -OBJTOP := ${HOST_OBJTOP} +.endif + +.if ${MACHINE:Nhost*} == "" MACHINE_ARCH= ${MACHINE_ARCH_${MACHINE}} +.if ${MACHINE} == "host32" +.MAKE.DEPENDFILE_PREFERENCE= \ + ${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.host32 \ + ${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.host \ + ${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX} +.endif .endif diff --git a/share/mk/local.sys.dirdeps.mk b/share/mk/local.sys.dirdeps.mk index ce4843482179..357b6e2aa5ff 100644 --- a/share/mk/local.sys.dirdeps.mk +++ b/share/mk/local.sys.dirdeps.mk @@ -43,7 +43,7 @@ LDFLAGS_LAST+= -L${STAGE_LIBDIR} .-include "local.toolchain.mk" -.if ${.MAKE.LEVEL} > 0 && ${MACHINE} == "host" && ${.MAKE.DEPENDFILE:E} != "host" +.if ${.MAKE.LEVEL} > 0 && ${MACHINE:Nhost*} == "" && ${.MAKE.DEPENDFILE:E} != "${MACHINE}" # we can use this but should not update it. UPDATE_DEPENDFILE?= NO .endif @@ -115,16 +115,10 @@ ${var}= ${HOST_${var}} .endfor .endif -.if ${MACHINE:Nhost:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE} -# cross-building .if !defined(FREEBSD_REVISION) FREEBSD_REVISION!= sed -n '/^REVISION=/{s,.*=,,;s,",,g;p; }' ${SRCTOP}/sys/conf/newvers.sh .export FREEBSD_REVISION .endif -CROSS_TARGET_FLAGS?= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION} -CFLAGS+= ${CROSS_TARGET_FLAGS} -ACFLAGS+= ${CROSS_TARGET_FLAGS} -.endif # we set these here, rather than local.gendirdeps.mk # so we can ensure any DEP_* values that might be used in @@ -150,7 +144,7 @@ $V?= ${${V:S,DEP_,,}} .endfor .endif -.if ${MACHINE} == "host" && ${.MAKE.OS} != "FreeBSD" +.if ${MACHINE:Nhost*} == "" && ${.MAKE.OS} != "FreeBSD" # some makefiles expect this BOOTSTRAPPING= 0 .endif diff --git a/share/mk/local.sys.machine.mk b/share/mk/local.sys.machine.mk index fc801a7cd11c..5e40dfe805f9 100644 --- a/share/mk/local.sys.machine.mk +++ b/share/mk/local.sys.machine.mk @@ -1,10 +1,11 @@ .-include -PSEUDO_MACHINE_LIST?= common host +PSEUDO_MACHINE_LIST?= common host host32 TARGET_MACHINE_LIST?= amd64 arm arm64 i386 powerpc riscv MACHINE_ARCH_host?= ${_HOST_ARCH} +MACHINE_ARCH_host32?= ${_HOST_ARCH32} MACHINE_ARCH_LIST_arm?= armv7 ${EXTRA_ARCHES_arm} MACHINE_ARCH_LIST_arm64?= aarch64 diff --git a/share/mk/local.sys.mk b/share/mk/local.sys.mk index 59b1a7c14a7c..eb21380f051c 100644 --- a/share/mk/local.sys.mk +++ b/share/mk/local.sys.mk @@ -95,4 +95,11 @@ META_COOKIE_RM?= META_COOKIE_TOUCH?= META_DEPS+= ${META_NOPHONY} +.if ${MACHINE:Nhost*:Ncommon} != "" && ${MACHINE} != ${HOST_MACHINE} +# cross-building +CROSS_TARGET_FLAGS?= -target ${MACHINE_ARCH}-unknown-freebsd${FREEBSD_REVISION} +CFLAGS+= ${CROSS_TARGET_FLAGS} +ACFLAGS+= ${CROSS_TARGET_FLAGS} +.endif + .endif diff --git a/share/mk/src.init.linux.mk b/share/mk/src.init.linux.mk index 1e351e1b41f6..536f32853d3c 100644 --- a/share/mk/src.init.linux.mk +++ b/share/mk/src.init.linux.mk @@ -1,5 +1,6 @@ # We want to build some host tools (eg makefs, mkimg) for Linux # This only gets included during DIRDEPS_BUILD when MACHINE is "host" +# or "host32" CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux @@ -13,3 +14,5 @@ LIBADD+= egacy m # Bring in the full GNU namespace CFLAGS+= -D_GNU_SOURCE +# for sane staging behavior +LN= ln -L diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index d7112cf57178..c234a9829fca 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -368,7 +368,7 @@ BROKEN_OPTIONS+= OFED .endif # MK_host_egacy is set by local.sys.mk so is valid here -.if ${MACHINE} == "host" && ${MK_host_egacy} == "yes" +.if ${MACHINE:Nhost*} == "" && ${MK_host_egacy} == "yes" # we cannot expect tests to work BROKEN_OPTIONS+= TESTS .endif diff --git a/tools/build/Makefile b/tools/build/Makefile index 8ad104f904ea..a19d2bf64bc6 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -126,6 +126,8 @@ CHACHA20INCS+= ${SRCTOP}/sys/crypto/chacha20/_chacha.h \ .if ${MACHINE} == "host" _host_arch= ${_HOST_ARCH} +.elif ${MACHINE} == "host32" +_host_arch= ${_HOST_ARCH32} .else _host_arch=${MACHINE} .endif