Bug 14939

Summary: libstdc++ doesn't compile with uclibc headers
Product: gcc Reporter: bero
Component: libstdc++Assignee: Joseph S. Myers <jsm28>
Status: RESOLVED FIXED    
Severity: enhancement CC: gcc-bugs
Priority: P2    
Version: 3.4.0   
Target Milestone: 4.2.0   
Host: i586-ark-linux-gnu Target: arm-ark-linuxuclibc
Build: i586-ark-linux-gnu Known to work:
Known to fail: Last reconfirmed: 2006-02-10 20:16:30
Attachments: Tweaks needed to get it to compile
Patch with ifdefs
alternate approach

Description bero 2004-04-13 12:53:30 UTC
The problem is that uclibc uses __ctype_touplow_t for its ctype stuff - it's 
typedef'ed to int16_t in uclibc headers. 
 
The error: 
 
In file included from ../../../../libstdc++-v3/src/ctype.cc:76: 
/usr/src/ark/BUILD/gcc-3.4.0-20040411/obj-arm-ark-linuxuclibc/arm-ark-linuxuclibc/libstdc++-v3/include/arm-ark-linuxuclibc/bits/ctype_noninline.h: 
In constructor `std::ctype<char>::ctype(int*, const short unsigned int*, bool, 
size_t)': 
/usr/src/ark/BUILD/gcc-3.4.0-20040411/obj-arm-ark-linuxuclibc/arm-ark-linuxuclibc/libstdc++-v3/include/arm-ark-linuxuclibc/bits/ctype_noninline.h:85: 
error: cannot convert `const __ctype_touplow_t*' to `const int*' in assignment 
/usr/src/ark/BUILD/gcc-3.4.0-20040411/obj-arm-ark-linuxuclibc/arm-ark-linuxuclibc/libstdc++-v3/include/arm-ark-linuxuclibc/bits/ctype_noninline.h:86: 
error: cannot convert `const __ctype_touplow_t*' to `const int*' in assignment 
/usr/src/ark/BUILD/gcc-3.4.0-20040411/obj-arm-ark-linuxuclibc/arm-ark-linuxuclibc/libstdc++-v3/include/arm-ark-linuxuclibc/bits/ctype_noninline.h: 
In constructor `std::ctype<char>::ctype(const short unsigned int*, bool, 
size_t)': 
/usr/src/ark/BUILD/gcc-3.4.0-20040411/obj-arm-ark-linuxuclibc/arm-ark-linuxuclibc/libstdc++-v3/include/arm-ark-linuxuclibc/bits/ctype_noninline.h:123: 
error: cannot convert `const __ctype_touplow_t*' to `const int*' in assignment 
/usr/src/ark/BUILD/gcc-3.4.0-20040411/obj-arm-ark-linuxuclibc/arm-ark-linuxuclibc/libstdc++-v3/include/arm-ark-linuxuclibc/bits/ctype_noninline.h:124: 
error: cannot convert `const __ctype_touplow_t*' to `const int*' in assignment 
make[3]: *** [ctype.lo] Error 1
Comment 1 Andrew Pinski 2004-04-13 15:37:29 UTC
Confirmed, the problem is that libstdc++ is using the glibc's version of ctype_noninline.h instead of its 
own or the generic one.
Comment 2 bero 2004-04-13 18:37:25 UTC
Created attachment 6081 [details]
Tweaks needed to get it to compile

It works with this patch; the patch isn't ready for inclusion because to breaks
non-uclibc systems, got to add a couple of ifdefs.
Comment 3 bero 2004-04-21 13:00:45 UTC
Created attachment 6132 [details]
Patch with ifdefs

This version of the patch doesn't break non-uclibc systems, otherwise it's the
same as 6081.
Comment 4 Benjamin Kosnik 2004-05-24 18:13:25 UTC
Hmmm. I'd prefer it if you could just add a new config/os/uclib directory, and
populate it with the bits you need.

Either that, or take the uclib defines out of the generic header, via some
unspecified method.

-benjamin
Comment 5 Benjamin Kosnik 2004-05-25 21:58:20 UTC
Created attachment 6381 [details]
alternate approach


Hey. This is a sketch of the alternate approach I'd suggested. 

Someone who has access to a uclibc setup, and the inclination to test this,
should try it out. I suspect parts of this are wrong: it's highly unlikely that
the glibc ctype bits will work with uclibc (and then the routines from the
config/os/generic should be used or modified instead.). 

Also, in the original patch, config/locale/generic bits are touched. This is
not necessary: why was it done? The __c_locale type is not equivalent to ctype
bits....

I think the original patch couldn't possibly be correct. 

This alternate approach, when cleaned up, will actually work and is suitable
for submission.

best,
benjamin
Comment 6 Benjamin Kosnik 2004-07-26 21:03:41 UTC
Can you please comment on this proposed patch? 

-benjamin
Comment 7 Andrew Pinski 2004-10-25 00:48:32 UTC
Can you tell us if this patch works?
Comment 8 Joseph S. Myers 2006-02-10 20:16:30 UTC
Fixed by my patch <http://gcc.gnu.org/ml/gcc-patches/2006-02/msg00843.html>, pending review.  I add a config/os/uclibc directory as suggested in comment#4.
Comment 9 Joseph S. Myers 2006-02-16 23:29:16 UTC
Subject: Bug 14939

Author: jsm28
Date: Thu Feb 16 23:29:10 2006
New Revision: 111160

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111160
Log:
gcc:
	PR target/20353
	PR target/24578
	PR target/24837
	* config/linux.opt: New file.
	* config/linux.h (CHOOSE_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER,
	LINUX_DYNAMIC_LINKER): Define.
	(TARGET_C99_FUNCTIONS): Define depending on TARGET_GLIBC.
	* config.gcc (*-*-linux*): Define extra_options.
	(*-*-*uclibc*): Define UCLIBC_DEFAULT.
	(arm*-*-linux-gnueabi): Change to arm*-*-linux-*eabi.
	* config/arm/linux-eabi.h (LINUX_TARGET_INTERPRETER): Change to
	GLIBC_DYNAMIC_LINKER.
	* config/arm/linux-elf.h (LINUX_TARGET_INTERPRETER): Likewise.
	(LINUX_TARGET_LINK_SPEC): Use LINUX_DYNAMIC_LINKER.
	* config/mips/linux.h (GLIBC_DYNAMIC_LINKER): Define.
	(LINK_SPEC): Use LINUX_DYNAMIC_LINKER.
	* doc/invoke.texi (GNU/Linux Options): New section.

gcc/testsuite:
	* gcc.dg/builtins-config.h (HAVE_C99_RUNTIME): Don't define if
	__UCLIBC__ is defined.

libstdc++-v3:
	PR libstdc++/14939
	* config/os/uclibc/ctype_base.h, config/os/uclibc/ctype_inline.h,
	config/os/uclibc/ctype_noninline.h, config/os/uclibc/os_defines.h:
	New.
	* acinclude.m4 (GLIBCXX_CONFIGURE): Test whether using uClibc.
	* configure.host: Use os/uclibc for uClibc.
	* crossconfig.m4 (*-linux*): Use link tests.  Don't hardcode
	presence of math functions.
	* configure: Regenerate.

Added:
    trunk/gcc/config/linux.opt
    trunk/libstdc++-v3/config/os/uclibc/
    trunk/libstdc++-v3/config/os/uclibc/ctype_base.h
    trunk/libstdc++-v3/config/os/uclibc/ctype_inline.h
    trunk/libstdc++-v3/config/os/uclibc/ctype_noninline.h
    trunk/libstdc++-v3/config/os/uclibc/os_defines.h
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config.gcc
    trunk/gcc/config/arm/linux-eabi.h
    trunk/gcc/config/arm/linux-elf.h
    trunk/gcc/config/linux.h
    trunk/gcc/config/mips/linux.h
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/builtins-config.h
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/acinclude.m4
    trunk/libstdc++-v3/configure
    trunk/libstdc++-v3/configure.host
    trunk/libstdc++-v3/crossconfig.m4

Comment 10 Joseph S. Myers 2006-02-16 23:38:50 UTC
Subject: Bug 14939

Author: jsm28
Date: Thu Feb 16 23:38:44 2006
New Revision: 111161

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111161
Log:
	PR libstdc++/14939
	PR target/20353
	PR target/24578
	PR target/24837
	* gcc/config/linux.opt: New file.
	* gcc/config/linux.h (CHOOSE_DYNAMIC_LINKER,
	UCLIBC_DYNAMIC_LINKER, LINUX_DYNAMIC_LINKER): Define.
	(TARGET_C99_FUNCTIONS): Define depending on TARGET_GLIBC.
	* gcc/config.gcc (*-*-linux*): Define extra_options.
	(*-*-*uclibc*): Define UCLIBC_DEFAULT.
	(arm*-*-linux-gnueabi): Change to arm*-*-linux-*eabi.
	* gcc/config/arm/linux-eabi.h (LINUX_TARGET_INTERPRETER): Change
	to GLIBC_DYNAMIC_LINKER.
	* gcc/config/arm/linux-elf.h (LINUX_TARGET_INTERPRETER): Likewise.
	(LINUX_TARGET_LINK_SPEC): Use LINUX_DYNAMIC_LINKER.
	* gcc/config/mips/linux.h (GLIBC_DYNAMIC_LINKER): Define.
	(LINK_SPEC): Use LINUX_DYNAMIC_LINKER.
	* gcc/doc/invoke.texi (GNU/Linux Options): New section.
	* gcc/testsuite/gcc.dg/builtins-config.h (HAVE_C99_RUNTIME): Don't
	define if __UCLIBC__ is defined.
	* libstdc++-v3/config/os/uclibc/ctype_base.h,
	libstdc++-v3/config/os/uclibc/ctype_inline.h,
	libstdc++-v3/config/os/uclibc/ctype_noninline.h,
	libstdc++-v3/config/os/uclibc/os_defines.h: New.
	* libstdc++-v3/acinclude.m4 (GLIBCXX_CONFIGURE): Test whether
	using uClibc.
	* libstdc++-v3/configure.host: Use os/uclibc for uClibc.
	* libstdc++-v3/crossconfig.m4 (*-linux*): Use link tests.  Don't
	hardcode presence of math functions.
	* libstdc++-v3/configure: Regenerate.

Added:
    branches/csl/sourcerygxx-4_1/gcc/config/linux.opt
    branches/csl/sourcerygxx-4_1/libstdc++-v3/config/os/uclibc/
    branches/csl/sourcerygxx-4_1/libstdc++-v3/config/os/uclibc/ctype_base.h
    branches/csl/sourcerygxx-4_1/libstdc++-v3/config/os/uclibc/ctype_inline.h
    branches/csl/sourcerygxx-4_1/libstdc++-v3/config/os/uclibc/ctype_noninline.h
    branches/csl/sourcerygxx-4_1/libstdc++-v3/config/os/uclibc/os_defines.h
Modified:
    branches/csl/sourcerygxx-4_1/ChangeLog.csl
    branches/csl/sourcerygxx-4_1/gcc/config.gcc
    branches/csl/sourcerygxx-4_1/gcc/config/arm/linux-eabi.h
    branches/csl/sourcerygxx-4_1/gcc/config/arm/linux-elf.h
    branches/csl/sourcerygxx-4_1/gcc/config/linux.h
    branches/csl/sourcerygxx-4_1/gcc/config/mips/linux.h
    branches/csl/sourcerygxx-4_1/gcc/doc/invoke.texi
    branches/csl/sourcerygxx-4_1/gcc/testsuite/gcc.dg/builtins-config.h
    branches/csl/sourcerygxx-4_1/libstdc++-v3/acinclude.m4
    branches/csl/sourcerygxx-4_1/libstdc++-v3/configure
    branches/csl/sourcerygxx-4_1/libstdc++-v3/configure.host
    branches/csl/sourcerygxx-4_1/libstdc++-v3/crossconfig.m4

Comment 11 Joseph S. Myers 2006-02-16 23:39:45 UTC
Fixed for 4.2.