Re: need macOS/Darwin help (was: preconv test failure on Darwin with nixpkgs 25.11)
"G. Branden Robinson" <[email protected]>
| Newsgroups | gmane.comp.printing.groff.general |
|---|---|
| Message-ID | <20260227080426.i4pja4tkk5te2sfs@illithid> |
Hi Alexis & John, At 2026-02-24T14:11:02+1100, John Gardner wrote: > > I don't know if there's any such thing as running an alternative > > libc on a macOS/Darwin system--maybe the system crashes; maybe Apple > > activates a kill switch in your Mac; or maybe things work more or > > less fine. > > It's actually far worse than any of those possibilities, I'm afraid. [much snippage; imagine Charlie Sheen "winning" meme here] > All of these complexities are why building software on OpenBSD makes > me feel like I'm FLYING. macOS isn't a walled garden, it's a prison > cell lined with garden-wallpaper. Heck, running just about any other OS in the world seems like it would feel like levitating at least a foot off the ground. At 2026-02-24T11:19:26+0100, Alexis wrote: [snip] > Note that $(which printf) will not work reliably as printf can be > a shell built-in as is the case for macOS' default shell, i.e. zsh. Yeah, this seems like a tough nut to crack, so I'm inclined to take a different approach. I was able to get to a Darwin system via the FSF France's compiler farm,[1] but unfortunately uchardet isn't installed by default and the "homebrew environment" that is supposedly available on a temporary basis seems not to work--I can't "brew install" anything due to permissions problems, and attempting to "sudo" that doesn't simply refuse my access (not a surprise), but vomits forth something about a bad gid which looks to me like the value of a 32-bit UINT_MAX. So...no idea. Would you guys try the attached revised "smoke-test.sh" for preconv on your Darwin system(s)? Just take the 1.24.0.rc4 distribution archive, unpack it (if it isn't already), and replace src/preproc/preconv/tests/smoke-test.sh with it. Please let me know the results. Regards, Branden [1] https://portal.cfarm.net/machines/list/
smoke-test.sh
(application/x-sh, 4.3 KB)
#!/bin/sh
#
# Copyright 2020-2024 G. Branden Robinson
#
# This file is part of groff, the GNU roff typesetting system.
#
# groff is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# groff is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
preconv="${abs_top_builddir:-.}/preconv"
fail=
wail () {
echo ...FAILED >&2
fail=YES
}
# Ensure a predictable character encoding.
export LC_ALL=C
echo "testing -e flag override of BOM detection" >&2
printf '\376\377\0\100\0\n' \
| "$preconv" -d -e euc-kr 2>&1 > /dev/null \
| grep -q "no search for coding tag" || wail
echo "testing detection of UTF-32BE BOM" >&2
printf '\0\0\376\377\0\0\0\100\0\0\0\n' \
| "$preconv" -d 2>&1 > /dev/null \
| grep -q "found BOM" || wail
echo "testing detection of UTF-32LE BOM" >&2
printf '\377\376\0\0\100\0\0\0\n\0\0\0' \
| "$preconv" -d 2>&1 > /dev/null \
| grep -q "found BOM" || wail
echo "testing detection of UTF-16BE BOM" >&2
printf '\376\377\0\100\0\n' \
| "$preconv" -d 2>&1 > /dev/null \
| grep -q "found BOM" || wail
echo "testing detection of UTF-16LE BOM" >&2
printf '\377\376\100\0\n\0' \
| "$preconv" -d 2>&1 > /dev/null \
| grep -q "found BOM" || wail
echo "testing detection of UTF-8 BOM" >&2
printf '\357\273\277@\n' \
| "$preconv" -d 2>&1 > /dev/null \
| grep -q "found BOM" || wail
# We do not find a coding tag on piped input because it isn't seekable.
echo "testing detection of Emacs coding tag in piped input" >&2
printf '.\\" -*- coding: euc-kr; -*-\\n' \
| "$preconv" -d 2>&1 >/dev/null \
| grep -q "no coding tag" || wail
test -z "$fail" || exit
# We need uchardet to work to get past this point.
if ! "$preconv" -v | grep -q 'with uchardet support'
then
echo "$0: preconv lacks uchardet support; skipping" >&2
exit 77 # skip
fi
# Instead of using temporary files, which in all fastidiousness means
# cleaning them up even if we're interrupted, which in turn means
# setting up signal handlers, we use files in the build tree.
# TODO: groff_mmse(7) is no longer UTF-8-encoded; find another.
#doc=contrib/mm/groff_mmse.7
#echo "testing uchardet detection on UTF-8 document $doc" >&2
#"$preconv" -d -D us-ascii 2>&1 >/dev/null $doc \
# | grep -q 'charset: UTF-8' || wail
# uchardet can't seek on a pipe either.
echo "testing uchardet detection on pipe (expect fallback to -D)" >&2
printf 'Eat at the caf\351.\n' \
| "$preconv" -d -D euc-kr 2>&1 > /dev/null \
| grep -q "encoding used: 'EUC-KR'" || wail
test -z "$fail" || exit
# Fall back to the locale.
#
# It's hard to determine the character encoding of the 'C' locale
# because the only POSIX-standard way to do so is to build a C program
# to call `nl_langinfo(CODESET)`. There's also no POSIX-standard way
# to ask a system to report the byte sequence it uses to encode, say,
# "lowercase e with acute accent".
#
# (I think Perl can do that, though.)
#
# We're just a shell script, so on non-glibc systems, we guess at it.
#
# On glibc systems, the 'C' locale uses "ANSI_X3.4-1968" for the
# character set, and `locale charmap` tells us as much, but preconv
# assumes Latin-1 instead of US-ASCII, so we override that.
#
# On Darwin (macOS) systems, we assume US-ASCII.
#
# For everything else, we assume UTF-8.
libc_vendor=
if command -v locale > /dev/null
then
libc_vendor=gnu
charset=ISO-8859-1
elif [ "$(uname -s)" = "Darwin" ]
then
libc_vendor=apple
charset=US-ASCII
else
libc_vendor=unknown
charset=UTF-8
fi
printf "standard C library vendor: %s;" $libc_vendor >&2
printf " expecting preconv character encoding %s\n" $charset >&2
echo "testing fallback to locale setting in environment" >&2
printf 'Eat at the caf\351.\n' \
| "$preconv" -d 2>&1 > /dev/null \
| grep -q "encoding used: '$charset'" || wail
test -z "$fail"
# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAmmhUAIACgkQ0Z6cfXEm bc6Mdg/9HN9e2YD3Y6VkUHGceACG5JMAr9rQLHSeBEzxXnhWzZotpkMdej4KZnpC xk0peOK0j7x3Z+3Iw61MVVfrG7f88RniUCAJs9kB+HyIjMg8CF/QNvt+AZ+uqTR9 PuPJ2HpC7N1siZUOB7Tn2u9qlbvx6+PLXDT+GYBpBeHLS0Xh9n/n/0yWpbCrzPKF mbV3NWwTjgQSIK6zm6gWAWujDd1+7tkLR+1X+G25I+qu6A5JmIgx2vsMWyp/1APh J2e7z7cXZsYsPNWNrX4Vsdz3/uGfIVCohca4MXjRyJtn2aO63leVgzED4tG61PY8 AMQBS05vwijEyXGhn92LIut9a+k25neSxyQwR7UFluJEqJYwzhI3y/hDiPSr/YWU uzK+2mcoYK0pPYPwAMxaBVjK24IvFCv4Eb4wy9Crlmk35buiCQ7iBmdTiKrGsw1b qGOiwRCVS+XLQtj1CoVgVa7uhRjJoDNxSy9eqbWlQKVeAoUERx2ZKqqsFIHPiLb5 e1nV8tN76JPU4e88/adW99X/AyBc3ISrs0sYeZzW8kO+PrBApEgOoweovE0ot1vF oj1fpx5OOfxRxYLCIOoYyg8QDDiJLpkhccK1FpXJDVCqy9df1YqoMAgruO91TIAj 7vSMpWUAsTGAtxXgxijBPiGHw2pRWewuRxj2vVbanu5jBX2Cj5M= =R8ZH -----END PGP SIGNATURE-----