pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: GO on macOS Monterrey
On 3/5/22 17:19, Roland Illig wrote:
Am 05.03.2022 um 22:35 schrieb Jason Bacon:
I don't think there's a problem here. ${OPSYS} == "Darwin" is checked
first, and if that's false, ${OSX_VERSION:R} >= 12 need not be
evaluated, so it doesn't matter if OSX_VERSION is empty. I just tested
on NetBSD and it works as expected (builds go14).
The bmake from pkgsrc is from 2020-05-24, which means that it always
evaluates ${OSX_VERSION}, even if ${OPSYS} is not "Darwin". This has
been fixed in NetBSD 10's make.
To demonstrate this:
$ cat <<'EOF' > macos.mk
.if ${OPSYS} == Darwin && ${OSX_VERSION:U0.0:R} >= 12
.endif
EOF
$ OPSYS=NetBSD bmake -r -f macos.mk -dcv
...
lhs = "NetBSD", rhs = "Darwin", op = ==
Applying[OSX_VERSION] :U to ""
Result[OSX_VERSION] of :U is "0.0"
Applying[OSX_VERSION] :R to "0.0"
Result[OSX_VERSION] of :R is "0"
left = 0.000000, right = 12.000000, op = >=
...
On NetBSD 10, the debug log has a different format but is still roughly
comparable:
$ OPSYS=NetBSD /usr/bin/make -r -f macos.mk -dcv
...
CondParser_Eval: ${OPSYS} == Darwin && ${OSX_VERSION:U0.0:R} >= 12
Var_Parse: ${OPSYS} == Darwin && ${OSX_VERSION:U0.0:R} >= 12 (eval-defined)
Comparing "NetBSD" == "Darwin"
Var_Parse: ${OSX_VERSION:U0.0:R} >= 12 (parse-only)
Parsing modifier ${OSX_VERSION:U...}
Result of ${OSX_VERSION:U0.0} is "" (parse-only, defined)
Parsing modifier ${OSX_VERSION:R}
Result of ${OSX_VERSION:R} is "" (parse-only, defined)
...
The log output does not have a line for "Comparing 12.000000" now.
Furthermore, it clearly says that the second condition is parse-only, it
is not evaluated.
Be careful though if OSX_VERSION can have three parts, for example
12.0.0. In such a case, the modifier ':R' would only strip the last
component, leaving 12.0. This can be compared numerically, and in the
edge case of having version numbers like 12.10.3, this number would be
less than 12.2.3, simply because 12.100000 < 12.200000. When comparing
with 12.0, this is no problem though.
To get only the major version even in case of three-part version
numbers, use ':R' twice, resulting in ${OSX_VERSION:R:R}.
Roland
Interesting, thanks for the detailed explanation.
A variation on that shows that an empty variable evaluates to 0.0 in
this setting:
NetBSD netbsd9.acadix bacon ~ 1014: (pkgsrc): cat macos.mk
.if ${OPSYS} == Darwin && ${OSX_VERSION:R} >= 12
.endif
NetBSD netbsd9.acadix bacon ~ 1015: (pkgsrc): env OPSYS=NetBSD bmake -r
-f macos.mk -dcv
[snip]
Applying[OSX_VERSION] :R to ""
Result[OSX_VERSION] of :R is ""
left = 0.000000, right = 12.000000, op = >=
So it's safe for non-Darwin platforms and adding :U seems to have no effect.
To assess the situation on Darwin, I added the following to a pkg Makefile:
do-configure:
@echo ${OPSYS}
@echo ${OSX_VERSION} ${OSX_VERSION:R} ${OSX_VERSION:R:R}
bmake configure produces:
Darwin
12.2 12 12
So the :R:R syntax is safe with a 2-part version, which was the only
question left in my mind following Roland's tips.
Assuming OSX_VERSION will never have *four* parts, I would go with the
following:
--- bootstrap.mk 14 Jul 2021 14:32:04 -0000 1.7
+++ bootstrap.mk 6 Mar 2022 00:19:22 -0000
@@ -1,7 +1,7 @@
# $NetBSD: bootstrap.mk,v 1.7 2021/07/14 14:32:04 jperkin Exp $
.if !defined(GOROOT_BOOTSTRAP) || !exists(${GOROOT_BOOTSTRAP}/bin/go)
-. if ${MACHINE_ARCH} == "aarch64"
+. if ${MACHINE_ARCH} == "aarch64" || ${OPSYS} == "Darwin" &&
${OSX_VERSION:R:R} >= 12
BUILD_DEPENDS+= go-bin-[0-9]*:../../lang/go-bin
GOROOT_BOOTSTRAP= ${PREFIX}/go-bin
. else
Home |
Main Index |
Thread Index |
Old Index