distro: Add patch to allow the bootstrap Guile to work without iconv.

* distro/patches/guile-default-utf8.patch: New file.
* Makefile.am (dist_patch_DATA): Add it.

* distro/packages/base.scm (%guile-static): Use it.
  (%guile-static-stripped): Add call to `remove-store-references'.
This commit is contained in:
Ludovic Courtès 2012-10-17 17:51:33 +02:00
parent b7f280ee3e
commit eb1db76e34
3 changed files with 117 additions and 1 deletions

View File

@ -50,6 +50,7 @@ dist_patch_DATA = \
distro/patches/binutils-ld-new-dtags.patch \
distro/patches/diffutils-gets-undeclared.patch \
distro/patches/guile-1.8-cpp-4.5.patch \
distro/patches/guile-default-utf8.patch \
distro/patches/guile-relocatable.patch \
distro/patches/libtool-skip-tests.patch \
distro/patches/m4-gets-undeclared.patch \

View File

@ -2005,6 +2005,8 @@ store.")
(inputs
`(("patch/relocatable"
,(search-patch "guile-relocatable.patch"))
("patch/utf8"
,(search-patch "guile-default-utf8.patch"))
,@(package-inputs guile-2.0)))
(arguments
`(;; When `configure' checks for ltdl availability, it
@ -2031,7 +2033,8 @@ store.")
;; Allow Guile to be relocated, as is needed during
;; bootstrap.
#:patches
(list (assoc-ref %build-inputs "patch/relocatable"))
(list (assoc-ref %build-inputs "patch/relocatable")
(assoc-ref %build-inputs "patch/utf8"))
;; There are uses of `dynamic-link' in
;; {foreign,coverage}.test that don't fly here.
@ -2094,6 +2097,7 @@ store.")
(mkdir (string-append out "/bin"))
(copy-file (string-append in "/bin/guile")
(string-append out "/bin/guile"))
(remove-store-references (string-append out "/bin/guile"))
#t))))
(inputs `(("guile" ,%guile-static)))))

View File

@ -0,0 +1,111 @@
This hack makes Guile default to UTF-8. This avoids calls to
`iconv_open'; `iconv_open' tries to open shared objects that aren't
available during bootstrap, so using UTF-8 avoids that (and UTF-8 has
built-in conversions in glibc, too.)
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index cf41f2f..facfb91 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -1887,7 +1887,7 @@ utf_encoding_name (char *name, size_t utf_width, SCM endianness)
if (scm_i_is_narrow_string (str)) \
{ \
err = mem_iconveh (scm_i_string_chars (str), c_strlen, \
- "ISO-8859-1", c_utf_name, \
+ "UTF-8", c_utf_name, \
iconveh_question_mark, NULL, \
&c_utf, &c_utf_len); \
if (SCM_UNLIKELY (err)) \
diff --git a/libguile/ports.c b/libguile/ports.c
index 301bc44..b0ea2e6 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1750,7 +1750,7 @@ scm_ungetc (scm_t_wchar c, SCM port)
if (pt->encoding != NULL)
encoding = pt->encoding;
else
- encoding = "ISO-8859-1";
+ encoding = "UTF-8";
len = sizeof (result_buf);
result = u32_conv_to_encoding (encoding,
@@ -2212,7 +2212,7 @@ scm_i_set_port_encoding_x (SCM port, const char *encoding)
pt = SCM_PTAB_ENTRY (port);
if (encoding == NULL)
- encoding = "ISO-8859-1";
+ encoding = "UTF-8";
if (pt->encoding != encoding)
pt->encoding = scm_gc_strdup (encoding, "port");
diff --git a/libguile/posix.c b/libguile/posix.c
index 4f8b8ac..fea7f74 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1740,7 +1740,7 @@ SCM_DEFINE (scm_setlocale, "setlocale", 1, 1, 0,
SCM_SYSERROR;
}
- enc = locale_charset ();
+ enc = "UTF-8";
/* Set the default encoding for new ports. */
scm_i_set_default_port_encoding (enc);
diff --git a/libguile/script.c b/libguile/script.c
index 83daf8a..083891e 100644
--- a/libguile/script.c
+++ b/libguile/script.c
@@ -387,7 +387,7 @@ locale_arguments_to_string_list (int argc, char **const argv)
SCM lst;
const char *encoding;
- encoding = environ_locale_charset ();
+ encoding = "UTF-8";
for (i = argc - 1, lst = SCM_EOL;
i >= 0;
i--)
diff --git a/libguile/strings.c b/libguile/strings.c
index 5d0db23..8266247 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1576,7 +1576,7 @@ scm_from_locale_string (const char *str)
SCM
scm_from_locale_stringn (const char *str, size_t len)
{
- return scm_from_stringn (str, len, locale_charset (),
+ return scm_from_stringn (str, len, "UTF-8",
scm_i_default_port_conversion_handler ());
}
@@ -1803,7 +1803,7 @@ char *
scm_to_locale_stringn (SCM str, size_t *lenp)
{
return scm_to_stringn (str, lenp,
- locale_charset (),
+ "UTF-8",
scm_i_default_port_conversion_handler ());
}
@@ -2054,7 +2054,7 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
"string contains #\\nul character: ~S",
scm_list_1 (str));
- if (scm_i_is_narrow_string (str) && (encoding == NULL))
+ if (scm_i_is_narrow_string (str))
{
/* If using native Latin-1 encoding, just copy the string
contents. */
@@ -2079,11 +2079,11 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
len = 0;
enc = encoding;
if (enc == NULL)
- enc = "ISO-8859-1";
+ enc = "UTF-8";
if (scm_i_is_narrow_string (str))
{
ret = mem_iconveh (scm_i_string_chars (str), ilen,
- "ISO-8859-1", enc,
+ "UTF-8", enc,
(enum iconv_ilseq_handler) handler, NULL,
&buf, &len);