[PATCH] gexp: Improve support of Unicode characters.

  • Open
  • quality assurance status badge
Details
3 participants
  • Janneke Nieuwenhuizen
  • Ludovic Courtès
  • Tomas Volf
Owner
unassigned
Submitted by
Tomas Volf
Severity
normal
T
T
Tomas Volf wrote on 6 Oct 2024 17:42
(address . guix-patches@gnu.org)(name . Tomas Volf)(address . ~@wolfsden.cz)
a0c437bad0b83665734831f7de7fc7e1f6972128.1728229346.git.~@wolfsden.cz
Support for non-ASCII characters was mixed. Some gexp forms did support them,
while others did not. Combined with current value for
%default-port-conversion-strategy, that sometimes led to unpleasant surprises.
For example:

(scheme-file "utf8" #~(with-output-to-file #$output
(λ _ (display "?"))))

Was written to the store as:

((? _ (display "\u732b")))

No, that is not font issue on your part, that is an actual #\? instead of the
lambda character. Which, surprisingly, does not do what it should when
executed.

The solution is to switch to C.UTF-8 locale where possible, since it is now
always available. Or to explicitly set the port encoding.

No tests are provided, since majority of tests/gexp.scm use guile in version
2, and it tends to work under it. The issues occur mostly with guile 3.

I did test it locally using:

#!/bin/sh
set -eu
set -x

[ -f guix.scm ] || { echo >&2 Run from root of Guix repo.; exit 1; }
[ -f gnu.scm ] || { echo >&2 Run from root of Guix repo.; exit 1; }

cat >?.scm <<'EOF'
(define-module (?)
#:export (say))

(define (say)
"nyaaaa~~~~!")
EOF

mkdir -p dir-with-utf8-file
cp ?.scm dir-with-utf8-file/

cat >repro.scm <<'EOF'
(use-modules (guix build utils)
(guix derivations)
(guix gexp)
(guix store)
(ice-9 ftw)
(ice-9 textual-ports))

(define cat "?")

(define (drv-content drv)
(call-with-input-file (derivation->output-path drv)
get-string-all))

(define (out-content out)
(call-with-input-file out
get-string-all))

(define (drv-listing drv)
(scandir (derivation->output-path drv)))

(define (dir-listing dir)
(scandir dir))

(define-macro (test exp lower? report)
(let ((type (car exp)))
`(false-if-exception
(let ((drv (with-store %store
(run-with-store %store
(,(if lower? lower-object identity) ,exp)))))
(format #t "~%~a:~%" ',type)
(when (with-store %store
(build-derivations %store (list drv)))
(format #t "~a~%" (,report drv)))))))

(test (computed-file "utf8"
#~(with-output-to-file #$output
(λ _ (display #$cat))))
#t drv-content)

(test (program-file "utf8"
#~((λ _ (display #$cat))))
#t drv-content)

(test (scheme-file "utf8"
#~((λ _ (display #$cat))))
#t drv-content)

(test (text-file* "utf8" cat cat cat)
#f drv-content)

(test (compiled-modules '((?)))
#f drv-listing)

(test (file-union "utf8" `((,cat ,(plain-file "utf8" cat))))
#t drv-listing)

;;; No fix needed:
(test (imported-modules '((?)))
#f dir-listing)

(test (local-file "dir-with-utf8-file" #:recursive? #t)
#t dir-listing)

(test (plain-file "utf8" cat)
#t out-content)

(test (mixed-text-file "utf8" cat cat cat)
#t drv-content)

(test (directory-union "utf8" (list (local-file "dir-with-utf8-file"
#:recursive? #t)))
#t dir-listing)
EOF

guix shell -CWN -D guix glibc-locales -- \
env LANG=C.UTF-8 ./pre-inst-env guix repl -- ./repro.scm

Before this commit, the output is:

+ '[' -f guix.scm ']'
+ '[' -f gnu.scm ']'
+ cat
+ mkdir -p dir-with-utf8-file
+ cp ?.scm dir-with-utf8-file/
+ cat
+ guix shell -CWN -D guix glibc-locales -- env LANG=C.UTF-8 ./pre-inst-env guix repl -- ./repro.scm

computed-file:
?

program-file:
#!/gnu/store/mfkz7fvlfpv3ppwbkv0imb19nrf95akf-guile-3.0.9/bin/guile --no-auto-compile
!#
((? _ (display "\u732b")))

scheme-file:
((? _ (display "\u732b")))

text-file*:
???

compiled-modules:
building path(s) `/gnu/store/ay3jifyvliigfgnz67jf0kgngzpya5a5-module-import-compiled'
Backtrace:
5 (primitive-load "/gnu/store/rn7b0dq6iqfmmqyqzamix2mjmfy?")
In ice-9/eval.scm:
619:8 4 (_ #f)
In srfi/srfi-1.scm:
460:18 3 (fold #<procedure 7ffff79245e0 at ice-9/eval.scm:336:1?> ?)
In ice-9/eval.scm:
245:16 2 (_ #(#(#<directory (guix build utils) 7ffff779f320>) # ?))
In ice-9/boot-9.scm:
1982:24 1 (_ _)
In unknown file:
0 (stat "./???.scm" #<undefined>)

ERROR: In procedure stat:
In procedure stat: No such file or directory: "./???.scm"
builder for `/gnu/store/dxg87135zcd6a1c92dlrkyvxlbhfwfld-module-import-compiled.drv' failed with exit code 1

file-union:
(. .. ?)

imported-modules:
(. .. ?.scm)

local-file:
(. .. ?.scm)

plain-file:
?

mixed-text-file:
???

directory-union:
(. .. ?.scm)

Which I think you will agree is far from optimal. After my fix the output
changes to:

+ '[' -f guix.scm ']'
+ '[' -f gnu.scm ']'
+ cat
+ mkdir -p dir-with-utf8-file
+ cp ?.scm dir-with-utf8-file/
+ cat
+ guix shell -CWN -D guix glibc-locales -- env LANG=C.UTF-8 ./pre-inst-env guix repl -- ./repro.scm

computed-file:
?

program-file:
#!/gnu/store/8kbmn359jqkgsbqgqxnmiryvd9ynz8w7-guile-3.0.9/bin/guile --no-auto-compile
!#
((λ _ (display "?")))

scheme-file:
((λ _ (display "?")))

text-file*:
???

compiled-modules:
(. .. ?.go)

file-union:
(. .. ?)

imported-modules:
(. .. ?.scm)

local-file:
(. .. ?.scm)

plain-file:
?

mixed-text-file:
???

directory-union:
(. .. ?.scm)

Which is actually what the user would expect.

I also added missing arguments to the documentation.

* guix/gexp.scm (computed-file): Set LANG to C.UTF-8 by default.
(compiled-modules): Try to `setlocale'.
(gexp->script), (gexp->file): New `locale' argument defaulting to C.UTF-8.
(text-file*): Set output port encoding to UTF-8.
* doc/guix.texi (G-Expressions)[computed-file]: Document the changes. Use
@var. Document #:guile.
[gexp->script]: Document #:locale. Fix default value for #:target.
[gexp->file]: Document #:locale, #:system and #:target.

Change-Id: Ib323b51af88a588b780ff48ddd04db8be7c729fb
---
doc/guix.texi | 11 +++++++----
guix/gexp.scm | 24 ++++++++++++++++++------
2 files changed, 25 insertions(+), 10 deletions(-)

Toggle diff (122 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 52e36e4354..683ba2f44b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12270,7 +12270,9 @@ G-Expressions
This is the declarative counterpart of @code{text-file}.
@end deffn
-@deffn {Procedure} computed-file name gexp [#:local-build? #t] [#:options '()]
+@deffn {Procedure} computed-file @var{name} @var{gexp} @
+ [#:local-build? #t] [#:guile] @
+ [#:options '(#:env-vars (("LANG" . "C.UTF-8")))]
Return an object representing the store item @var{name}, a file or
directory computed by @var{gexp}. When @var{local-build?} is true (the
default), the derivation is built locally. @var{options} is a list of
@@ -12281,7 +12283,7 @@ G-Expressions
@deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
[#:guile (default-guile)] [#:module-path %load-path] @
- [#:system (%current-system)] [#:target #f]
+ [#:system (%current-system)] [#:target 'current] [#:locale "C.UTF-8"]
Return an executable script @var{name} that runs @var{exp} using
@var{guile}, with @var{exp}'s imported modules in its search path.
Look up @var{exp}'s modules in @var{module-path}.
@@ -12318,8 +12320,9 @@ G-Expressions
@deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
[#:set-load-path? #t] [#:module-path %load-path] @
- [#:splice? #f] @
- [#:guile (default-guile)]
+ [#:splice? #f] [#:guile (default-guile)] @
+ [#:system (%current-system)] [#:target 'current] @
+ [#:locale "C.UTF-8"]
Return a derivation that builds a file @var{name} containing @var{exp}.
When @var{splice?} is true, @var{exp} is considered to be a list of
expressions that will be spliced in the resulting file.
diff --git a/guix/gexp.scm b/guix/gexp.scm
index e44aea6420..c8aba91779 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -597,7 +597,10 @@ (define-record-type <computed-file>
(options computed-file-options)) ;list of arguments
(define* (computed-file name gexp
- #:key guile (local-build? #t) (options '()))
+ #:key
+ guile
+ (local-build? #t)
+ (options '(#:env-vars (("LANG" . "C.UTF-8")))))
"Return an object representing the store item NAME, a file or directory
computed by GEXP. When LOCAL-BUILD? is #t (the default), it ensures the
corresponding derivation is built locally. OPTIONS may be used to pass
@@ -1700,6 +1703,9 @@ (define* (compiled-modules modules
(system base target)
(system base compile))
+ ;; Best effort. The locale is not installed in all contexts.
+ (false-if-exception (setlocale LC_ALL "C.UTF-8"))
+
(define modules
(getenv "modules"))
@@ -1990,7 +1996,8 @@ (define* (gexp->script name exp
#:key (guile (default-guile))
(module-path %load-path)
(system (%current-system))
- (target 'current))
+ (target 'current)
+ (locale "C.UTF-8"))
"Return an executable script NAME that runs EXP using GUILE, with EXP's
imported modules in its search path. Look up EXP's modules in MODULE-PATH."
(mlet* %store-monad ((target (if (eq? target 'current)
@@ -2033,7 +2040,8 @@ (define* (gexp->script name exp
;; These derivations are not worth offloading or
;; substituting.
#:local-build? #t
- #:substitutable? #f)))
+ #:substitutable? #f
+ #:env-vars `(("LANG" . ,locale)))))
(define* (gexp->file name exp #:key
(guile (default-guile))
@@ -2041,7 +2049,8 @@ (define* (gexp->file name exp #:key
(module-path %load-path)
(splice? #f)
(system (%current-system))
- (target 'current))
+ (target 'current)
+ (locale "C.UTF-8"))
"Return a derivation that builds a file NAME containing EXP. When SPLICE?
is true, EXP is considered to be a list of expressions that will be spliced in
the resulting file.
@@ -2081,7 +2090,8 @@ (define* (gexp->file name exp #:key
#:local-build? #t
#:substitutable? #f
#:system system
- #:target target)
+ #:target target
+ #:env-vars `(("LANG" . ,locale)))
(gexp->derivation name
(gexp
(call-with-output-file (ungexp output)
@@ -2098,7 +2108,8 @@ (define* (gexp->file name exp #:key
#:local-build? #t
#:substitutable? #f
#:system system
- #:target target))))
+ #:target target
+ #:env-vars `(("LANG" . ,locale))))))
(define* (text-file* name #:rest text)
"Return as a monadic value a derivation that builds a text file containing
@@ -2108,6 +2119,7 @@ (define* (text-file* name #:rest text)
(define builder
(gexp (call-with-output-file (ungexp output "out")
(lambda (port)
+ (set-port-encoding! port "UTF-8")
(display (string-append (ungexp-splicing text)) port)))))
(gexp->derivation name builder
--
2.46.0
T
T
Tomas Volf wrote on 23 Oct 2024 02:13
(address . 73660@debbugs.gnu.org)
87ttd365hu.fsf@wolfsden.cz
Hello,

any opinion regarding this patch? I think it prevents whole class of
annoying bugs, and some forms already had support for it, this just
extend it to all forms.

Have a nice day,
Tomas
J
J
Janneke Nieuwenhuizen wrote on 10 Jan 17:00 +0100
(name . Tomas Volf)(address . ~@wolfsden.cz)(address . 73660@debbugs.gnu.org)
87v7ummzgf.fsf@gnu.org
Tomas Volf writes:

Hi,

Toggle quote (4 lines)
> any opinion regarding this patch? I think it prevents whole class of
> annoying bugs, and some forms already had support for it, this just
> extend it to all forms.

While I don't feel qualified to LGTM this patch, it makes sense to me.

I added the patch to core-packages-team, but also reverted it to avoid a
world rebuild.

Just now I pushed a newlyrebased core-packages-team with the patch

Would you like to also keep an eye out for how that works?

Greetings,
Janneke

--
Janneke Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com| Avatar® https://AvatarAcademy.com
T
T
Tomas Volf wrote on 11 Jan 01:42 +0100
(name . Janneke Nieuwenhuizen)(address . janneke@gnu.org)(address . 73660@debbugs.gnu.org)
87ikqmp4e4.fsf@wolfsden.cz
Janneke Nieuwenhuizen <janneke@gnu.org> writes:

Toggle quote (14 lines)
> Tomas Volf writes:
>
> Hi,
>
>> any opinion regarding this patch? I think it prevents whole class of
>> annoying bugs, and some forms already had support for it, this just
>> extend it to all forms.
>
> While I don't feel qualified to LGTM this patch, it makes sense to me.
>
> As discussed on IRC <https://logs.guix.gnu.org/guix/2025-01-05.log#134213>
> I added the patch to core-packages-team, but also reverted it to avoid a
> world rebuild.

Re-reading the IRC log I have noticed I forgot to say my thanks, so,
thank you :)

Toggle quote (6 lines)
>
> Just now I pushed a newlyrebased core-packages-team with the patch
> in action, see <https://ci.guix.gnu.org/jobset/core-packages-team>.
>
> Would you like to also keep an eye out for how that works?

I can take a look from time to time (seems to still be building). Let
us hope nothing burns down. I *think* it should not really break
anything, but who knows, Guix is complex beast and I am not that smart.

Have a nice weekend,
Tomas

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmeBvoQOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wandbQ/9FTixcveZyrU01FUoc8LwZ46W0TB8su8V0kOw
Q0lsoQBzyCpKw07S6uvccFNf5qgWpRSwTUOT3nYxnOtya8sya3h0znHFqClrdUBl
MwB4sHGKkA3UR2wpehHon6jEe9wKy6pmbDmgSNcCnXl7C+oeLmu1sNUxG1Jg8ZOb
adye9jOfB4oWIVGpQkwKtIseKFHJZ7PepCwjD9tKonugGIYhzW/nvl57oYDPyGws
Mh+bMy5oa3YA2CFeeDf98VUqifYBc0oglXO30LyRWP6y3C3UKinJNQXolFZTqL/u
7KGkdIBP97XlF22ifnz+fqptq5F68kQZxSyl8m4SaBNH7L5VZzznGj4szXFI/r89
71cdBPNPqmYWRAiU/O3PfAonBmZPEAOzxcYSLpXL0wbJ/+ZZ4H6ftXv3KhBSD+R/
cM4D5cWtwGpcy1ySLeQ2p27RXKwyd4Odm3cwIIp3bQJdws132CGKKt+TYw8zJaCa
z0mL1FI3OKICsh6ueSST6gEacRNGqpryE4GmVCRxLby86QTj0uoJwYI8m5emA/Ik
ajDFBS55mmhEQ5OCe3LcqqPVP7MC3cJM6B1jtlzgrPolvnbe5zu0jeQWI5ZyTNeK
6aiIIL7wfx3Az4t5NRp83f6k6QJU8PCLPqaukT9tGYdYp+ZeqilkFN73VwVSw+Ta
LlmWy9M=
=daNr
-----END PGP SIGNATURE-----

T
T
Tomas Volf wrote on 11 Jan 18:07 +0100
(name . Janneke Nieuwenhuizen)(address . janneke@gnu.org)(address . 73660@debbugs.gnu.org)
875xmlp9dy.fsf@wolfsden.cz
Janneke Nieuwenhuizen <janneke@gnu.org> writes:

Toggle quote (2 lines)
> Would you like to also keep an eye out for how that works?

It seems the evaluation failed, however I have no idea if that is due to
my changes or not. The first issue I see in the log seems to be:

Toggle snippet (3 lines)
building of `/gnu/store/5qizz7ba86rd979xspsw3vi2xpg6gq7b-glibc-headers-mesboot-2.16.0.drv' timed out after 3600 seconds of silence

For what it is worth, it fails to me locally as well, but with a
different error:

Toggle snippet (6 lines)
build of /gnu/store/n45z6cfa9i3jdh07q1ib6pcbll8j6jn7-libstdc++-boot0-4.9.4.drv failed
View build log at '/var/log/guix/drvs/n4/5z6cfa9i3jdh07q1ib6pcbll8j6jn7-libstdc++-boot0-4.9.4.drv.gz'.
cannot build derivation `/gnu/store/gai3hg9c8qb89qlz8fwrgpscmf74g6c8-gcc-cross-boot0-14.2.0.drv': 1 dependencies couldn't be built
cannot build derivation `/gnu/store/f2di3rzlyqa2xsby7z197wsldvqixq0l-gcc-cross-boot0-wrapped-14.2.0.drv': 1 dependencies couldn't be built

Which, looking into the log leads to:

Toggle snippet (6 lines)
starting phase `patch-tzdb.cc'
error: in phase 'patch-tzdb.cc': uncaught exception:
system-error "mkstemp!" "~A" ("No such file or directory") (2)
phase `patch-tzdb.cc' failed after 0.0 seconds

I am not sure this is caused by my changes. When I revert the commit:

Toggle snippet (10 lines)
$ git -C guix-proper log -1
commit 178c8707fc795b7612ed493523a2f4ef5a71966d (HEAD -> xx)
Author: Linux User
Date: Sat Jan 11 16:56:00 2025 +0000

Revert "gexp: Improve support of Unicode characters."
This reverts commit 3532efb0167dae540d9b968b191aa76c4ec79212.

It still fails with the same error.

Any ideas?

Tomas

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmeCpTkOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wanLtBAAsU8HjVCEDLFI9RpKaEr8bJSTRITWqzd2jq8e
xTFGShf4XDT+pTwLBGbsIqgworHIxIIHN+0zMejCiUXHLSu8WoqMdXaNTCFT/8dG
NAnSaNbp/oGUVYpDwumhSb3mfAZ8fN8AxssSCHan728Lo0r0cOlJ8ZKNx6QLXey5
BCuITcmhn6RMhJRj40u5YI5XDA9RuOKrkxhoo0idGX5MvaPDdncCCTJxTulAkJS0
GvUvlCSR2KwALwbUu4fY/0iOL9TO2jhNMk5Z4ft1fmJb500KmjlFCyUqAG2jCguz
FM54jdRzAkMsHoiWNoJyxfv+NogQG3oFDO6bbSbcCz/0vIN2OP0jiLsRWIzOgKO/
Af1CxAfL6RQyBdm9URY5yRQoXmvqbzKb1K5aeF9Pi0EKWH9bIjP7GGC/N6gpkt7S
GDjmUrXOSg7iH8X4YGaFyfM0taeCC9NSgBtLW/gGKsUBOk6GcQt8eXJErkJCUzOj
1kyyyfDMStxrr8jsE2D4Ta9qz771Xfux74HnU4PC4zUtaCmbB4QUUYmL+tHOFUUT
vqrvoCAXnnO6TzomcKFj6uoo07HuUsd7VZee6tm/LdOGMK7M5L6jQZNmAoB2Su67
wO/bIHlHq4HAC3gk0BztAO6ykOVZYmmj6x6MWanc76HhC3qu49BqUMgs4QQx3gi6
CtZt+5s=
=Iq5M
-----END PGP SIGNATURE-----

J
J
Janneke Nieuwenhuizen wrote on 11 Jan 19:09 +0100
(name . Tomas Volf)(address . ~@wolfsden.cz)(address . 73660@debbugs.gnu.org)
878qrhmdcc.fsf@gnu.org
Tomas Volf writes:

Hello Tomas,

Toggle quote (11 lines)
> Janneke Nieuwenhuizen <janneke@gnu.org> writes:
>
>> Would you like to also keep an eye out for how that works?
>
> It seems the evaluation failed, however I have no idea if that is due to
> my changes or not. The first issue I see in the log seems to be:
>
> building of
> `/gnu/store/5qizz7ba86rd979xspsw3vi2xpg6gq7b-glibc-headers-mesboot-2.16.0.drv'
> timed out after 3600 seconds of silence

Ah. I wondered why there was a big red cross instead of a lot of nice
green builds...

Toggle quote (16 lines)
> For what it is worth, it fails to me locally as well, but with a
> different error:
>
> build of /gnu/store/n45z6cfa9i3jdh07q1ib6pcbll8j6jn7-libstdc++-boot0-4.9.4.drv failed
> View build log at '/var/log/guix/drvs/n4/5z6cfa9i3jdh07q1ib6pcbll8j6jn7-libstdc++-boot0-4.9.4.drv.gz'.
> cannot build derivation `/gnu/store/gai3hg9c8qb89qlz8fwrgpscmf74g6c8-gcc-cross-boot0-14.2.0.drv': 1 dependencies couldn't be built
> cannot build derivation `/gnu/store/f2di3rzlyqa2xsby7z197wsldvqixq0l-gcc-cross-boot0-wrapped-14.2.0.drv': 1 dependencies couldn't be built
>
>
> Which, looking into the log leads to:
>
> starting phase `patch-tzdb.cc'
> error: in phase 'patch-tzdb.cc': uncaught exception:
> system-error "mkstemp!" "~A" ("No such file or directory") (2)
> phase `patch-tzdb.cc' failed after 0.0 seconds

Weird! Oh wait, I removed guards around that stage.

core-packages-team-old has

Toggle snippet (35 lines)
#$@(if (target-hurd64?)
#~((add-after 'unpack 'patch-hurd64
(lambda _
(substitute* "libstdc++-v3/src/c++20/tzdb.cc"
(("#if ! defined _GLIBCXX_ZONEINFO_DIR")
"#if __GNU__ || ! defined _GLIBCXX_ZONEINFO_DIR")))))
'())
#$@(if (and (target-x86-64?) (target-linux?)
(version>=? (package-version gcc) "14"))
#~((add-after 'unpack 'patch-x86_64-linux
(lambda _
(substitute* "libstdc++-v3/src/c++20/tzdb.cc"
(("#if ! defined _GLIBCXX_ZONEINFO_DIR")
"#if __x86_64__ || ! defined _GLIBCXX_ZONEINFO_DIR")))))
'())
#$@(if (and (target-x86-32?) (target-linux?)
(version>=? (package-version gcc) "14"))
#~((add-after 'unpack 'patch-x86_64-linux
(lambda _
(substitute* "libstdc++-v3/src/c++20/tzdb.cc"
(("#if ! defined _GLIBCXX_ZONEINFO_DIR")
"#if __i386__ || __x86_64__ || ! defined _GLIBCXX_ZONEINFO_DIR")))))
'())
#$@(if (and (target-linux?)
(not (target-x86-64?))
(not (target-x86-32?))
(version>=? (package-version gcc) "14"))
#~((add-after 'unpack 'patch-tzdb.cc
(lambda _
(substitute* "libstdc++-v3/src/c++20/tzdb.cc"
(("#if ! defined _GLIBCXX_ZONEINFO_DIR")
"#if 1 // ! defined _GLIBCXX_ZONEINFO_DIR")))))
'()))

and the new core-packages-team has

Toggle snippet (7 lines)
(add-after 'unpack 'patch-tzdb.cc
(lambda _
(substitute* "libstdc++-v3/src/c++20/tzdb.cc"
(("#if ! defined _GLIBCXX_ZONEINFO_DIR")
"#if 1 // ! defined _GLIBCXX_ZONEINFO_DIR")))))

ow, there it already is. Silly me, we need the gcc-14 guard. I was so
happy all systems seemed to need the same code that I also removed the
check for gcc-14.

Toggle quote (2 lines)
> I am not sure this is caused by my changes. When I revert the commit:

Certainly not! But thanks for trying!

[..]

Toggle quote (2 lines)
> Any ideas?

Meanwhile, because it seemed the build farm stopped working for me, I
started to build myself again and currently have

Toggle snippet (5 lines)
successfully built /gnu/store/5qizz7ba86rd979xspsw3vi2xpg6gq7b-glibc-headers-mesboot-2.16.0.drv
successfully built /gnu/store/91212rdl4cn4rr8aqfrbilxagmx9fwj3-glibc-mesboot-2.16.0.drv
successfully built /gnu/store/5a0bd35brzf1sgnw10slaxipmxa3cafn-gcc-mesboot1-wrapper-4.6.4.drv

so I didn't see this problem yet. I've pushed a squash! commit that
should fix this. Thanks!

Greetings,
Janneke

--
Janneke Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com| Avatar® https://AvatarAcademy.com
L
L
Ludovic Courtès wrote on 12 Jan 16:19 +0100
(name . Tomas Volf)(address . ~@wolfsden.cz)
874j24kqk8.fsf@gnu.org
Hello,

Tomas Volf <~@wolfsden.cz> skribis:

Toggle quote (11 lines)
> * guix/gexp.scm (computed-file): Set LANG to C.UTF-8 by default.
> (compiled-modules): Try to `setlocale'.
> (gexp->script), (gexp->file): New `locale' argument defaulting to C.UTF-8.
> (text-file*): Set output port encoding to UTF-8.
> * doc/guix.texi (G-Expressions)[computed-file]: Document the changes. Use
> @var. Document #:guile.
> [gexp->script]: Document #:locale. Fix default value for #:target.
> [gexp->file]: Document #:locale, #:system and #:target.
>
> Change-Id: Ib323b51af88a588b780ff48ddd04db8be7c729fb

[...]

Toggle quote (7 lines)
> (define* (computed-file name gexp
> - #:key guile (local-build? #t) (options '()))
> + #:key
> + guile
> + (local-build? #t)
> + (options '(#:env-vars (("LANG" . "C.UTF-8")))))

I’d suggest LC_CTYPE (or LC_ALL?) rather than LANG.

Also, what about making it the default for the #:env-vars of
‘gexp->derivation’? That way it wouldn’t need to be repeated in several
places.

Toggle quote (7 lines)
> @@ -1700,6 +1703,9 @@ (define* (compiled-modules modules
> (system base target)
> (system base compile))
>
> + ;; Best effort. The locale is not installed in all contexts.
> + (false-if-exception (setlocale LC_ALL "C.UTF-8"))

Sounds good. I would make it a separate patch.

s/in all contexts/when cross-compiling/

Toggle quote (8 lines)
> @@ -1990,7 +1996,8 @@ (define* (gexp->script name exp
> #:key (guile (default-guile))
> (module-path %load-path)
> (system (%current-system))
> - (target 'current))
> + (target 'current)
> + (locale "C.UTF-8"))

I would remove this argument and instead add an explicit, hard-coded:

(set-port-encoding! port "UTF-8")

in the body of ‘call-with-output-file’ here, just like you did below.

Toggle quote (9 lines)
> (define* (text-file* name #:rest text)
> "Return as a monadic value a derivation that builds a text file containing
> @@ -2108,6 +2119,7 @@ (define* (text-file* name #:rest text)
> (define builder
> (gexp (call-with-output-file (ungexp output "out")
> (lambda (port)
> + (set-port-encoding! port "UTF-8")
> (display (string-append (ungexp-splicing text)) port)))))

LGTM. This can be moved to a separate file.

How does that sound?

Apologies for not replying earlier!

Ludo’.
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 73660@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 73660
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch