public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Issue with locale (sysroot installation)
@ 2021-03-20 21:32 Oleg Smolsky
  2021-03-21  8:19 ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Smolsky @ 2021-03-20 21:32 UTC (permalink / raw)
  To: libc-help

Hello there! I'm testing a GCC-10/glibc-2.33 combo where libc is 
installed into a sysroot. Here is a small test demonstrating a problem:

#include <iostream>
#include <locale>
int main() {
     std::cout << "User-preferred locale: " << std::locale("").name() << 
std::endl;
}

Things work when I build this test using a normal compiler and the 
program prints "en_US.UTF-8" on my system. Yet I get an exception when 
running a program built with the GCC-10/glibc combo:

     what():  locale::facet::_S_create_c_locale name not valid

Here is what the run-time setup is for the test program:

$ ldd test
         linux-vdso.so.1 =>  (0x00007ffd6d7d8000)
         libpthread.so.0 => /opt/sysroot/lib64/libpthread.so.0 
(0x00007f3aafb0d000)
         librt.so.1 => /opt/sysroot/lib64/librt.so.1 (0x00007f3aaf905000)
         libdl.so.2 => /opt/sysroot/lib64/libdl.so.2 (0x00007f3aaf701000)
         libstdc++.so.6 => /opt/gcc-10sr/lib64/libstdc++.so.6 
(0x00007f3aaf334000)
         libm.so.6 => /opt/sysroot/lib64/libm.so.6 (0x00007f3aaeff5000)
         libgcc_s.so.1 => /opt/gcc-10sr/lib64/libgcc_s.so.1 
(0x00007f3aaedde000)
         libc.so.6 => /opt/sysroot/lib64/libc.so.6 (0x00007f3aaea1b000)
         /opt/sysroot/lib64/ld-linux-x86-64.so.2 => 
/lib64/ld-linux-x86-64.so.2 (0x00007f3aafd2b000)

Some notes:

1. The program works when I force the locale via environment with LC_ALL=C

2. In the broken case it looks like glibc code is searching in the 
system dirs. Here is "strace -e file" output:

openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 4
newfstatat(4, "", {st_mode=S_IFREG|0644, st_size=2981280, ...}, 
AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 4
newfstatat(4, "", {st_mode=S_IFREG|0644, st_size=2995, ...}, 
AT_EMPTY_PATH) = 0
openat(AT_FDCWD, "/usr/lib/locale/en_US.UTF-8/LC_TIME", 
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/en_US.utf8/LC_TIME", 
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/en_US/LC_TIME", O_RDONLY|O_CLOEXEC) = 
-1 ENOENT (No such file or directory)
...

3. I tried installing locales with "localedata/install-locale-files" and 
"localedata/install-locales". Yet the program does not look in the 
sysroot...

4. Glibc was configured with:

CC=$boostrap_gcc/bin/gcc CXX=$boostrap_gcc/bin/g++ PATH=/opt/3p/bin:$PATH \
     ../configure \
         --prefix=/usr --libdir=/usr/lib \
         --host=x86_64-pc-linux \
         --enable-kernel=4.4.0 \
         --with-headers=$sysroot/usr/include

Could someone shed some light on how this setup is supposed to work 
please? It seems like I am missing some glue/config that should get 
baked into glibc during compilation or installation...

Thanks in advance!
Oleg.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-21 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-20 21:32 Issue with locale (sysroot installation) Oleg Smolsky
2021-03-21  8:19 ` Florian Weimer
2021-03-21 15:17   ` Oleg Smolsky
2021-03-21 18:27     ` Oleg Smolsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).