Bug#747103: libc6-dev: setlocale in static binary fails
Package: libc6-dev
Version: 2.13-38
Severity: important
Hello list,
I'm trying to use setlocale() in a static binary, and I compil with:
$ gcc -Wall -static code.c -o code
When I run
$ ./code
I expect to see "lundi" instead of "Monday", but it's not working with static compilation.
(it's ok in dynamic compil. with: $gcc -Wall -code.c -o code).
The locale "fr_FR" is correctly installed on my system (package locales configured with fr_FR).
The code.c is fairly simple :
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>
int main(void)
{
setlocale (LC_ALL, "fr_FR");
printf("%s\n",nl_langinfo(DAY_2));
return 0;
}
I have done some debug (with gcc -ggdb) :
- the return of setlocale is correct "fr_FR" in static and dyn. compil,
- it seems to me that setdata()/setname() in file setlocale.c don't do right job (pb with CATEGORY_USED(category))
- I have try use of:
$ cd tmp ; localedef -i fr_FR -f ISO-8859-1 ./fr_FR
and put in code.c before setlocale():
setenv("LOCPATH","/home/raphael/tmp,1);
but: it's not better in static compilation
- I have noticed with $strace -eopen ./code
that in dynamic compil : open("/home/raphael/tmp/fr_FR/LC_xxx", O_RDONLY) = 3 (with setenv)
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3 (without setenv)
but in static compil with setenv and setlocale(LC_TIME, "fr_FR"); nothing is opened ...
I have tried this code under different OS :
- RedHat Enterprise Linux Server release 5.5 (Tikanga) or 6 --> it works as expected
- Debian Etch, Debian Lenny --> it works as expected
- Debian Wheezy --> the bug is present
Thank you
-- System Information:
Debian Release: 6.0.9
APT prefers oldstable
APT policy: (500, 'oldstable')
Architecture: i386 (x86_64)
Kernel: Linux 2.6.32.8_x86_64 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=fr_FR, LC_CTYPE=fr_FR (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Versions of packages libc6-dev depends on:
ii libc-dev-bin 2.13-38 Embedded GNU C Library: Developmen
ii libc6 2.13-38 Embedded GNU C Library: Shared lib
ii linux-libc-dev 2.6.32-48squeeze5 Linux support headers for userspac
Versions of packages libc6-dev recommends:
ii gcc [c-compiler] 4:4.4.5-1 The GNU C compiler
ii gcc-4.4 [c-compiler] 4.4.7-2 GNU C compiler
Versions of packages libc6-dev suggests:
ii glibc-doc 2.11.3-4 Embedded GNU C Library: Documentat
ii manpages-dev 3.27-1 Manual pages about using GNU/Linux
Reply to: