Subject: Re: bug#30395: ‘gcc’ doesn't compile with LD_LIBRARY_PATH="$HOME/.guix-profile/lib"

From: [email-masked] (Ludovic Courtès)
Date: Sat, 17 Feb 2018 22:16:02 +0100

Hi,

This is getting interesting.  :-)

Mathieu Lirzin <[email-masked]> skribis:

> [email-masked] (Ludovic Courtès) writes:

[...]

>> I don’t get it yet.  The log shows this:
>>
>> 9543  execve("/gnu/store/x7i79rihhdjkps5fx0f9p2q0svh5a88n-guile-2.2.2/bin/guile", ["/gnu/store/x7i79rihhdjkps5fx0f9p"..., "-c", "(load-compiled \"/gnu/store/w27in"..., "-plugin", "/gnu/store/xjpchnxm9fgg05fqm9apy"..., "-plugin-opt=/gnu/store/xjpchnxm9"..., "-plugin-opt=-fresolution=/tmp/cc"..., "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "-plugin-opt=-pass-through=-lgcc_"..., "-plugin-opt=-pass-through=-lc", "-plugin-opt=-pass-through=-lgcc", "-plugin-opt=-pass-through=-lgcc_"..., "--eh-frame-hdr", "-m", "elf_x86_64", "-dynamic-linker", "/gnu/store/3h31zsqxjjg52da5gp3qm"..., "/gnu/store/0qg64bwn2z3g91b5iw16i"..., "/gnu/store/0qg64bwn2z3g91b5iw16i"..., "/gnu/store/45rhjm5ryms10frcyrzcd"..., "-L/gnu/store/0qg64bwn2z3g91b5iw1"..., "-L/gnu/store/45rhjm5ryms10frcyrz"..., "-L/gnu/store/45rhjm5ryms10frcyrz"..., "-L/gnu/store/3h31zsqxjjg52da5gp3"..., "/tmp/cc9aj9M2.o", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "-L/gnu/store/3h31zsqxjjg52da5gp3"..., "-rpath=/gnu/store/3h31zsqxjjg52d"..., ...], 0x113a520 /* 31 vars */) = 0
>>
>> 9543  open("/home/mthl/.guix-profile/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
>>
>> 9543  write(2, "Uncaught exception:\n", 20) = 20
>> 9543  futex(0x7f5d453c6930, FUTEX_WAKE_PRIVATE, 2147483647) = 0
>> 9543  futex(0x7f5d43ab0190, FUTEX_WAKE_PRIVATE, 2147483647) = 0
>> 9543  close(3)                          = 0
>> 9543  close(4)                          = 0
>> 9543  munmap(0x7f5d455e8000, 4096)      = 0
>> 9543  exit(0)                           = ?
>> 9539  <... wait4 resumed> 0xcddb20, 0, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
>> 9539  --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
>>
>> This is the execution of ld-wrapper and it terminates with “Uncaught
>> exception”, which isn’t really helpful.  Apparently this happens before
>> ‘boot-9.scm’ was even search for.
>>
>> Can you reproduce it by running ‘ld’ directly in that environment?  Or
>> better yet, by running ‘guile’?  The next thing is to try and do that
>> in gdb…
>
> Yes I can reproduce simply by running ‘guile’ (v2.2.2 and v2.2.3).  :-)
>
> LD_LIBRARY_PATH="$HOME/.guix-profile/lib" guile
> Uncaught exception:
> Throw to key encoding-error with args ("scm_to_stringn" "cannot convert
> narrow string to output locale" 22 #f #f)

Awesome.  :-)

> I have tried to set LC_ALL=C, but this doesn't have any impact.  Here
> are the outputs of ‘LD_LIBRARY_PATH="$HOME/.guix-profile/lib" strace -f
> -s 1000 -o OUTPUT guile’ for the failing environment with [email-masked] in
> the profile:

[...]

> 13061 open("/gnu/store/38kr8xi7nib8rx8xr4gi0w0d8knyca3k-glibc-2.25/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
> 13061 fstat(3, {st_mode=S_IFREG|0444, st_size=2997, ...}) = 0
> 13061 read(3, "# Locale name alias data base.\n# Copyright (C) 1996-2017 Free Software Foundation, Inc.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2, or (at your option)\n# any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, see <http://www.gnu.org/licenses/>.\n\n# The format of this file is the same as for the corresponding file of\n# the X Window System, which normally can be found in\n#\t/usr/lib/X11/locale/locale.alias\n# A single line contains two fields: an alias and a substitution value.\n# All entries are case independent.\n\n# Note: This file is o"..., 4096) = 2997
> 13061 read(3, "", 4096)                 = 0
> 13061 close(3)                          = 0
> 13061 open("/run/current-system/locale/2.25/fr_FR.utf8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = 3
> 13061 fstat(3, {st_mode=S_IFREG|0444, st_size=299, ...}) = 0
> 13061 mmap(NULL, 299, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f726d164000
> 13061 close(3)                          = 0
> 13061 open("/gnu/store/38kr8xi7nib8rx8xr4gi0w0d8knyca3k-glibc-2.25/lib/gconv/gconv-modules.cache", O_RDONLY) = -1 ENOENT (No such file or directory)
> 13061 open("/gnu/store/5x9zxdmxphmprlchfl3a2y8w5ykcwkjc-glibc-2.25/lib/gconv/gconv-modules", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

How come this ‘gconv-modules’ file doesn’t exist?  I have it here.
I have:

--8<---------------cut here---------------start------------->8---
$ guix hash -r /gnu/store/5x9zxdmxphmprlchfl3a2y8w5ykcwkjc-glibc-2.25
03la0p9pigf6r33px5nckky9fxvrynvw1fgn9v2l04zlys7k3k2y
$ wget -q -O - https://berlin.guixsd.org/5x9zxdmxphmprlchfl3a2y8w5ykcwkjc.narinfo | grep NarHash
NarHash: sha256:03la0p9pigf6r33px5nckky9fxvrynvw1fgn9v2l04zlys7k3k2y
--8<---------------cut here---------------end--------------->8---

What about you?

Can you try ‘guix gc --verify’?

FTR these two libcs come from here (on x86_64 with current master):

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build -e '((@ (guix packages) package-replacement) (@@ (gnu packages base) glibc))' --no-grafts
/gnu/store/bwbh5zfg06lxla7db6zslmkpc4jjq663-glibc-2.25-debug
/gnu/store/5x9zxdmxphmprlchfl3a2y8w5ykcwkjc-glibc-2.25
$ ./pre-inst-env guix build -e '(@@ (gnu packages commencement) glibc-final)'
/gnu/store/w295br3vqqdvmd7hb2ga8h8hk3sd9iiv-glibc-2.25-debug
/gnu/store/3h31zsqxjjg52da5gp3qmhkh4x8klhah-glibc-2.25
--8<---------------cut here---------------end--------------->8---

> When looking at ‘scm_to_stringn’ code and crossing with the actual error
> message it looks like the failing instruction is the following:
>
>       ret = mem_iconveh (scm_i_string_chars (str), ilen,
>                          "ISO-8859-1", enc,
>                          (enum iconv_ilseq_handler) handler, NULL,
>                          &buf, &len);

Yes, without ‘gconv-modules’, libc cannot determine how to convert from
ISO-8859-1.

Thanks for investigating!

Ludo’.