Re: git: f9ee4156741a - main - build target triple variable from sys/conf/newvers.sh

From: Jessica Clarke <jrtc27_at_freebsd.org>
Date: Tue, 03 May 2022 15:15:05 UTC
On 3 May 2022, at 12:16, Alfredo Dal'Ava Junior <alfredo@FreeBSD.org> wrote:
> 
> The branch main has been updated by alfredo:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=f9ee4156741a205c93ae947595b5c48717107d9e
> 
> commit f9ee4156741a205c93ae947595b5c48717107d9e
> Author:     Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>
> AuthorDate: 2022-05-03 11:09:38 +0000
> Commit:     Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>
> CommitDate: 2022-05-03 11:09:38 +0000
> 
>    build target triple variable from sys/conf/newvers.sh
> 
>    Retrieve FreeBSD revision number directly from sys/conf/newvers.sh
>    when building the compiler target triple value, avoiding manual
>    intervention on other files every new release.
> 
>    Reviewed by:    imp
>    MFC after:      2 months
>    Sponsored by:   Instituto de Pesquisas Eldorado (eldorado.org.br)
>    Differential Revision:  https://reviews.freebsd.org/D34429
> ---
> Makefile.inc1           | 4 ++--
> lib/clang/llvm.build.mk | 9 ++++++---
> share/mk/bsd.compat.mk  | 4 ++--
> share/mk/src.sys.env.mk | 5 +++++
> 4 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/Makefile.inc1 b/Makefile.inc1
> index 2b913e4e51f8..e3081594ec77 100644
> --- a/Makefile.inc1
> +++ b/Makefile.inc1
> @@ -138,9 +138,9 @@ TARGET_ABI=	gnueabi
> .endif
> .endif
> MACHINE_ABI?=	unknown
> -MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/sf$//}-${MACHINE_ABI}-freebsd14.0
> +MACHINE_TRIPLE?=${MACHINE_ARCH:S/amd64/x86_64/:C/sf$//}-${MACHINE_ABI}-freebsd${OS_REVISION}
> TARGET_ABI?=	unknown
> -TARGET_TRIPLE?=	${TARGET_ARCH:S/amd64/x86_64/:C/sf$//}-${TARGET_ABI}-freebsd14.0
> +TARGET_TRIPLE?=	${TARGET_ARCH:S/amd64/x86_64/:C/sf$//}-${TARGET_ABI}-freebsd${OS_REVISION}
> KNOWN_ARCHES?=	aarch64/arm64 \
> 		amd64 \
> 		armv6/arm \
> diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk
> index 5aff7081fb76..dd54bf7312d9 100644
> --- a/lib/clang/llvm.build.mk
> +++ b/lib/clang/llvm.build.mk
> @@ -14,6 +14,10 @@
> .error Please define SRCDIR before including this file
> .endif
> 
> +.ifndef OS_REVISION
> +.error Please define OS_REVISION before including this file
> +.endif
> +
> .PATH:		${LLVM_BASE}/${SRCDIR}
> 
> CFLAGS+=	-I${SRCTOP}/lib/clang/include
> @@ -40,10 +44,9 @@ TARGET_ABI=	-gnueabi
> TARGET_ABI=
> .endif
> VENDOR=		unknown
> -OS_VERSION=	freebsd14.0
> 
> -LLVM_TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI}
> -LLVM_BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-${OS_VERSION}
> +LLVM_TARGET_TRIPLE?=	${TARGET_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-freebsd${OS_REVISION}${TARGET_ABI}
> +LLVM_BUILD_TRIPLE?=	${BUILD_ARCH:C/amd64/x86_64/:C/[hs]f$//:S/mipsn32/mips64/}-${VENDOR}-freebsd${OS_REVISION}
> 
> CFLAGS+=	-DLLVM_DEFAULT_TARGET_TRIPLE=\"${LLVM_TARGET_TRIPLE}\"
> CFLAGS+=	-DLLVM_HOST_TRIPLE=\"${LLVM_BUILD_TRIPLE}\"
> diff --git a/share/mk/bsd.compat.mk b/share/mk/bsd.compat.mk
> index 6a7d3d3c7e80..e99281775b84 100644
> --- a/share/mk/bsd.compat.mk
> +++ b/share/mk/bsd.compat.mk
> @@ -30,7 +30,7 @@ LIB32CPUFLAGS=	-march=${COMPAT_CPUTYPE}
> .endif
> .if ${COMPAT_COMPILER_TYPE} == gcc
> .else
> -LIB32CPUFLAGS+=	-target x86_64-unknown-freebsd14.0
> +LIB32CPUFLAGS+=	-target x86_64-unknown-freebsd${OS_REVISION}
> .endif
> LIB32CPUFLAGS+=	-m32
> LIB32_MACHINE=	i386
> @@ -51,7 +51,7 @@ LIB32CPUFLAGS=	-mcpu=${COMPAT_CPUTYPE}
> .if ${COMPAT_COMPILER_TYPE} == "gcc"
> LIB32CPUFLAGS+=	-m32
> .else
> -LIB32CPUFLAGS+=	-target powerpc-unknown-freebsd14.0
> +LIB32CPUFLAGS+=	-target powerpc-unknown-freebsd${OS_REVISION}
> .endif
> 
> LIB32_MACHINE=	powerpc
> diff --git a/share/mk/src.sys.env.mk b/share/mk/src.sys.env.mk
> index 6f11489bfd2f..86f739414230 100644
> --- a/share/mk/src.sys.env.mk
> +++ b/share/mk/src.sys.env.mk
> @@ -23,6 +23,11 @@ RELTOP?= 	${RELDIR:C,[^/]+,..,g}
> RELOBJTOP?=	${RELTOP}
> RELSRCTOP?=	${RELTOP}
> 
> +.if !defined(OS_REVISION)
> +OS_REVISION!=eval `sh ${SRCTOP}/sys/conf/newvers.sh -V REVISION` && echo $$REVISION || echo

In what situation would you ever want the version to silently be
omitted on error, rather than stopping the build?

Jess

> +.export OS_REVISION
> +.endif
> +
> # site customizations that do not depend on anything!
> 
> # Save MAKEOBJDIRPREFIX and don't let src-env.conf modify it.