* Preparing for the libc/locale upgrade
@ 2015-09-24 19:25 Ludovic Courtès
0 siblings, 0 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-09-24 19:25 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 2349 bytes --]
Problem: Programs linked against libc < 2.22 abort when trying to load
libc 2.22-or-later locale data:
https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html
Programs linked against libc 2.22 do not abort when trying to load 2.21
locale data, but they fail to load data for the LC_COLLATE category (in
which case ‘setlocale’ returns ENOENT and the program prints a warning)
due to the addition of the _NL_COLLATE_ENCODING_TYPE element.
In all situations, as a last resort, one can always run:
export LC_ALL=C
to sidestep the incompatibility issues.
Since ‘core-updates’ will soon be merged, bringing libc 2.22, here’s a
preview of the problems you may encounter and possible solutions.
Consequences on GuixSD:
• If programs in user profile use libc 2.22 but
/run/current-system/locale provides libc 2.21 locales: no hard
problem, but the LC_COLLATE problem.
• If LOCPATH points to 2.22 locales but /run/current-system/profile
contains 2.21 programs (Coreutils, sed, grep, etc.), these will
abort. Solution: unset LOCPATH so that programs use the 2.21 locale
data from /run/current-system/locale.
• If /run/current-system is upgraded to 2.22 but user profiles contain
2.21 programs, these will abort. Solution: upgrade user profiles,
or install glibc-utf8-locale-2.21 in user profile (preferably before
upgrading GuixSD to libc 2.22.)
Consequences for Guix on foreign distros:
• If the host distro provides binaries that use libc < 2.22 and you
use a mixture of Guix-provided and distro-provided programs, this is
pretty bad.
Solution: unset LOCPATH and say goodbye to locales for Guix-provided
packages (setting LOCPATH=$HOME/.guix-profile/lib/locale would break
all the distro-provided programs), or use exclusively Guix-provided
programs, or use the “C” locale.
Lesson learned:
• On GuixSD, we should use a versioned directory,
/run/current-system/locale/X.Y, as the default locale directory,
which would avoid problems.
• The attached patches allow GuixSD users to choose a different libc
than the current one to build the locales that go to
/run/current-system/locale. However this isn’t really satisfying.
Comments welcome!
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-system-locale-Add-a-glibc-for-locales-knob.patch --]
[-- Type: text/x-patch, Size: 9410 bytes --]
From beb9975ed28e12b78f7043d76f2895c97cd7e4a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 24 Sep 2015 21:03:45 +0200
Subject: [PATCH 2/2] system: locale: Add a 'glibc-for-locales' knob.
* gnu/system.scm (<operating-system>)[glibc-for-locales]: New field.
(operating-system-locale-directory): Honor it.
* gnu/system/locale.scm (sanity-check): New procedure.
(locale-directory): Use it.
* doc/guix.texi (Locales)[Locale Data Compatibility Considerations]: New
section.
---
doc/guix.texi | 42 +++++++++++++++++++++++
gnu/system.scm | 5 ++-
gnu/system/locale.scm | 95 +++++++++++++++++++++++++++++++++------------------
3 files changed, 108 insertions(+), 34 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 07c5add..6c0adda 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5158,6 +5158,10 @@ Library Reference Manual}). @xref{Locales}, for more information.
The list of locale definitions to be compiled and that may be used at
run time. @xref{Locales}.
+@item @code{glibc-for-locales} (default: @var{glibc-2.21})
+The GNU@tie{}libc package whose locale data and tools are used to build
+the locale definitions. @xref{Locales}.
+
@item @code{name-service-switch} (default: @var{%default-nss})
Configuration of libc's name service switch (NSS)---a
@code{<name-service-switch>} object. @xref{Name Service Switch}, for
@@ -5615,6 +5619,44 @@ instance it has @code{uk_UA.utf8} but @emph{not}, say,
@code{uk_UA.UTF-8}.
@end defvr
+@subsubsection Locale Data Compatibility Considerations
+
+@cindex incompatibility, of locale data
+@code{operating-system} declarations provide a @code{glibc-for-locales}
+field to specify the GNU@tie{}libc package that is used to compile
+locale declarations (@pxref{operating-system Reference}). ``Why would I
+care?'', you may ask. Well, it turns out that the binary format of
+locale data may be incompatible from one libc version to another.
+
+@c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
+@c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
+For instance, a program linked against libc version 2.21 is unable to
+read locale data produced with libc 2.22; worse, that program
+@emph{aborts} instead of simply ignoring the incompatible locale
+data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
+the incompatible locale data, which is already an improvement.}. On the
+other hand, a program linked against libc 2.22 can read locale data from
+libc 2.21, except for @code{LC_COLLATE} data; thus calls to
+@code{setlocale} may fail, but programs will not abort.
+
+The ``problem'' in GuixSD is that users have a lot of freedom: They can
+choose whether and when to upgrade software in their profiles, and might
+be using a libc version different from the one the system administrator
+used to build the system-wide locale data.
+
+Fortunately, users can also install their own locale data and define
+@var{LOCPATH} accordingly (@pxref{locales-and-locpath, @code{LOCPATH}
+and locale packages}).
+
+Still, it is best if the system-wide locale data at
+@file{/run/current-system/locale} is built using an older libc. That
+way, both programs linked against the new libc and programs linked
+against the older one can load locale data. For this reason, the
+@code{glibc-for-locales} field defaults to a libc version slightly older
+than the current one, with the caveat that some locale categories may be
+incompatible.
+
+
@node Services
@subsection Services
diff --git a/gnu/system.scm b/gnu/system.scm
index cee5f37..8b5f981 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -146,6 +146,8 @@
(default "en_US.utf8"))
(locale-definitions operating-system-locale-definitions ; list of <locale-definition>
(default %default-locale-definitions))
+ (glibc-for-locales operating-system-glibc-for-locales ; <package>
+ (default glibc-2.21))
(name-service-switch operating-system-name-service-switch ; <name-service-switch>
(default %default-nss))
@@ -866,7 +868,8 @@ listed in OS. The C library expects to find it under
(raise (condition
(&message (message "system locale lacks a definition")))))
- (locale-directory (operating-system-locale-definitions os)))
+ (locale-directory (operating-system-locale-definitions os)
+ #:libc (operating-system-glibc-for-locales os)))
(define (kernel->grub-label kernel)
"Return a label for the GRUB menu entry that boots KERNEL."
diff --git a/gnu/system/locale.scm b/gnu/system/locale.scm
index 393dd42..f7e17f8 100644
--- a/gnu/system/locale.scm
+++ b/gnu/system/locale.scm
@@ -20,8 +20,11 @@
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (gnu packages base)
+ #:use-module (gnu packages guile)
+ #:use-module (gnu packages linux)
#:use-module (gnu packages compression)
#:use-module (srfi srfi-26)
+ #:use-module (ice-9 match)
#:export (locale-definition
locale-definition?
locale-definition-name
@@ -59,6 +62,25 @@
(string-append #$output "/"
#$(locale-definition-name locale))))))
+(define (sanity-check locale-data locale)
+ "Return an expression that returns true if a program linked against the
+current glibc package can read locale data for LOCALE from LOCALE-DATA."
+ #~(begin
+ (format #t "checking whether current libc can \
+load this locale data from '~a'...~%"
+ #$locale-data)
+ (setenv "LOCPATH" #$locale-data)
+ (setenv "LC_ALL" #$locale)
+
+ ;; If this fails with an assertion failure, then this is bad. See
+ ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>
+ ;; and <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>.
+ ;; We can't check whether (setlocale LC_ALL "") works because it is
+ ;; likely to fail, at least because of one locale category whose data
+ ;; format has changed incompatibly.
+ (zero? (system* (string-append #$(canonical-package glibc)
+ "/bin/locale")))))
+
(define* (locale-directory locales
#:key (libc (canonical-package glibc)))
"Return a directory containing all of LOCALES compiled."
@@ -70,8 +92,15 @@
(setenv "PATH" (string-append #$gzip "/bin"))
(exit
- (and #$@(map (cut localedef-command <> #:libc libc)
- locales)))))
+ (and (system* (string-append #$libc "/bin/localedef") "--version")
+ #$@(map (cut localedef-command <> #:libc libc)
+ locales)
+ #$(match locales
+ ((first . _)
+ (sanity-check #~#$output
+ (locale-definition-name first)))
+ (()
+ #t))))))
(gexp->derivation "locale" build
#:local-build? #t))
@@ -97,37 +126,37 @@
(source "en_US")
(charset "UTF-8"))
(utf8-locales "ca_ES"
- "cs_CZ"
- "da_DK"
- "de_DE"
- "el_GR"
- "en_AU"
- "en_CA"
- "en_GB"
- "en_US"
- "es_AR"
- "es_CL"
- "es_ES"
- "es_MX"
- "fi_FI"
- "fr_BE"
- "fr_CA"
- "fr_CH"
- "fr_FR"
- "ga_IE"
- "it_IT"
- "ja_JP"
- "ko_KR"
- "nb_NO"
- "nl_NL"
- "pl_PL"
- "pt_PT"
- "ro_RO"
- "ru_RU"
- "sv_SE"
- "tr_TR"
- "uk_UA"
- "vi_VN"
+ ;; "cs_CZ"
+ ;; "da_DK"
+ ;; "de_DE"
+ ;; "el_GR"
+ ;; "en_AU"
+ ;; "en_CA"
+ ;; "en_GB"
+ ;; "en_US"
+ ;; "es_AR"
+ ;; "es_CL"
+ ;; "es_ES"
+ ;; "es_MX"
+ ;; "fi_FI"
+ ;; "fr_BE"
+ ;; "fr_CA"
+ ;; "fr_CH"
+ ;; "fr_FR"
+ ;; "ga_IE"
+ ;; "it_IT"
+ ;; "ja_JP"
+ ;; "ko_KR"
+ ;; "nb_NO"
+ ;; "nl_NL"
+ ;; "pl_PL"
+ ;; "pt_PT"
+ ;; "ro_RO"
+ ;; "ru_RU"
+ ;; "sv_SE"
+ ;; "tr_TR"
+ ;; "uk_UA"
+ ;; "vi_VN"
"zh_CN"))))
;;; locale.scm ends here
--
2.5.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-gnu-glibc-Add-version-2.21.patch --]
[-- Type: text/x-patch, Size: 1285 bytes --]
From 5024853a917706ba9ef0353444ce54d3b846b5be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 24 Sep 2015 16:21:45 +0200
Subject: [PATCH 1/2] gnu: glibc: Add version 2.21.
* gnu/packages/base.scm (glibc-2.21): New variable.
---
gnu/packages/base.scm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 69db178..d263093 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -618,6 +618,21 @@ with the Linux kernel.")
(license lgpl2.0+)
(home-page "http://www.gnu.org/software/libc/")))
+(define-public glibc-2.21
+ ;; The old libc, which we use mostly to build locale data in the old format
+ ;; (which the new libc can cope with.)
+ (package
+ (inherit glibc)
+ (version "2.21")
+ (source (origin
+ (inherit (package-source glibc))
+ (uri (string-append "mirror://gnu/glibc/glibc-"
+ version ".tar.xz"))
+ (sha256
+ (base32
+ "1f135546j34s9bfkydmx2nhh9vwxlx60jldi80zmsnln6wj3dsxf"))
+ (patches (list (search-patch "glibc-ldd-x86_64.patch")))))))
+
(define-public glibc-locales
(package
(inherit glibc)
--
2.5.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Preparing for the libc/locale upgrade
@ 2015-09-28 9:17 Federico Beffa
2015-09-28 20:45 ` Ludovic Courtès
2015-09-29 14:32 ` Mark H Weaver
0 siblings, 2 replies; 30+ messages in thread
From: Federico Beffa @ 2015-09-28 9:17 UTC (permalink / raw)
To: Guix-devel
ludo@gnu.org (Ludovic Courtès) writes:
[...]
> Consequences for Guix on foreign distros:
>
> • If the host distro provides binaries that use libc < 2.22 and you
> use a mixture of Guix-provided and distro-provided programs, this is
> pretty bad.
>
> Solution: unset LOCPATH and say goodbye to locales for Guix-provided
> packages (setting LOCPATH=$HOME/.guix-profile/lib/locale would break
> all the distro-provided programs), or use exclusively Guix-provided
> programs, or use the “C” locale.
Does this means that Guix on other distributions is no longer of
interest to the Guix project and it is essentially unsupported?
Or is this a transitory situation and an acceptable solution is being
worked on?
Regards,
Fede
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-28 9:17 Preparing for the libc/locale upgrade Federico Beffa
@ 2015-09-28 20:45 ` Ludovic Courtès
2015-09-30 12:35 ` Federico Beffa
2015-09-29 14:32 ` Mark H Weaver
1 sibling, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2015-09-28 20:45 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
> [...]
>
>> Consequences for Guix on foreign distros:
>>
>> • If the host distro provides binaries that use libc < 2.22 and you
>> use a mixture of Guix-provided and distro-provided programs, this is
>> pretty bad.
>>
>> Solution: unset LOCPATH and say goodbye to locales for Guix-provided
>> packages (setting LOCPATH=$HOME/.guix-profile/lib/locale would break
>> all the distro-provided programs), or use exclusively Guix-provided
>> programs, or use the “C” locale.
>
> Does this means that Guix on other distributions is no longer of
> interest to the Guix project and it is essentially unsupported?
No, definitely not!
While suboptimal, the 3 solutions above are probably OK as a temporary
measure.
For the longer term, I hope we can help improve libc:
https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html
(I’d like to apply this patch in Guix in the next ‘core-updates’ cycle
anyway to mitigate the problem.)
> Or is this a transitory situation and an acceptable solution is being
> worked on?
This is transitory because sooner or later your host distro will upgrade
to libc 2.22 as well.
IMO Guix is not at fault; rather, it sheds light on a shortcoming of
libc’s handling of locale data, which was designed with single-libc
systems in mind.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-28 9:17 Preparing for the libc/locale upgrade Federico Beffa
2015-09-28 20:45 ` Ludovic Courtès
@ 2015-09-29 14:32 ` Mark H Weaver
2015-09-29 16:12 ` Federico Beffa
2015-10-01 19:57 ` Leo Famulari
1 sibling, 2 replies; 30+ messages in thread
From: Mark H Weaver @ 2015-09-29 14:32 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> writes:
> ludo@gnu.org (Ludovic Courtès) writes:
>
> [...]
>
>> Consequences for Guix on foreign distros:
>>
>> • If the host distro provides binaries that use libc < 2.22 and you
>> use a mixture of Guix-provided and distro-provided programs, this is
>> pretty bad.
>>
>> Solution: unset LOCPATH and say goodbye to locales for Guix-provided
>> packages (setting LOCPATH=$HOME/.guix-profile/lib/locale would break
>> all the distro-provided programs), or use exclusively Guix-provided
>> programs, or use the “C” locale.
>
> Does this means that Guix on other distributions is no longer of
> interest to the Guix project and it is essentially unsupported?
>
> Or is this a transitory situation and an acceptable solution is being
> worked on?
I think I know a workaround: leave LOCPATH unset, and make
/run/current-system/locale a symlink to freshly generated locales for
glibc 2.22. Guix-compiled software is configured to look for locales
there if LOCPATH is unset.
Mark
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-29 14:32 ` Mark H Weaver
@ 2015-09-29 16:12 ` Federico Beffa
2015-10-01 19:57 ` Leo Famulari
1 sibling, 0 replies; 30+ messages in thread
From: Federico Beffa @ 2015-09-29 16:12 UTC (permalink / raw)
To: Mark H Weaver; +Cc: Guix-devel
On Tue, Sep 29, 2015 at 4:32 PM, Mark H Weaver <mhw@netris.org> wrote:
> Federico Beffa <beffa@ieee.org> writes:
>
>> ludo@gnu.org (Ludovic Courtès) writes:
>>
>> [...]
>>
>>> Consequences for Guix on foreign distros:
>>>
>>> • If the host distro provides binaries that use libc < 2.22 and you
>>> use a mixture of Guix-provided and distro-provided programs, this is
>>> pretty bad.
>>>
>>> Solution: unset LOCPATH and say goodbye to locales for Guix-provided
>>> packages (setting LOCPATH=$HOME/.guix-profile/lib/locale would break
>>> all the distro-provided programs), or use exclusively Guix-provided
>>> programs, or use the “C” locale.
>>
>> Does this means that Guix on other distributions is no longer of
>> interest to the Guix project and it is essentially unsupported?
>>
>> Or is this a transitory situation and an acceptable solution is being
>> worked on?
>
> I think I know a workaround: leave LOCPATH unset, and make
> /run/current-system/locale a symlink to freshly generated locales for
> glibc 2.22. Guix-compiled software is configured to look for locales
> there if LOCPATH is unset.
That's a promising trick.
Thanks!
Fede
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-28 20:45 ` Ludovic Courtès
@ 2015-09-30 12:35 ` Federico Beffa
2015-09-30 13:46 ` Ludovic Courtès
2015-10-01 7:02 ` Preparing for the libc/locale upgrade Konrad Hinsen
0 siblings, 2 replies; 30+ messages in thread
From: Federico Beffa @ 2015-09-30 12:35 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
On Mon, Sep 28, 2015 at 10:45 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Federico Beffa <beffa@ieee.org> skribis:
>
>> ludo@gnu.org (Ludovic Courtès) writes:
>>
>> [...]
>>
>>> Consequences for Guix on foreign distros:
>>>
>>> • If the host distro provides binaries that use libc < 2.22 and you
>>> use a mixture of Guix-provided and distro-provided programs, this is
>>> pretty bad.
>>>
>>> Solution: unset LOCPATH and say goodbye to locales for Guix-provided
>>> packages (setting LOCPATH=$HOME/.guix-profile/lib/locale would break
>>> all the distro-provided programs), or use exclusively Guix-provided
>>> programs, or use the “C” locale.
>>
>> Does this means that Guix on other distributions is no longer of
>> interest to the Guix project and it is essentially unsupported?
>
> No, definitely not!
>
Thats good to hear!
> While suboptimal, the 3 solutions above are probably OK as a temporary
> measure.
From my point of view Mark's suggestion sounds as the most acceptable
(although I've not tested it as I've not updated my Guix yet).
>
> For the longer term, I hope we can help improve libc:
>
> https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html
>
> (I’d like to apply this patch in Guix in the next ‘core-updates’ cycle
> anyway to mitigate the problem.)
>
>> Or is this a transitory situation and an acceptable solution is being
>> worked on?
>
> This is transitory because sooner or later your host distro will upgrade
> to libc 2.22 as well.
Sure, but popular distributions like Debian are likely to upgrade in a
few of years! So, without action the problem is not going away any
time soon.
>
> IMO Guix is not at fault; rather, it sheds light on a shortcoming of
> libc’s handling of locale data, which was designed with single-libc
> systems in mind.
I fully agree with your statement. However, leaving Guix users (I'm
not talking about developers) exposed to such problems is not what I
expect from a high quality product. A brute force fix may be to tell
each Guix program where the locale is with a wrapper. This is for sure
not elegant (and there may be better ways, you know better...), but
the point is that probably a way to preserve a good end user
experience out of the box does exist and, from my point of view, we
should provide it. The first experience is very important to retain
users. If it's bad most people just walk away.
Regards,
Fede
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-30 12:35 ` Federico Beffa
@ 2015-09-30 13:46 ` Ludovic Courtès
2015-09-30 15:53 ` Federico Beffa
2015-10-01 7:02 ` Preparing for the libc/locale upgrade Konrad Hinsen
1 sibling, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2015-09-30 13:46 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> On Mon, Sep 28, 2015 at 10:45 PM, Ludovic Courtès <ludo@gnu.org> wrote:
[...]
> From my point of view Mark's suggestion sounds as the most acceptable
Which one is it?
>> IMO Guix is not at fault; rather, it sheds light on a shortcoming of
>> libc’s handling of locale data, which was designed with single-libc
>> systems in mind.
>
> I fully agree with your statement. However, leaving Guix users (I'm
> not talking about developers) exposed to such problems is not what I
> expect from a high quality product.
I agree.
> A brute force fix may be to tell each Guix program where the locale is
> with a wrapper. This is for sure not elegant (and there may be better
> ways, you know better...), but the point is that probably a way to
> preserve a good end user experience out of the box does exist and,
> from my point of view, we should provide it.
Well, we could ship 110+ MiB of locales along with our libc, as we used
to do¹; adding a wrapper basically amounts to this. That way, no need
to fiddle with LOCPATH, the right locale data will always be found.
But honestly, I think that sucks. It shouldn’t be all-or-nothing.
Alternately, we could patch our libc to honor GUIX_LOCPATH (in addition
to LOCPATH), so that the host distro’s programs are unaffected, and thus
don’t end up aborting with that assertion failure.
That’s the best kludge that comes to mind (yeah that’s an oxymoron ;-)).
Thoughts?
Thanks,
Ludo’.
¹ http://bugs.gnu.org/18085
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-30 13:46 ` Ludovic Courtès
@ 2015-09-30 15:53 ` Federico Beffa
2015-10-01 21:58 ` [PATCH 0/2] Avoiding incompatible locale data in LOCPATH Ludovic Courtès
` (2 more replies)
0 siblings, 3 replies; 30+ messages in thread
From: Federico Beffa @ 2015-09-30 15:53 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
On Wed, Sep 30, 2015 at 3:46 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Federico Beffa <beffa@ieee.org> skribis:
>
>> On Mon, Sep 28, 2015 at 10:45 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>
> [...]
>
>> From my point of view Mark's suggestion sounds as the most acceptable
>
> Which one is it?
For some reason I don't see Mark's message on the ML. So instead of a
link, a copy/paste from his email:
"
I think I know a workaround: leave LOCPATH unset, and make
/run/current-system/locale a symlink to freshly generated locales for
glibc 2.22. Guix-compiled software is configured to look for locales
there if LOCPATH is unset.
"
>
>>> IMO Guix is not at fault; rather, it sheds light on a shortcoming of
>>> libc’s handling of locale data, which was designed with single-libc
>>> systems in mind.
>>
>> I fully agree with your statement. However, leaving Guix users (I'm
>> not talking about developers) exposed to such problems is not what I
>> expect from a high quality product.
>
> I agree.
>
>> A brute force fix may be to tell each Guix program where the locale is
>> with a wrapper. This is for sure not elegant (and there may be better
>> ways, you know better...), but the point is that probably a way to
>> preserve a good end user experience out of the box does exist and,
>> from my point of view, we should provide it.
>
> Well, we could ship 110+ MiB of locales along with our libc, as we used
> to do¹; adding a wrapper basically amounts to this. That way, no need
> to fiddle with LOCPATH, the right locale data will always be found.
>
> But honestly, I think that sucks. It shouldn’t be all-or-nothing.
>
> Alternately, we could patch our libc to honor GUIX_LOCPATH (in addition
> to LOCPATH), so that the host distro’s programs are unaffected, and thus
> don’t end up aborting with that assertion failure.
>
> That’s the best kludge that comes to mind (yeah that’s an oxymoron ;-)).
From my point of view either one is much better than the current situation.
Thanks,
Fede
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-30 12:35 ` Federico Beffa
2015-09-30 13:46 ` Ludovic Courtès
@ 2015-10-01 7:02 ` Konrad Hinsen
1 sibling, 0 replies; 30+ messages in thread
From: Konrad Hinsen @ 2015-10-01 7:02 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
On 30/09/2015 14:35, Federico Beffa wrote:
> From my point of view Mark's suggestion sounds as the most acceptable
> (although I've not tested it as I've not updated my Guix yet).
I just tested it, it works fine. And, finally, no more error messages
about missing locales anywhere!
Konrad.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-09-29 14:32 ` Mark H Weaver
2015-09-29 16:12 ` Federico Beffa
@ 2015-10-01 19:57 ` Leo Famulari
2015-10-01 20:36 ` Taylan Ulrich Bayırlı/Kammer
1 sibling, 1 reply; 30+ messages in thread
From: Leo Famulari @ 2015-10-01 19:57 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel
Just want to confirm I'm doing your workaround properly... like this?
$ ln -s gnu/store/...-glibc-utf8-locales-2.22/lib/locale
/run/current-system/locale
$ echo $LOCPATH
The previous line is blank, showing that $LOCPATH is unset.
On Tue, Sep 29, 2015, at 10:32, Mark H Weaver wrote:
> Federico Beffa <beffa@ieee.org> writes:
>
> > ludo@gnu.org (Ludovic Courtès) writes:
> >
> > [...]
> >
> >> Consequences for Guix on foreign distros:
> >>
> >> • If the host distro provides binaries that use libc < 2.22 and you
> >> use a mixture of Guix-provided and distro-provided programs, this is
> >> pretty bad.
> >>
> >> Solution: unset LOCPATH and say goodbye to locales for Guix-provided
> >> packages (setting LOCPATH=$HOME/.guix-profile/lib/locale would break
> >> all the distro-provided programs), or use exclusively Guix-provided
> >> programs, or use the “C” locale.
> >
> > Does this means that Guix on other distributions is no longer of
> > interest to the Guix project and it is essentially unsupported?
> >
> > Or is this a transitory situation and an acceptable solution is being
> > worked on?
>
> I think I know a workaround: leave LOCPATH unset, and make
> /run/current-system/locale a symlink to freshly generated locales for
> glibc 2.22. Guix-compiled software is configured to look for locales
> there if LOCPATH is unset.
>
> Mark
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: Preparing for the libc/locale upgrade
2015-10-01 19:57 ` Leo Famulari
@ 2015-10-01 20:36 ` Taylan Ulrich Bayırlı/Kammer
0 siblings, 0 replies; 30+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2015-10-01 20:36 UTC (permalink / raw)
To: Leo Famulari; +Cc: guix-devel
Leo Famulari <leo@famulari.name> writes:
> Just want to confirm I'm doing your workaround properly... like this?
> $ ln -s gnu/store/...-glibc-utf8-locales-2.22/lib/locale
> /run/current-system/locale
> $ echo $LOCPATH
>
> The previous line is blank, showing that $LOCPATH is unset.
I think that would leave you with a dangling symlink when that
/gnu/store item gets garbage collected. (You also forgot the first
slash.)
The following might be preferable:
guix package -p /run/current-system/profile -i glibc-locales
ln -s profile/lib/locale /run/current-system/locale
Don't know if there's an even better way.
HTH,
Taylan
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-09-30 15:53 ` Federico Beffa
@ 2015-10-01 21:58 ` Ludovic Courtès
2015-10-02 0:06 ` Mark H Weaver
2015-10-04 8:32 ` Ricardo Wurmus
2015-10-01 21:58 ` [PATCH 1/2] gnu: glibc: Honor 'GUIX_LOCPATH' Ludovic Courtès
2015-10-01 21:58 ` [PATCH 2/2] gnu: glibc: Look for locale data in versioned sub-directories Ludovic Courtès
2 siblings, 2 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-01 21:58 UTC (permalink / raw)
To: guix-devel; +Cc: beffa
[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]
So, below are a couple of patches implementing ideas that were discussed here
and on IRC to improve the locale mess.
The first patch adds the 'GUIX_LOCPATH' environment variable, the idea being
that on foreign distros, users could set this variable instead of 'LOCPATH',
and the host distro's programs wouldn't break.
The second patch was suggested by Mark. It basically adds "/2.22" to every
directory name specified in LOCPATH, as well as to the default locale
directory. The idea here is that libc would only stumble on compatible
locale data.
Actually with that second patch, I think 'GUIX_LOCPATH' is unneeded, because
effectively Guix's libc would already be interpreting 'LOCPATH' differently.
So my inclination would be to apply only the second one.
Thoughts?
I'd like to get that on 'core-updates' soon so we can quickly get the better
fix.
Thanks,
Ludo'.
Ludovic Courtès (2):
gnu: glibc: Honor 'GUIX_LOCPATH'.
gnu: glibc: Look for locale data in versioned sub-directories.
doc/guix.texi | 23 +++++++----
gnu-system.am | 2 +
gnu/packages/base.scm | 24 ++++++-----
gnu/packages/patches/glibc-guix-locpath.patch | 38 +++++++++++++++++
gnu/packages/patches/glibc-versioned-locpath.patch | 47 ++++++++++++++++++++++
5 files changed, 116 insertions(+), 18 deletions(-)
create mode 100644 gnu/packages/patches/glibc-guix-locpath.patch
create mode 100644 gnu/packages/patches/glibc-versioned-locpath.patch
--
2.5.0
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 1/2] gnu: glibc: Honor 'GUIX_LOCPATH'.
2015-09-30 15:53 ` Federico Beffa
2015-10-01 21:58 ` [PATCH 0/2] Avoiding incompatible locale data in LOCPATH Ludovic Courtès
@ 2015-10-01 21:58 ` Ludovic Courtès
2015-10-01 21:58 ` [PATCH 2/2] gnu: glibc: Look for locale data in versioned sub-directories Ludovic Courtès
2 siblings, 0 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-01 21:58 UTC (permalink / raw)
To: guix-devel; +Cc: beffa
[-- Attachment #1: Type: text/plain, Size: 703 bytes --]
* gnu/packages/patches/glibc-guix-locpath.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/base.scm (glibc)[source]: Use it.
[native-search-paths]: Use 'GUIX_LOCPATH' instead of 'LOCPATH'.
* doc/guix.texi (Application Setup): Introduce the term "foreign
distro". Document 'GUIX_LOCPATH'.
---
doc/guix.texi | 23 +++++++++++-----
gnu-system.am | 1 +
gnu/packages/base.scm | 7 +++--
gnu/packages/patches/glibc-guix-locpath.patch | 38 +++++++++++++++++++++++++++
4 files changed, 60 insertions(+), 9 deletions(-)
create mode 100644 gnu/packages/patches/glibc-guix-locpath.patch
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-glibc-Honor-GUIX_LOCPATH.patch --]
[-- Type: text/x-patch; name="0001-gnu-glibc-Honor-GUIX_LOCPATH.patch", Size: 5372 bytes --]
diff --git a/doc/guix.texi b/doc/guix.texi
index 68ee451..1ad4229 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -933,24 +933,24 @@ daemons on the same machine.
@node Application Setup
@section Application Setup
-When using Guix on top of GNU/Linux distribution other than GuixSD, a
-few additional steps are needed to get everything in place. Here are
-some of them.
+When using Guix on top of GNU/Linux distribution other than GuixSD---a
+so-called @dfn{foreign distro}---a few additional steps are needed to
+get everything in place. Here are some of them.
@subsection Locales
@anchor{locales-and-locpath}
@cindex locales, when not on GuixSD
@vindex LOCPATH
+@vindex GUIX_LOCPATH
Packages installed @i{via} Guix will not use the host system's locale
data. Instead, you must first install one of the locale packages
-available with Guix and then define the @code{LOCPATH} environment
-variable (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library
-Reference Manual}):
+available with Guix and then define the @code{GUIX_LOCPATH} environment
+variable:
@example
$ guix package -i glibc-locales
-$ export LOCPATH=$HOME/.guix-profile/lib/locale
+$ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
@end example
Note that the @code{glibc-locales} package contains data for all the
@@ -958,6 +958,15 @@ locales supported by the GNU@tie{}libc and weighs in at around
110@tie{}MiB. Alternately, the @code{glibc-utf8-locales} is smaller but
limited to a few UTF-8 locales.
+The @code{GUIX_LOCPATH} variable plays the exact same role as
+@code{LOCPATH} (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C
+Library Reference Manual}). However, since it is honored only by Guix's
+libc, and not by the libc provided by foreign distros, using
+@code{GUIX_LOCPATH} allows you to make sure the the foreign distro's
+programs will not end up loading incompatible locale data. This is
+important because the locale data format used by different libc versions
+may be incompatible.
+
@subsection X11 Fonts
The majority of graphical applications use Fontconfig to locate and
diff --git a/gnu-system.am b/gnu-system.am
index f2f7e17..aba8f8d 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -469,6 +469,7 @@ dist_patch_DATA = \
gnu/packages/patches/glib-tests-timer.patch \
gnu/packages/patches/glib-tests-gapplication.patch \
gnu/packages/patches/glibc-bootstrap-system.patch \
+ gnu/packages/patches/glibc-guix-locpath.patch \
gnu/packages/patches/glibc-ldd-x86_64.patch \
gnu/packages/patches/glibc-locales.patch \
gnu/packages/patches/glibc-o-largefile.patch \
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index a7d9459..337fdae 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -476,6 +476,7 @@ store.")
(modules '((guix build utils)))
(patches (map search-patch
'("glibc-ldd-x86_64.patch"
+ "glibc-guix-locpath.patch"
"glibc-o-largefile.patch")))))
(build-system gnu-build-system)
@@ -606,9 +607,11 @@ store.")
(native-search-paths
;; Search path for packages that provide locale data. This is useful
- ;; primarily in build environments.
+ ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
+ ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
+ ;; distros.
(list (search-path-specification
- (variable "LOCPATH")
+ (variable "GUIX_LOCPATH")
(files '("lib/locale")))))
(synopsis "The GNU C Library")
diff --git a/gnu/packages/patches/glibc-guix-locpath.patch b/gnu/packages/patches/glibc-guix-locpath.patch
new file mode 100644
index 0000000..2a814a3
--- /dev/null
+++ b/gnu/packages/patches/glibc-guix-locpath.patch
@@ -0,0 +1,38 @@
+Honor a special 'GUIX_LOCPATH' environment variable.
+
+This is most useful when using Guix on top of another distro, which uses an
+different libc version with incompatible locale data. In this case, setting
+'GUIX_LOCPATH' rather than 'LOCPATH' allows users to tell Guix's libc where to
+look for its locale data without breaking programs that use the other libc.
+
+See <https://lists.gnu.org/archive/html/guix-devel/2015-09/msg00717.html> for
+some background information.
+
+--- a/locale/newlocale.c
++++ b/locale/newlocale.c
+@@ -102,7 +102,9 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
+ locale_path = NULL;
+ locale_path_len = 0;
+
+- locpath_var = getenv ("LOCPATH");
++ locpath_var = getenv ("GUIX_LOCPATH");
++ if (locpath_var == NULL || locpath_var[0] == '\0')
++ locpath_var = getenv ("LOCPATH");
+ if (locpath_var != NULL && locpath_var[0] != '\0')
+ {
+ if (__argz_create_sep (locpath_var, ':',
+diff --git a/locale/setlocale.c b/locale/setlocale.c
+index ead030d..ca2337d 100644
+--- a/locale/setlocale.c
++++ b/locale/setlocale.c
+@@ -251,7 +251,9 @@ setlocale (int category, const char *locale)
+ locale_path = NULL;
+ locale_path_len = 0;
+
+- locpath_var = getenv ("LOCPATH");
++ locpath_var = getenv ("GUIX_LOCPATH");
++ if (locpath_var == NULL || locpath_var[0] == '\0')
++ locpath_var = getenv ("LOCPATH");
+ if (locpath_var != NULL && locpath_var[0] != '\0')
+ {
+ if (__argz_create_sep (locpath_var, ':',
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/2] gnu: glibc: Look for locale data in versioned sub-directories.
2015-09-30 15:53 ` Federico Beffa
2015-10-01 21:58 ` [PATCH 0/2] Avoiding incompatible locale data in LOCPATH Ludovic Courtès
2015-10-01 21:58 ` [PATCH 1/2] gnu: glibc: Honor 'GUIX_LOCPATH' Ludovic Courtès
@ 2015-10-01 21:58 ` Ludovic Courtès
2 siblings, 0 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-01 21:58 UTC (permalink / raw)
To: guix-devel; +Cc: beffa
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
* gnu/packages/patches/glibc-versioned-locpath.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/base.scm (glibc)[source]: Use it.
[arguments]: Remove explicit version sub-directory from
libc_cv_localedir.
(glibc-locales, glibc-utf8-locales): Write to a VERSION
sub-directory.
---
gnu-system.am | 1 +
gnu/packages/base.scm | 17 ++++----
gnu/packages/patches/glibc-versioned-locpath.patch | 47 ++++++++++++++++++++++
3 files changed, 56 insertions(+), 9 deletions(-)
create mode 100644 gnu/packages/patches/glibc-versioned-locpath.patch
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-gnu-glibc-Look-for-locale-data-in-versioned-sub-dire.patch --]
[-- Type: text/x-patch; name="0002-gnu-glibc-Look-for-locale-data-in-versioned-sub-dire.patch", Size: 5463 bytes --]
diff --git a/gnu-system.am b/gnu-system.am
index aba8f8d..3aa9144 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -473,6 +473,7 @@ dist_patch_DATA = \
gnu/packages/patches/glibc-ldd-x86_64.patch \
gnu/packages/patches/glibc-locales.patch \
gnu/packages/patches/glibc-o-largefile.patch \
+ gnu/packages/patches/glibc-versioned-locpath.patch \
gnu/packages/patches/gmp-arm-asm-nothumb.patch \
gnu/packages/patches/gnucash-price-quotes-perl.patch \
gnu/packages/patches/gnutls-doc-fix.patch \
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 337fdae..443c54e 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -477,6 +477,7 @@ store.")
(patches (map search-patch
'("glibc-ldd-x86_64.patch"
"glibc-guix-locpath.patch"
+ "glibc-versioned-locpath.patch"
"glibc-o-largefile.patch")))))
(build-system gnu-build-system)
@@ -510,16 +511,12 @@ store.")
;; Set the default locale path. In practice, $LOCPATH may be
;; defined to point whatever locales users want. However, setuid
;; binaries don't honor $LOCPATH, so they'll instead look into
- ;; $libc_cv_localedir; we choose /run/current-system/locale/X.Y,
+ ;; $libc_cv_localedir; we choose /run/current-system/locale
;; with the idea that it is going to be populated by the sysadmin.
- ;; The "X.Y" sub-directory is because locale data formats are
- ;; incompatible across libc versions; see
- ;; <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
;;
;; `--localedir' is not honored, so work around it.
;; See <http://sourceware.org/ml/libc-alpha/2013-03/msg00093.html>.
- (string-append "libc_cv_localedir=/run/current-system/locale/"
- ,version)
+ "libc_cv_localedir=/run/current-system/locale"
(string-append "--with-headers="
(assoc-ref %build-inputs "linux-headers")
@@ -655,7 +652,8 @@ the 'share/locale' sub-directory of this package.")
;; Use $(libdir)/locale as is the case by default.
(list (string-append "libc_cv_localedir="
(assoc-ref %outputs "out")
- "/lib/locale")))))))))
+ "/lib/locale/"
+ ,(package-version glibc))))))))))
(define-public glibc-utf8-locales
(package
@@ -664,7 +662,7 @@ the 'share/locale' sub-directory of this package.")
(source #f)
(build-system trivial-build-system)
(arguments
- '(#:modules ((guix build utils))
+ `(#:modules ((guix build utils))
#:builder (begin
(use-modules (srfi srfi-1)
(guix build utils))
@@ -672,7 +670,8 @@ the 'share/locale' sub-directory of this package.")
(let* ((libc (assoc-ref %build-inputs "glibc"))
(gzip (assoc-ref %build-inputs "gzip"))
(out (assoc-ref %outputs "out"))
- (localedir (string-append out "/lib/locale")))
+ (localedir (string-append out "/lib/locale/"
+ ,version)))
;; 'localedef' needs 'gzip'.
(setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
diff --git a/gnu/packages/patches/glibc-versioned-locpath.patch b/gnu/packages/patches/glibc-versioned-locpath.patch
new file mode 100644
index 0000000..b643399
--- /dev/null
+++ b/gnu/packages/patches/glibc-versioned-locpath.patch
@@ -0,0 +1,47 @@
+The format of locale data can be incompatible between libc versions, and
+loading incompatible data can lead to 'setlocale' returning EINVAL at best
+or triggering an assertion failure at worst. See
+https://lists.gnu.org/archive/html/guix-devel/2015-09/msg00717.html
+for background information.
+
+To address that, this patch changes libc to look for locale data in
+version-specific sub-directories. So, if LOCPATH=/foo:/bar, locale data
+is searched for in /foo/X.Y and /bar/X.Y, where X.Y is the libc version
+number.
+
+That way, a single 'LOCPATH' setting can work even if different libc versions
+coexist on the system.
+
+--- a/intl/l10nflist.c
++++ b/intl/l10nflist.c
+@@ -25,6 +25,10 @@
+ # include <config.h>
+ #endif
+
++#ifdef _LIBC
++# include <version.h>
++#endif
++
+ #include <string.h>
+
+ #if defined _LIBC || defined HAVE_ARGZ_H
+@@ -164,6 +168,9 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
+
+ /* Allocate room for the full file name. */
+ abs_filename = (char *) malloc (dirlist_len
++#ifdef _LIBC
++ + strlen (VERSION) + 1
++#endif
+ + strlen (language)
+ + ((mask & XPG_TERRITORY) != 0
+ ? strlen (territory) + 1 : 0)
+@@ -185,6 +192,10 @@ _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
+ memcpy (abs_filename, dirlist, dirlist_len);
+ __argz_stringify (abs_filename, dirlist_len, ':');
+ cp = abs_filename + (dirlist_len - 1);
++#ifdef _LIBC
++ *cp++ = '/';
++ cp = stpcpy (cp, VERSION);
++#endif
+ *cp++ = '/';
+ cp = stpcpy (cp, language);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-01 21:58 ` [PATCH 0/2] Avoiding incompatible locale data in LOCPATH Ludovic Courtès
@ 2015-10-02 0:06 ` Mark H Weaver
2015-10-02 16:52 ` Ludovic Courtès
2015-10-04 8:32 ` Ricardo Wurmus
1 sibling, 1 reply; 30+ messages in thread
From: Mark H Weaver @ 2015-10-02 0:06 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel, beffa
Ludovic Courtès <ludo@gnu.org> writes:
> So, below are a couple of patches implementing ideas that were discussed here
> and on IRC to improve the locale mess.
>
> The first patch adds the 'GUIX_LOCPATH' environment variable, the idea being
> that on foreign distros, users could set this variable instead of 'LOCPATH',
> and the host distro's programs wouldn't break.
>
> The second patch was suggested by Mark. It basically adds "/2.22" to every
> directory name specified in LOCPATH, as well as to the default locale
> directory. The idea here is that libc would only stumble on compatible
> locale data.
>
> Actually with that second patch, I think 'GUIX_LOCPATH' is unneeded, because
> effectively Guix's libc would already be interpreting 'LOCPATH' differently.
> So my inclination would be to apply only the second one.
>
> Thoughts?
For compatibility reasons, I think we should add "/2.22" _only_ to the
entries of GUIX_LOCPATH. IMO, it's unwise to change the meaning of
LOCPATH. Some programs, build systems, or user scripts might use
"localedef" in a directory, set LOCPATH to that directory, and expect it
to work.
Mark
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-02 0:06 ` Mark H Weaver
@ 2015-10-02 16:52 ` Ludovic Courtès
2015-10-03 22:20 ` Ludovic Courtès
0 siblings, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-02 16:52 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel, beffa
[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]
Mark H Weaver <mhw@netris.org> skribis:
> For compatibility reasons, I think we should add "/2.22" _only_ to the
> entries of GUIX_LOCPATH. IMO, it's unwise to change the meaning of
> LOCPATH. Some programs, build systems, or user scripts might use
> "localedef" in a directory, set LOCPATH to that directory, and expect it
> to work.
Yes, makes sense. I noticed that the recipe for ‘tre’ relies on
‘LOCPATH’, and I agree that it’s best to keep ‘LOCPATH’ semantics.
So, as discussed on IRC, here’s a second patch that:
• introduces ‘GUIX_LOCPATH’, which is like ‘LOCPATH’, except
versioned;
• keeps ‘LOCPATH’, without appending “/X.Y” to its entries, and giving
it less precedence than ‘GUIX_LOCPATH’;
We would tell people to migrate away from ‘LOCPATH’ in favor of
‘GUIX_LOCPATH’.
I think we should use this patch as a starting point for a discussion
for the libc people. I’d argue that would be acceptable even for
upstream (with s/GUIX_LOCPATH/LOCALE_PATH/ for instance.)
Please review carefully. Ideally I’d like to push this patch or a
variant thereof tomorrow, so we can start the full rebuild.
TIA!
Ludo’.
[-- Attachment #2: the patch --]
[-- Type: text/x-patch, Size: 15025 bytes --]
From 7258d8c6e2a464f911723cabc2e35f7e05c49192 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 1 Oct 2015 21:32:50 +0200
Subject: [PATCH] gnu: glibc: Look for locale data in versioned
sub-directories.
* gnu/packages/patches/glibc-versioned-locpath.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/base.scm (glibc)[source]: Use it.
[arguments]: Add explicit version sub-directory to
libc_cv_localedir.
[native-search-paths]: Use 'GUIX_LOCPATH' instead of 'LOCPATH'.
(glibc-locales, glibc-utf8-locales): Write to a VERSION
sub-directory.
---
doc/guix.texi | 23 +-
gnu-system.am | 1 +
gnu/packages/base.scm | 17 +-
gnu/packages/patches/glibc-versioned-locpath.patch | 240 +++++++++++++++++++++
4 files changed, 268 insertions(+), 13 deletions(-)
create mode 100644 gnu/packages/patches/glibc-versioned-locpath.patch
diff --git a/doc/guix.texi b/doc/guix.texi
index 68ee451..1ad4229 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -933,24 +933,24 @@ daemons on the same machine.
@node Application Setup
@section Application Setup
-When using Guix on top of GNU/Linux distribution other than GuixSD, a
-few additional steps are needed to get everything in place. Here are
-some of them.
+When using Guix on top of GNU/Linux distribution other than GuixSD---a
+so-called @dfn{foreign distro}---a few additional steps are needed to
+get everything in place. Here are some of them.
@subsection Locales
@anchor{locales-and-locpath}
@cindex locales, when not on GuixSD
@vindex LOCPATH
+@vindex GUIX_LOCPATH
Packages installed @i{via} Guix will not use the host system's locale
data. Instead, you must first install one of the locale packages
-available with Guix and then define the @code{LOCPATH} environment
-variable (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library
-Reference Manual}):
+available with Guix and then define the @code{GUIX_LOCPATH} environment
+variable:
@example
$ guix package -i glibc-locales
-$ export LOCPATH=$HOME/.guix-profile/lib/locale
+$ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
@end example
Note that the @code{glibc-locales} package contains data for all the
@@ -958,6 +958,15 @@ locales supported by the GNU@tie{}libc and weighs in at around
110@tie{}MiB. Alternately, the @code{glibc-utf8-locales} is smaller but
limited to a few UTF-8 locales.
+The @code{GUIX_LOCPATH} variable plays the exact same role as
+@code{LOCPATH} (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C
+Library Reference Manual}). However, since it is honored only by Guix's
+libc, and not by the libc provided by foreign distros, using
+@code{GUIX_LOCPATH} allows you to make sure the the foreign distro's
+programs will not end up loading incompatible locale data. This is
+important because the locale data format used by different libc versions
+may be incompatible.
+
@subsection X11 Fonts
The majority of graphical applications use Fontconfig to locate and
diff --git a/gnu-system.am b/gnu-system.am
index f2f7e17..571e660 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -472,6 +472,7 @@ dist_patch_DATA = \
gnu/packages/patches/glibc-ldd-x86_64.patch \
gnu/packages/patches/glibc-locales.patch \
gnu/packages/patches/glibc-o-largefile.patch \
+ gnu/packages/patches/glibc-versioned-locpath.patch \
gnu/packages/patches/gmp-arm-asm-nothumb.patch \
gnu/packages/patches/gnucash-price-quotes-perl.patch \
gnu/packages/patches/gnutls-doc-fix.patch \
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index a7d9459..1402a44 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -476,6 +476,7 @@ store.")
(modules '((guix build utils)))
(patches (map search-patch
'("glibc-ldd-x86_64.patch"
+ "glibc-versioned-locpath.patch"
"glibc-o-largefile.patch")))))
(build-system gnu-build-system)
@@ -606,9 +607,11 @@ store.")
(native-search-paths
;; Search path for packages that provide locale data. This is useful
- ;; primarily in build environments.
+ ;; primarily in build environments. Use 'GUIX_LOCPATH' rather than
+ ;; 'LOCPATH' to avoid interference with the host system's libc on foreign
+ ;; distros.
(list (search-path-specification
- (variable "LOCPATH")
+ (variable "GUIX_LOCPATH")
(files '("lib/locale")))))
(synopsis "The GNU C Library")
@@ -649,10 +652,11 @@ the 'share/locale' sub-directory of this package.")
(alist-delete 'install ,phases)))
((#:configure-flags flags)
`(append ,flags
- ;; Use $(libdir)/locale as is the case by default.
+ ;; Use $(libdir)/locale/X.Y as is the case by default.
(list (string-append "libc_cv_localedir="
(assoc-ref %outputs "out")
- "/lib/locale")))))))))
+ "/lib/locale/"
+ ,(package-version glibc))))))))))
(define-public glibc-utf8-locales
(package
@@ -661,7 +665,7 @@ the 'share/locale' sub-directory of this package.")
(source #f)
(build-system trivial-build-system)
(arguments
- '(#:modules ((guix build utils))
+ `(#:modules ((guix build utils))
#:builder (begin
(use-modules (srfi srfi-1)
(guix build utils))
@@ -669,7 +673,8 @@ the 'share/locale' sub-directory of this package.")
(let* ((libc (assoc-ref %build-inputs "glibc"))
(gzip (assoc-ref %build-inputs "gzip"))
(out (assoc-ref %outputs "out"))
- (localedir (string-append out "/lib/locale")))
+ (localedir (string-append out "/lib/locale/"
+ ,version)))
;; 'localedef' needs 'gzip'.
(setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
diff --git a/gnu/packages/patches/glibc-versioned-locpath.patch b/gnu/packages/patches/glibc-versioned-locpath.patch
new file mode 100644
index 0000000..bc76521
--- /dev/null
+++ b/gnu/packages/patches/glibc-versioned-locpath.patch
@@ -0,0 +1,240 @@
+The format of locale data can be incompatible between libc versions, and
+loading incompatible data can lead to 'setlocale' returning EINVAL at best
+or triggering an assertion failure at worst. See
+https://lists.gnu.org/archive/html/guix-devel/2015-09/msg00717.html
+for background information.
+
+To address that, this patch changes libc to honor a new 'GUIX_LOCPATH'
+variable, and to look for locale data in version-specific sub-directories of
+that variable. So, if GUIX_LOCPATH=/foo:/bar, locale data is searched for in
+/foo/X.Y and /bar/X.Y, where X.Y is the libc version number.
+
+That way, a single 'GUIX_LOCPATH' setting can work even if different libc
+versions coexist on the system.
+
+--- a/locale/newlocale.c
++++ b/locale/newlocale.c
+@@ -30,6 +30,7 @@
+ /* Lock for protecting global data. */
+ __libc_rwlock_define (extern , __libc_setlocale_lock attribute_hidden)
+
++extern error_t compute_locale_search_path (char **, size_t *);
+
+ /* Use this when we come along an error. */
+ #define ERROR_RETURN \
+@@ -48,7 +49,6 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
+ __locale_t result_ptr;
+ char *locale_path;
+ size_t locale_path_len;
+- const char *locpath_var;
+ int cnt;
+ size_t names_len;
+
+@@ -102,17 +102,8 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
+ locale_path = NULL;
+ locale_path_len = 0;
+
+- locpath_var = getenv ("LOCPATH");
+- if (locpath_var != NULL && locpath_var[0] != '\0')
+- {
+- if (__argz_create_sep (locpath_var, ':',
+- &locale_path, &locale_path_len) != 0)
+- return NULL;
+-
+- if (__argz_add_sep (&locale_path, &locale_path_len,
+- _nl_default_locale_path, ':') != 0)
+- return NULL;
+- }
++ if (compute_locale_search_path (&locale_path, &locale_path_len) != 0)
++ return NULL;
+
+ /* Get the names for the locales we are interested in. We either
+ allow a composite name or a single name. */
+diff --git a/locale/setlocale.c b/locale/setlocale.c
+index ead030d..0c0e314 100644
+--- a/locale/setlocale.c
++++ b/locale/setlocale.c
+@@ -215,12 +215,65 @@ setdata (int category, struct __locale_data *data)
+ }
+ }
+
++/* Return in *LOCALE_PATH and *LOCALE_PATH_LEN the locale data search path as
++ a colon-separated list. Return ENOMEN on error, zero otherwise. */
++error_t
++compute_locale_search_path (char **locale_path, size_t *locale_path_len)
++{
++ char* guix_locpath_var = getenv ("GUIX_LOCPATH");
++ char *locpath_var = getenv ("LOCPATH");
++
++ if (guix_locpath_var != NULL && guix_locpath_var[0] != '\0')
++ {
++ /* Entries in 'GUIX_LOCPATH' take precedence over 'LOCPATH'. These
++ entries are systematically prefixed with "/X.Y" where "X.Y" is the
++ libc version. */
++ if (__argz_create_sep (guix_locpath_var, ':',
++ locale_path, locale_path_len) != 0
++ || __argz_suffix_entries (locale_path, locale_path_len,
++ "/" VERSION) != 0)
++ goto bail_out;
++ }
++
++ if (locpath_var != NULL && locpath_var[0] != '\0')
++ {
++ char *reg_locale_path = NULL;
++ size_t reg_locale_path_len = 0;
++
++ if (__argz_create_sep (locpath_var, ':',
++ ®_locale_path, ®_locale_path_len) != 0)
++ goto bail_out;
++
++ if (__argz_append (locale_path, locale_path_len,
++ reg_locale_path, reg_locale_path_len) != 0)
++ goto bail_out;
++
++ free (reg_locale_path);
++ }
++
++ if (*locale_path != NULL)
++ {
++ /* Append the system default locale directory. */
++ if (__argz_add_sep (locale_path, locale_path_len,
++ _nl_default_locale_path, ':') != 0)
++ goto bail_out;
++ }
++
++ return 0;
++
++ bail_out:
++ free (*locale_path);
++ *locale_path = NULL;
++ *locale_path_len = 0;
++
++ return ENOMEM;
++}
++
+ char *
+ setlocale (int category, const char *locale)
+ {
+ char *locale_path;
+ size_t locale_path_len;
+- const char *locpath_var;
+ char *composite;
+
+ /* Sanity check for CATEGORY argument. */
+@@ -251,17 +304,10 @@ setlocale (int category, const char *locale)
+ locale_path = NULL;
+ locale_path_len = 0;
+
+- locpath_var = getenv ("LOCPATH");
+- if (locpath_var != NULL && locpath_var[0] != '\0')
++ if (compute_locale_search_path (&locale_path, &locale_path_len) != 0)
+ {
+- if (__argz_create_sep (locpath_var, ':',
+- &locale_path, &locale_path_len) != 0
+- || __argz_add_sep (&locale_path, &locale_path_len,
+- _nl_default_locale_path, ':') != 0)
+- {
+- __libc_rwlock_unlock (__libc_setlocale_lock);
+- return NULL;
+- }
++ __libc_rwlock_unlock (__libc_setlocale_lock);
++ return NULL;
+ }
+
+ if (category == LC_ALL)
+diff --git a/string/Makefile b/string/Makefile
+index 8424a61..f925503 100644
+--- a/string/Makefile
++++ b/string/Makefile
+@@ -38,7 +38,7 @@ routines := strcat strchr strcmp strcoll strcpy strcspn \
+ swab strfry memfrob memmem rawmemchr strchrnul \
+ $(addprefix argz-,append count create ctsep next \
+ delete extract insert stringify \
+- addsep replace) \
++ addsep replace suffix) \
+ envz basename \
+ strcoll_l strxfrm_l string-inlines memrchr \
+ xpg-strerror strerror_l
+diff --git a/string/argz-suffix.c b/string/argz-suffix.c
+new file mode 100644
+index 0000000..505b0f2
+--- /dev/null
++++ b/string/argz-suffix.c
+@@ -0,0 +1,56 @@
++/* Copyright (C) 2015 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++ Contributed by Ludovic Courtès <ludo@gnu.org>.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Lesser General Public
++ License as published by the Free Software Foundation; either
++ version 2.1 of the License, or (at your option) any later version.
++
++ The GNU C Library 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
++ Lesser General Public License for more details.
++
++ You should have received a copy of the GNU Lesser General Public
++ License along with the GNU C Library; if not, see
++ <http://www.gnu.org/licenses/>. */
++
++#include <argz.h>
++#include <errno.h>
++#include <stdlib.h>
++#include <string.h>
++
++
++error_t
++__argz_suffix_entries (char **argz, size_t *argz_len, const char *suffix)
++
++{
++ size_t suffix_len = strlen (suffix);
++ size_t count = __argz_count (*argz, *argz_len);
++ size_t new_argz_len = *argz_len + count * suffix_len;
++ char *new_argz = malloc (new_argz_len);
++
++ if (new_argz)
++ {
++ char *p = new_argz, *entry;
++
++ for (entry = *argz;
++ entry != NULL;
++ entry = argz_next (*argz, *argz_len, entry))
++ {
++ p = stpcpy (p, entry);
++ p = stpcpy (p, suffix);
++ p++;
++ }
++
++ free (*argz);
++ *argz = new_argz;
++ *argz_len = new_argz_len;
++
++ return 0;
++ }
++ else
++ return ENOMEM;
++}
++weak_alias (__argz_suffix_entries, argz_suffix_entries)
+diff --git a/string/argz.h b/string/argz.h
+index bb62a31..d276a35 100644
+--- a/string/argz.h
++++ b/string/argz.h
+@@ -134,6 +134,16 @@ extern error_t argz_replace (char **__restrict __argz,
+ const char *__restrict __str,
+ const char *__restrict __with,
+ unsigned int *__restrict __replace_count);
++
++/* Suffix each entry of ARGZ & ARGZ_LEN with SUFFIX. Return 0 on success,
++ and ENOMEN if memory cannot be allocated. */
++extern error_t __argz_suffix_entries (char **__restrict __argz,
++ size_t *__restrict __argz_len,
++ const char *__restrict __suffix);
++extern error_t argz_suffix_entries (char **__restrict __argz,
++ size_t *__restrict __argz_len,
++ const char *__restrict __suffix);
++
+ \f
+ /* Returns the next entry in ARGZ & ARGZ_LEN after ENTRY, or NULL if there
+ are no more. If entry is NULL, then the first entry is returned. This
--
2.5.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-02 16:52 ` Ludovic Courtès
@ 2015-10-03 22:20 ` Ludovic Courtès
2015-10-03 22:56 ` Daniel Pimentel
2015-10-04 17:04 ` Mark H Weaver
0 siblings, 2 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-03 22:20 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel, beffa
After a lot more thought, I changed my mind.
I realized that with the patch at
<https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>, it’s OK to
have, say,
LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
That way, programs will pick locale data that is compatible; so a 2.23
program might pick most of its locale data from the /2.22 directory (if
they are compatible), and some of them from /2.23 (if the format has
changed.)
We still need ‘GUIX_LOCPATH’ to avoid the assertion failure with older
libcs, only without the complicated semantics discussed yesterday.
The result is in ‘core-updates’:
b6ac545 * gnu: commencement: Remove the tricky locale compatibility handling.
f2d7bbb * gnu: glibc: Look for locale data in versioned sub-directories.
fbb909a * gnu: glibc: Honor 'GUIX_LOCPATH'.
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-03 22:20 ` Ludovic Courtès
@ 2015-10-03 22:56 ` Daniel Pimentel
2015-10-04 8:09 ` Ludovic Courtès
2015-10-04 17:04 ` Mark H Weaver
1 sibling, 1 reply; 30+ messages in thread
From: Daniel Pimentel @ 2015-10-03 22:56 UTC (permalink / raw)
To: ludo; +Cc: guix-devel, guix-devel-bounces+d4n1=opmbx.org, beffa
On 2015-10-03 19:20, ludo@gnu.org wrote:
> After a lot more thought, I changed my mind.
>
> I realized that with the patch at
> <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>, it’s OK
> to
> have, say,
>
>
> LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>
> That way, programs will pick locale data that is compatible; so a 2.23
> program might pick most of its locale data from the /2.22 directory (if
> they are compatible), and some of them from /2.23 (if the format has
> changed.)
>
> We still need ‘GUIX_LOCPATH’ to avoid the assertion failure with older
> libcs, only without the complicated semantics discussed yesterday.
>
> The result is in ‘core-updates’:
>
> b6ac545 * gnu: commencement: Remove the tricky locale compatibility
> handling.
> f2d7bbb * gnu: glibc: Look for locale data in versioned
> sub-directories.
> fbb909a * gnu: glibc: Honor 'GUIX_LOCPATH'.
>
> Ludo’.
Thanks!
I added 'export LC_ALL="C"' in my ~.bashrc.
I'll to do upgrade and report it.
--
Daniel Pimentel (d4n1 3:)
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-03 22:56 ` Daniel Pimentel
@ 2015-10-04 8:09 ` Ludovic Courtès
0 siblings, 0 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-04 8:09 UTC (permalink / raw)
To: Daniel Pimentel; +Cc: guix-devel, beffa
Daniel Pimentel <d4n1@openmailbox.org> skribis:
> I added 'export LC_ALL="C"' in my ~.bashrc.
>
> I'll to do upgrade and report it.
With LC_ALL=C, one sidesteps the problem. For real testing, you need to
use LC_ALL=pt_BR.utf8 or something like that.
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-01 21:58 ` [PATCH 0/2] Avoiding incompatible locale data in LOCPATH Ludovic Courtès
2015-10-02 0:06 ` Mark H Weaver
@ 2015-10-04 8:32 ` Ricardo Wurmus
2015-10-04 8:39 ` Ricardo Wurmus
1 sibling, 1 reply; 30+ messages in thread
From: Ricardo Wurmus @ 2015-10-04 8:32 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel, beffa
Ludovic Courtès <ludo@gnu.org> writes:
> The first patch adds the 'GUIX_LOCPATH' environment variable, the idea being
> that on foreign distros, users could set this variable instead of 'LOCPATH',
> and the host distro's programs wouldn't break.
>
> The second patch was suggested by Mark. It basically adds "/2.22" to every
> directory name specified in LOCPATH, as well as to the default locale
> directory. The idea here is that libc would only stumble on compatible
> locale data.
>
> Actually with that second patch, I think 'GUIX_LOCPATH' is unneeded, because
> effectively Guix's libc would already be interpreting 'LOCPATH' differently.
> So my inclination would be to apply only the second one.
I think that ‘GUIX_LOCPATH’ would still be useful for foreign systems
using Guix as a package manager. IIUC, the default location where our
libc looks for locale data is somewhere under ‘/run/current-system’,
which would have to be created on non-GuixSD systems.
If only the LOCPATH patch were applied, users of non-GuixSD systems
would have to make sure that ‘/run/current-system/..../2.22/’ exists and
points to valid locale data. With support for ‘GUIX_LOCPATH’ users of
this system could just install locale data into a profile and set
‘GUIX_LOCPATH’ accordingly without having to additionally manage a
symlink named ‘/run/current-system/.../2.22’.
This is especially useful in shared systems where users would otherwise
have to ask a system administrator to also provide this additional link
so that the Guix libc default lookup location can be satisfied.
But maybe I misunderstood. If so, I’d be happy if you could clarify.
Thanks!
~~ Ricardo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-04 8:32 ` Ricardo Wurmus
@ 2015-10-04 8:39 ` Ricardo Wurmus
2015-10-04 12:32 ` Ludovic Courtès
0 siblings, 1 reply; 30+ messages in thread
From: Ricardo Wurmus @ 2015-10-04 8:39 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel, beffa
Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> writes:
> Ludovic Courtès <ludo@gnu.org> writes:
>
>> The first patch adds the 'GUIX_LOCPATH' environment variable, the idea being
>> that on foreign distros, users could set this variable instead of 'LOCPATH',
>> and the host distro's programs wouldn't break.
>>
>> The second patch was suggested by Mark. It basically adds "/2.22" to every
>> directory name specified in LOCPATH, as well as to the default locale
>> directory. The idea here is that libc would only stumble on compatible
>> locale data.
>>
>> Actually with that second patch, I think 'GUIX_LOCPATH' is unneeded, because
>> effectively Guix's libc would already be interpreting 'LOCPATH' differently.
>> So my inclination would be to apply only the second one.
>
> I think that ‘GUIX_LOCPATH’ would still be useful for foreign systems
> using Guix as a package manager. IIUC, the default location where our
> libc looks for locale data is somewhere under ‘/run/current-system’,
> which would have to be created on non-GuixSD systems.
>
> If only the LOCPATH patch were applied, users of non-GuixSD systems
> would have to make sure that ‘/run/current-system/..../2.22/’ exists and
> points to valid locale data. With support for ‘GUIX_LOCPATH’ users of
> this system could just install locale data into a profile and set
> ‘GUIX_LOCPATH’ accordingly without having to additionally manage a
> symlink named ‘/run/current-system/.../2.22’.
>
> This is especially useful in shared systems where users would otherwise
> have to ask a system administrator to also provide this additional link
> so that the Guix libc default lookup location can be satisfied.
>
> But maybe I misunderstood. If so, I’d be happy if you could clarify.
I just saw your later emails. Please ignore the above.
Thank you and Mark for having figured out a solution!
~~ Ricardo
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-04 8:39 ` Ricardo Wurmus
@ 2015-10-04 12:32 ` Ludovic Courtès
2015-10-04 16:56 ` Mark H Weaver
0 siblings, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-04 12:32 UTC (permalink / raw)
To: Ricardo Wurmus; +Cc: guix-devel, beffa
So with current ‘core-updates’, someone on a “foreign distro” needs to
do:
guix package -i glibc-locales
export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22
Note the extra “/2.22”, which comes from commit f2d7bbb. This is a bit
of an annoyance for end users, but the point is that eventually this
would allow us to recommend things like:
export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
The only question is whether having the “/2.22” prefix by default is a
good idea. Opinions?
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-04 12:32 ` Ludovic Courtès
@ 2015-10-04 16:56 ` Mark H Weaver
2015-10-05 14:35 ` Ludovic Courtès
0 siblings, 1 reply; 30+ messages in thread
From: Mark H Weaver @ 2015-10-04 16:56 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel, beffa
ludo@gnu.org (Ludovic Courtès) writes:
> So with current ‘core-updates’, someone on a “foreign distro” needs to
> do:
>
> guix package -i glibc-locales
> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22
>
> Note the extra “/2.22”, which comes from commit f2d7bbb. This is a bit
> of an annoyance for end users, but the point is that eventually this
> would allow us to recommend things like:
>
> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>
> The only question is whether having the “/2.22” prefix by default is a
> good idea. Opinions?
I think the "/2.22" suffix will be needed to prevent another awkward
transition the next time glibc makes an incompatible change to their
locales. Suppose that 2.23 makes another incompatible change. After
that, many Guix systems will have a mixture of software linked with
glibc-2.22 and glibc-2.23.
One question: when this happens, do we have a mechanism for
automatically setting GUIX_LOCPATH to:
$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
or will that have to be done manually?
Mark
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-03 22:20 ` Ludovic Courtès
2015-10-03 22:56 ` Daniel Pimentel
@ 2015-10-04 17:04 ` Mark H Weaver
2015-10-05 14:38 ` Ludovic Courtès
1 sibling, 1 reply; 30+ messages in thread
From: Mark H Weaver @ 2015-10-04 17:04 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel, beffa
ludo@gnu.org (Ludovic Courtès) writes:
> After a lot more thought, I changed my mind.
>
> I realized that with the patch at
> <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>, it’s OK to
> have, say,
>
> LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>
> That way, programs will pick locale data that is compatible; so a 2.23
> program might pick most of its locale data from the /2.22 directory (if
> they are compatible), and some of them from /2.23 (if the format has
> changed.)
I'm a bit uncomfortable with this. A few questions:
* Will your glibc patch reliably ensure that no functionality is lost
because of picking up the wrong version of locales?
* Do we have a mechanism for automatically setting LOCPATH (or
GUIX_LOCPATH) to include all of the available locale versioned
subdirectories?
Mark
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-04 16:56 ` Mark H Weaver
@ 2015-10-05 14:35 ` Ludovic Courtès
2015-10-05 15:38 ` Federico Beffa
0 siblings, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-05 14:35 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel, beffa
Mark H Weaver <mhw@netris.org> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> So with current ‘core-updates’, someone on a “foreign distro” needs to
>> do:
>>
>> guix package -i glibc-locales
>> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22
>>
>> Note the extra “/2.22”, which comes from commit f2d7bbb. This is a bit
>> of an annoyance for end users, but the point is that eventually this
>> would allow us to recommend things like:
>>
>> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>>
>> The only question is whether having the “/2.22” prefix by default is a
>> good idea. Opinions?
>
> I think the "/2.22" suffix will be needed to prevent another awkward
> transition the next time glibc makes an incompatible change to their
> locales. Suppose that 2.23 makes another incompatible change. After
> that, many Guix systems will have a mixture of software linked with
> glibc-2.22 and glibc-2.23.
Yes. But we could just as well have ‘glibc-utf8-locales’ where
everything is in lib/locale directly, and ‘glibc-transition-locales’
where things are under lib/locale/2.22 and lib/locale/2.23. Dunno.
> One question: when this happens, do we have a mechanism for
> automatically setting GUIX_LOCPATH to:
>
> $HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>
> or will that have to be done manually?
Unless glibc is in the profile, that has to be done manually.
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-04 17:04 ` Mark H Weaver
@ 2015-10-05 14:38 ` Ludovic Courtès
0 siblings, 0 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-05 14:38 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel, beffa
Mark H Weaver <mhw@netris.org> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> After a lot more thought, I changed my mind.
>>
>> I realized that with the patch at
>> <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>, it’s OK to
>> have, say,
>>
>> LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>>
>> That way, programs will pick locale data that is compatible; so a 2.23
>> program might pick most of its locale data from the /2.22 directory (if
>> they are compatible), and some of them from /2.23 (if the format has
>> changed.)
>
> I'm a bit uncomfortable with this. A few questions:
>
> * Will your glibc patch reliably ensure that no functionality is lost
> because of picking up the wrong version of locales?
If locale data is missing or incompatible, ‘setlocale’ returns ENOENT or
EINVAL. That’s the worst that can happen.
> * Do we have a mechanism for automatically setting LOCPATH (or
> GUIX_LOCPATH) to include all of the available locale versioned
> subdirectories?
No.
This is not a problem on GuixSD because we would populate
/run/current-system/locale/{2.22,2.23} by default and rarely need to
fiddle with GUIX_LOCPATH.
On foreign distros, it means people have to maintain GUIX_LOCPATH by
hand; this is already the case, but now they’d have to append “/2.22”
and possibly other subdirectories.
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-05 14:35 ` Ludovic Courtès
@ 2015-10-05 15:38 ` Federico Beffa
2015-10-05 19:39 ` Ludovic Courtès
2015-10-05 21:09 ` Ludovic Courtès
0 siblings, 2 replies; 30+ messages in thread
From: Federico Beffa @ 2015-10-05 15:38 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
On Mon, Oct 5, 2015 at 4:35 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Mark H Weaver <mhw@netris.org> skribis:
>
>> ludo@gnu.org (Ludovic Courtès) writes:
>>
>>> So with current ‘core-updates’, someone on a “foreign distro” needs to
>>> do:
>>>
>>> guix package -i glibc-locales
>>> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22
>>>
>>> Note the extra “/2.22”, which comes from commit f2d7bbb. This is a bit
>>> of an annoyance for end users, but the point is that eventually this
>>> would allow us to recommend things like:
>>>
>>> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>>>
>>> The only question is whether having the “/2.22” prefix by default is a
>>> good idea. Opinions?
>>
>> I think the "/2.22" suffix will be needed to prevent another awkward
>> transition the next time glibc makes an incompatible change to their
>> locales. Suppose that 2.23 makes another incompatible change. After
>> that, many Guix systems will have a mixture of software linked with
>> glibc-2.22 and glibc-2.23.
>
> Yes. But we could just as well have ‘glibc-utf8-locales’ where
> everything is in lib/locale directly, and ‘glibc-transition-locales’
> where things are under lib/locale/2.22 and lib/locale/2.23. Dunno.
I'm wondering if it would be better to point GUIX_LOCPATH to
export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
and have 'glibc' itself to append it's own version number to that
string. In this way pre 2.22 programs (last official Guix(SD) release)
would find pre-2.22 locale in '/$HOME/.guix-profile/lib/locale'. The
next releases (with 'glibc-2.22' and following) will provide locales
in versioned sub-directory (no conflict with pre 2.22) and the new
programs will co-exist without users ever having to modify
GUIX_LOCPATH.
Regards,
Fede
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-05 15:38 ` Federico Beffa
@ 2015-10-05 19:39 ` Ludovic Courtès
2015-10-05 21:09 ` Ludovic Courtès
1 sibling, 0 replies; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-05 19:39 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> On Mon, Oct 5, 2015 at 4:35 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>> Mark H Weaver <mhw@netris.org> skribis:
>>
>>> ludo@gnu.org (Ludovic Courtès) writes:
>>>
>>>> So with current ‘core-updates’, someone on a “foreign distro” needs to
>>>> do:
>>>>
>>>> guix package -i glibc-locales
>>>> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22
>>>>
>>>> Note the extra “/2.22”, which comes from commit f2d7bbb. This is a bit
>>>> of an annoyance for end users, but the point is that eventually this
>>>> would allow us to recommend things like:
>>>>
>>>> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale/2.22:$HOME/.guix-profile/lib/locale/2.23
>>>>
>>>> The only question is whether having the “/2.22” prefix by default is a
>>>> good idea. Opinions?
>>>
>>> I think the "/2.22" suffix will be needed to prevent another awkward
>>> transition the next time glibc makes an incompatible change to their
>>> locales. Suppose that 2.23 makes another incompatible change. After
>>> that, many Guix systems will have a mixture of software linked with
>>> glibc-2.22 and glibc-2.23.
>>
>> Yes. But we could just as well have ‘glibc-utf8-locales’ where
>> everything is in lib/locale directly, and ‘glibc-transition-locales’
>> where things are under lib/locale/2.22 and lib/locale/2.23. Dunno.
>
> I'm wondering if it would be better to point GUIX_LOCPATH to
>
> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
>
> and have 'glibc' itself to append it's own version number to that
> string. In this way pre 2.22 programs (last official Guix(SD) release)
> would find pre-2.22 locale in '/$HOME/.guix-profile/lib/locale'. The
> next releases (with 'glibc-2.22' and following) will provide locales
> in versioned sub-directory (no conflict with pre 2.22) and the new
> programs will co-exist without users ever having to modify
> GUIX_LOCPATH.
This is what the patch at
<http://article.gmane.org/gmane.comp.gnu.guix.devel/12004> does.
However, it has the drawback of being fairly intrusive and non-trivial.
Intrusive in that it touches libc, and if it doesn’t make it upstream,
then we’ll have difficulties dealing with it. Non-trivial in that I
think it’s pretty unusual for software to automatically modify search
path entries (when defining FOOPATH=/x:/y, one expects Foo to look under
/x and /y, not under /x/2.22.)
None of these two approaches is perfect, but I’m inclined to make the
choice that requires the smallest amount of modifications to libc.
Thoughts?
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-05 15:38 ` Federico Beffa
2015-10-05 19:39 ` Ludovic Courtès
@ 2015-10-05 21:09 ` Ludovic Courtès
2015-10-06 6:29 ` Federico Beffa
1 sibling, 1 reply; 30+ messages in thread
From: Ludovic Courtès @ 2015-10-05 21:09 UTC (permalink / raw)
To: Federico Beffa; +Cc: Guix-devel
Federico Beffa <beffa@ieee.org> skribis:
> I'm wondering if it would be better to point GUIX_LOCPATH to
>
> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
>
> and have 'glibc' itself to append it's own version number to that
> string. In this way pre 2.22 programs (last official Guix(SD) release)
> would find pre-2.22 locale in '/$HOME/.guix-profile/lib/locale'.
With the discussion on IRC following your message, I ended up going back
to the solution that appends /2.22 to the GUIX_LOCPATH entries
automatically:
http://article.gmane.org/gmane.comp.gnu.guix.devel/12004
We’ll settle on that and declare the problem solved now. :-)
Sorry for the hesitations. It’s one of these situations where we have
conflicting principles: simplifying the users lives, and remaining close
to what upstream does.
Ludo’.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 0/2] Avoiding incompatible locale data in LOCPATH
2015-10-05 21:09 ` Ludovic Courtès
@ 2015-10-06 6:29 ` Federico Beffa
0 siblings, 0 replies; 30+ messages in thread
From: Federico Beffa @ 2015-10-06 6:29 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
On Mon, Oct 5, 2015 at 11:09 PM, Ludovic Courtès <ludo@gnu.org> wrote:
> Federico Beffa <beffa@ieee.org> skribis:
>
>> I'm wondering if it would be better to point GUIX_LOCPATH to
>>
>> export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
>>
>> and have 'glibc' itself to append it's own version number to that
>> string. In this way pre 2.22 programs (last official Guix(SD) release)
>> would find pre-2.22 locale in '/$HOME/.guix-profile/lib/locale'.
>
> With the discussion on IRC following your message, I ended up going back
> to the solution that appends /2.22 to the GUIX_LOCPATH entries
> automatically:
>
> http://article.gmane.org/gmane.comp.gnu.guix.devel/12004
>
> We’ll settle on that and declare the problem solved now. :-)
>
> Sorry for the hesitations. It’s one of these situations where we have
> conflicting principles: simplifying the users lives, and remaining close
> to what upstream does.
I think this is the right thing to do. It's not just about making the
lives of users easier, but rather preventing that users will see their
profile break after an update (when a new 'glibc' with incompatible
locales will come out). IMO such a behavior would just be bad design.
Thanks,
Fede
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2015-10-06 6:29 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-28 9:17 Preparing for the libc/locale upgrade Federico Beffa
2015-09-28 20:45 ` Ludovic Courtès
2015-09-30 12:35 ` Federico Beffa
2015-09-30 13:46 ` Ludovic Courtès
2015-09-30 15:53 ` Federico Beffa
2015-10-01 21:58 ` [PATCH 0/2] Avoiding incompatible locale data in LOCPATH Ludovic Courtès
2015-10-02 0:06 ` Mark H Weaver
2015-10-02 16:52 ` Ludovic Courtès
2015-10-03 22:20 ` Ludovic Courtès
2015-10-03 22:56 ` Daniel Pimentel
2015-10-04 8:09 ` Ludovic Courtès
2015-10-04 17:04 ` Mark H Weaver
2015-10-05 14:38 ` Ludovic Courtès
2015-10-04 8:32 ` Ricardo Wurmus
2015-10-04 8:39 ` Ricardo Wurmus
2015-10-04 12:32 ` Ludovic Courtès
2015-10-04 16:56 ` Mark H Weaver
2015-10-05 14:35 ` Ludovic Courtès
2015-10-05 15:38 ` Federico Beffa
2015-10-05 19:39 ` Ludovic Courtès
2015-10-05 21:09 ` Ludovic Courtès
2015-10-06 6:29 ` Federico Beffa
2015-10-01 21:58 ` [PATCH 1/2] gnu: glibc: Honor 'GUIX_LOCPATH' Ludovic Courtès
2015-10-01 21:58 ` [PATCH 2/2] gnu: glibc: Look for locale data in versioned sub-directories Ludovic Courtès
2015-10-01 7:02 ` Preparing for the libc/locale upgrade Konrad Hinsen
2015-09-29 14:32 ` Mark H Weaver
2015-09-29 16:12 ` Federico Beffa
2015-10-01 19:57 ` Leo Famulari
2015-10-01 20:36 ` Taylan Ulrich Bayırlı/Kammer
-- strict thread matches above, loose matches on Subject: below --
2015-09-24 19:25 Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.