[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libc6-dev: setlocale in static binary fails



On Tue, May 06, 2014 at 11:09:34PM +0200, Raphael Astier wrote:
> 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;
> }
> 
> The problem extends with use of strftime(). 
> 
> 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
> 
> Is it possible to do something with libc.a to avoid this bug ?
> 

You already reported bug #747103 about that. Your problem has been
reported upstream [1] with a patch fixing that [2] currently being
reviewed.

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=16915
[2] https://sourceware.org/ml/libc-alpha/2014-05/msg00134.html

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net


Reply to: