Bug 53

Summary: gcc-3.4.6 fails to compile with uClibc HEAD
Product: uClibc Reporter: rhabarber1848
Component: LocalesAssignee: unassigned
Status: RESOLVED WONTFIX    
Severity: enhancement CC: aldot, rhabarber1848, uclibc-cvs, vda.linux
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: diff of uClibc_locale.h shows removed code
uClibc .config
The patch which *possibly* fixes it

Description rhabarber1848 2009-01-15 17:37:56 UTC
Trying to cross-compile gcc-3.4.6 using uClibc CVS HEAD produces this error:

monetary_members.cc: In member function `void std::moneypunct<_CharT, _Intl>::_M_initialize_moneypunct(int*, const char*) [with _CharT = wchar_t, bool _Intl =  true]':
monetary_members.cc:412: error: `__global_locale' was not declared in this scope
monetary_members.cc: In member function `void std::moneypunct<_CharT, _Intl>::_M_initialize_moneypunct(int*, const char*) [with _CharT = wchar_t, bool _Intl =  false]':
monetary_members.cc:570: error: `__global_locale' was not declared in this scope

Using uClibc 0.9.30 everything is ok.
gcc-3.4.6 is patched using this: http://cvs.tuxbox.org/cgi-bin/viewcvs.cgi/tuxbox/cdk/Patches/gcc-uclibc.diff?view=markup
which is based on http://sources.busybox.net/index.py/trunk/buildroot/toolchain/gcc/4.2.4/200-uclibc-locale.patch?view=markup

Revoking all of these SVN commits from HEAD lets gcc-3.4.6 compile:
------------------------------------------------------------------------
r24572 | vda | 2008-12-28 13:06:04 +0100 (So, 28. Dez 2008) | 3 lines

fix another corner case in unifdef
------------------------------------------------------------------------
r24570 | vda | 2008-12-28 12:48:01 +0100 (So, 28. Dez 2008) | 4 lines

patch up unifdef to recognize and remove "#if defined _LIBC && something"
blocks too (and similar)
------------------------------------------------------------------------
r24565 | vda | 2008-12-27 12:01:17 +0100 (Sa, 27. Dez 2008) | 3 lines

Help unifdef to remove private parts of headers


I do not know which commit exactly is responsible for the compile error and I do not have the knowledge to further debug this.
Comment 1 rhabarber1848 2009-01-15 17:42:19 UTC
Created attachment 23 [details]
diff of uClibc_locale.h shows removed code

Attached you will find the diff of uClibc-generated include/bits/uClibc_locale.h

As you can see the unpatched uClibc SVN HEAD removes a lot of lines from this file, including 

extern struct __uclibc_locale_struct * __global_locale;


work_uclibc_head/image/cdkroot/include/bits/uClibc_locale.h
is the file produced by unpatched uClibc SVN HEAD

work_uclibc/image/cdkroot/include/bits/uClibc_locale.h
is the file produced by uClibc SVN HEAD, with commits 24565-24572 removed
Comment 2 rhabarber1848 2009-01-15 17:43:37 UTC
Created attachment 25 [details]
uClibc .config
Comment 3 Denys Vlasenko 2009-01-18 22:57:16 UTC
Created attachment 29 [details]
The patch which *possibly* fixes it

Please try it and let me know whether it works.
Comment 4 rhabarber1848 2009-01-19 09:14:58 UTC
Using latest SVN HEAD now produces this error message:

monetary_members.cc: In member function `void std::moneypunct<_CharT, _Intl>::_M_initialize_moneypunct(int*, const char*) [with _CharT = wchar_t, bool _Intl =  true]':
monetary_members.cc:412: error: invalid use of undefined type `struct __uclibc_locale_struct'
/root/tuxbox/work_uclibc/image/cdk/powerpc-tuxbox-linux-uclibc/include/bits/uClibc_locale.h:93: error: forward declaration of `struct __uclibc_locale_struct'
monetary_members.cc:413: error: invalid use of undefined type `struct __uclibc_locale_struct'
/root/tuxbox/work_uclibc/image/cdk/powerpc-tuxbox-linux-uclibc/include/bits/uClibc_locale.h:93: error: forward declaration of `struct __uclibc_locale_struct'
monetary_members.cc: In member function `void std::moneypunct<_CharT, _Intl>::_M_initialize_moneypunct(int*, const char*) [with _CharT = wchar_t, bool _Intl =  false]':
monetary_members.cc:570: error: invalid use of undefined type `struct __uclibc_locale_struct'
/root/tuxbox/work_uclibc/image/cdk/powerpc-tuxbox-linux-uclibc/include/bits/uClibc_locale.h:93: error: forward declaration of `struct __uclibc_locale_struct'
monetary_members.cc:571: error: invalid use of undefined type `struct __uclibc_locale_struct'
/root/tuxbox/work_uclibc/image/cdk/powerpc-tuxbox-linux-uclibc/include/bits/uClibc_locale.h:93: error: forward declaration of `struct __uclibc_locale_struct'
Comment 5 rhabarber1848 2009-01-19 12:04:47 UTC
The solution which works here is to copy the original libc/sysdeps/linux/common/bits/uClibc_locale.h to $PREFIX/include/bits
Comment 6 rhabarber1848 2009-01-19 14:52:53 UTC
Another bug shows up later in the compile process:

In file included from /root/tuxbox/work_uclibc2/compile/cdk/build_gcc/powerpc-tuxbox-linux-uclibc/nof/libstdc++-v3/include/csignal:49,
                 from /root/tuxbox/work_uclibc2/compile/cdk/gcc-3.4.6/libstdc++-v3/include/stdc++.h:42:
/root/tuxbox/work_uclibc2/image/cdk/powerpc-tuxbox-linux-uclibc/include/signal.h:372:24: ucontext.h: No such file or directory
In file included from /root/tuxbox/work_uclibc2/compile/cdk/build_gcc/powerpc-tuxbox-linux-uclibc/nof/libstdc++-v3/include/csignal:49,
                 from /root/tuxbox/work_uclibc2/compile/cdk/gcc-3.4.6/libstdc++-v3/include/stdc++.h:42:
/root/tuxbox/work_uclibc2/image/cdk/powerpc-tuxbox-linux-uclibc/include/signal.h:372:24: ucontext.h: No such file or directory


The reason is this patch:
http://sources.busybox.net/index.py/trunk/uClibc/Makefile.in?r1=24405&r2=24595&diff_format=h

I am compiling uClibc with UCLIBC_SUSV3_LEGACY disabled in this case.

Removing these lines from signal.h fixes the compile problem:

# ifdef __USE_XOPEN
/* This will define `ucontext_t' and `mcontext_t'.  */
#  include <ucontext.h>
# endif

but it may have side-effects I am not aware of.
Comment 7 Denys Vlasenko 2009-01-21 01:39:25 UTC
Ok. You patched the gcc. The error happens here:

+#ifdef __UCLIBC_MJN3_ONLY__
+#warning fix this... should be monetary
+#endif
+#ifdef __UCLIBC__
+# ifdef __UCLIBC_HAS_XLOCALE__
+         _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+         _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+# else
+         _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+         _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+# endif
+#else

I have no idea why this patch attempts to use uclibc internals. It is not supposed to ever do it.

I will revert my "fix". Please work with patch author to stop using uclibc internals.
Comment 8 Denys Vlasenko 2009-01-21 01:40:49 UTC
I meant that error happens in that place in the libstdc++-v3/config/locale/uclibc/monetary_members.cc

This file is created by the patch you applied to gcc tree.
Comment 9 Denys Vlasenko 2009-01-21 02:19:38 UTC
> I am compiling uClibc with UCLIBC_SUSV3_LEGACY disabled in this case.

Perhaps you need to enable it then
Comment 10 rhabarber1848 2009-01-21 10:24:01 UTC
(In reply to comment #7)
> Please work with patch author to stop using uclibc internals.

Hi,

who maintains the patch which can be found on your SVN in the buildroot section?
Or in other words, will the buildroot suffer from the same problem with
uClibc SVN HEAD and <= gcc-4.2.4?

In regard to signal.h I reactivated UCLIBC_SUSV3_LEGACY (mainly because I am
too lazy to port usleep() to nanosleep(), but thats another topic), but I
think other software will suffer from the same problem, a header is included
which is not present.
Comment 11 Denys Vlasenko 2009-01-21 21:57:14 UTC
I guess you need to talk to buildroot project:

http://buildroot.uclibc.org/
http://buildroot.uclibc.org/lists.html
Comment 12 rhabarber1848 2009-02-19 21:42:35 UTC
For the record, this patch fixes the problem:
http://lists.uclibc.org/pipermail/uclibc/2009-February/041918.html

I know this patch will not make it into CVS, but it works;)
Comment 13 Bernhard Reutner-Fischer 2009-03-03 00:04:40 UTC
I think that this works as expected with the 0.9.30.1 release.

Note that the (c++) locale support for any supported gcc version needs
a re-implementation based off generic support. This is a known TODO at
the time of this writing, sensible, tested patches welcome.
Comment 14 Bernhard Reutner-Fischer 2010-03-12 18:52:51 UTC
A clean reimplementation in gcc is in order for everything > 0.9.30.