[c++] i686 toolchain additional shared fails

Peter Schmid schmid@snake.iap.physik.tu-darmstadt.de
Fri Jan 12 06:43:00 GMT 2001


After applying the following patches to the current cvs sources

*** /home/peter/egcs/gcc/libstdc++-v3/src/string-inst.cc~	Thu Jan  4 12:11:25 2001
--- /home/peter/egcs/gcc/libstdc++-v3/src/string-inst.cc	Fri Jan 12 12:54:35 2001
***************
*** 39,44 ****
--- 39,45 ----
  // Instantiation configuration.
  #ifndef C
  # define C char
+ # define _GLIBCPP_INSTANTIATING_CHAR 1
  #endif
  
  namespace std 
*************** namespace std 
*** 73,78 ****
--- 74,100 ----
  
    template 
      S::basic_string(S::iterator, S::iterator, const allocator<C>&);
+ 
+ // These members are explicitly specialized, and can only be in one
+ // translation unit or else we get multiple copies. . . 
+ #if _GLIBCPP_INSTANTIATING_CHAR
+   template<>
+     const char* 
+     string::_S_find(const char* __beg, const char* __end, char __c)
+     { 
+       const char* __ret = strchr(__beg, __c); 
+       return (__ret ? __ret : __end);
+     }
+ #elif defined(_GLIBCPP_USE_WCHAR_T)
+   template<>
+     const wchar_t* 
+     wstring::_S_find(const wchar_t* __beg, const wchar_t* __end, wchar_t __c)
+     {
+       return find_if(__beg, __end, 
+ 		     _Char_traits_match<wchar_t, traits_type>(__c));
+     }
+ #endif
+ 
  } // namespace std
  
  
*** /home/peter/egcs/gcc/libstdc++-v3/include/bits/basic_string.tcc~	Fri Jan 12 12:34:24 2001
--- /home/peter/egcs/gcc/libstdc++-v3/include/bits/basic_string.tcc	Fri Jan 12 12:57:43 2001
*************** namespace std
*** 836,841 ****
--- 836,853 ----
        __buf[__bytes] = _CharT();
      }
  
+ // Specialization for char, definitions in src/string-inst.cc.
+   template<>
+     const char*
+     string::_S_find(const char* __beg, const char* __end, char __c);
+ 
+ // Specialization for wchar_t.
+ #ifdef _GLIBCPP_USE_WCHAR_T
+   template<>
+     const wchar_t*
+     wstring::_S_find(const wchar_t* __beg, const wchar_t* __end, wchar_t __c);
+ #endif
+     
  } // std::
  
  #endif /* _CPP_BITS_STRING_TCC */

as suggested by the previous message
< http://gcc.gnu.org/ml/libstdc++/2001-01/msg00139.html >
all dynamically built executables run successfully, as demonstrated by
the appended logfile. 

This patch has surprising consequences, for
example, named locales seem to work again. Code like 

#include <iostream>
#include <locale>
using namespace std;

int main()
{
    cin.imbue(locale::classic());
    cout.imbue(locale("de_DE"));
    double value;
    while (cin >> value) {
        cout << value << endl;
    }
}

is compiled into a working executable, except that EOF is not handled correctly
if pressed on the keyboard or via io-redirection, and therefore the
output never terminates, if not killed by a signal. 

But not all statically linked executables work as expected. If I
install the compiler, and the support libraries, and copy the source
code of the failing executable and debug_assert in another directory,
everything works if the executable is linked *completely* dynamically
or statically. But if the static libstdc++-library is linked against
the shared libc-library some executables, for example append.cc do not
work. Maybe this problem is glibc-2.1.3 related. Does linking a static
library against a dynamic libc not work on this target? 

Surprisingly, the backtrace of a segfaulting program looks similar to
those of the failing dynamically linked executables before checking in
the above patches. 

I am not shure if the patches really fix the problem or only disguise
underlying problems.

Peter Schmid

peter@kiste:~/trans/check > g++ -ggdb3 -DDEBUG_ASSERT -ffunction-sections -fdata-sections -o append append.cc -I.
peter@kiste:~/trans/check > ./append
peter@kiste:~/trans/check > echo $?
0
peter@kiste:~/trans/check > g++ -ggdb3 -DDEBUG_ASSERT -ffunction-sections -fdata-sections -o append append.cc -I. -static
peter@kiste:~/trans/check > ./append
peter@kiste:~/trans/check > echo $?
0

peter@kiste:~/trans/check > g++ -ggdb3 -DDEBUG_ASSERT -ffunction-sections -fdata-sections -o append append.cc -I. /usr/local/lib/libstdc++.a 
peter@kiste:~/trans/check > ./append
Segmentation fault (core dumped)
peter@kiste:~/trans/check > echo $?
139

peter@kiste:~/trans/check > g++ -nodefaultlibs -ggdb3 -DDEBUG_ASSERT -ffunction-sections -fdata-sections -o append append.cc -I. /usr/local/lib/libstdc++.a -lc -lm -lgcc
peter@kiste:~/trans/check > ./append
Segmentation fault (core dumped)
peter@kiste:~/trans/check > echo $?
139
peter@kiste:~/trans/check > ldd append
	libc.so.6 => /lib/libc.so.6 (0x40018000)
	libm.so.6 => /lib/libm.so.6 (0x400fa000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) r
Starting program: /home/peter/trans/check/append 

Program received signal SIGSEGV, Segmentation fault.
0x8049686 in next_stack_level (pc=0x804aae5, udata=0xbffff43c, 
    caller_udata=0xbffff3bc)
Current language:  auto; currently c
(gdb) where
#0  0x8049686 in next_stack_level (pc=0x804aae5, udata=0xbffff43c, 
    caller_udata=0xbffff3bc)
#1  0x8049790 in throw_helper (eh=0x8057960, pc=0x804aae5, 
    my_udata=0xbffff4fc, offset_p=0xbffff4f8)
#2  0x8049b2a in __throw ()
#3  0x804aae6 in _ZSt14__out_of_rangePKc (str=0x8052bd9 "__pos > this->size()")
    at ../../../../gcc/libstdc++-v3/src/stdexcept.cc:54
#4  0x804d766 in _ZNKSs8_M_checkEj (this=0xbffff7bc, __pos=1)
    at /usr/local/include/g++-v3/bits/basic_string.h:265
#5  0x804cd44 in _ZNSs6appendERKSsjj (this=0xbffff7ac, __str=@0xbffff7bc, 
    __pos=1, __n=0) at /usr/local/include/g++-v3/bits/basic_string.tcc:490
#6  0x8049ec8 in _Z6test01v () at append.cc:46
#7  0x804a94b in main () at append.cc:162
#8  0x40030a4e in __libc_start_main (main=0x804a940 <main>, argc=1, 
    argv=0xbffff8ac, init=0x8048b2c <_init>, fini=0x8052850 <_fini>, 
    rtld_fini=0x4000aa20 <_dl_fini>, stack_end=0xbffff8a4)
    at ../sysdeps/generic/libc-start.c:92
(gdb) 


host: Linux 2.4.0-test12 #22 Sun Dec 17 17:24:36 CET 2000 i686
compiler: Reading specs from /home/peter/egcs/build/i686-pc-linux-gnu/libstdc++-v3/../../gcc/specs
Configured with: ../gcc/configure --enable-shared --disable-nls
gcc version 2.97 20010111 (experimental)
g++: No input files
compiler flags: -ggdb3 -DDEBUG_ASSERT -ffunction-sections -fdata-sections
date: 20010112
pass/fail results:  99/2 shared + 91/10 static = 190/12 total

p == pass/fail execution test
     +: pass, -b: build failure, -r: run failure, x: disabled
ctime == time to compile and link
etime == time for executable to run
text == size of the executable text section
data == size of the executable data section
total == size of the executable

p ctime	etime	text	data	total	name	
+  1	0.166	729	24	9859	17_intro/header_ciso646.cc -static
+  1	0.182	729	24	10190	17_intro/header_ciso646.cc 

+  2	0.166	358	24	18499	17_intro/header_cstdio.cc -static
+  2	0.178	358	24	18830	17_intro/header_cstdio.cc 

+  1	0.166	358	24	18238	17_intro/header_cstdlib.cc -static
+  1	0.202	358	24	18569	17_intro/header_cstdlib.cc 

+  2	0.167	370	24	9802	17_intro/header_cstring.cc -static
+  1	0.179	370	24	10133	17_intro/header_cstring.cc 

+  1	0.168	358	24	15176	17_intro/header_ctime.cc -static
+  2	0.185	358	24	15507	17_intro/header_ctime.cc 

+  1	0.170	358	24	19421	17_intro/header_cwchar.cc -static
+  1	0.177	358	24	19752	17_intro/header_cwchar.cc 

+  1	0.166	346	24	8753	17_intro/header_cwctype.cc -static
+  1	0.179	346	24	9084	17_intro/header_cwctype.cc 

+  6	0.166	346	28	185199	17_intro/header_fstream.cc -static
+  6	0.179	346	28	185853	17_intro/header_fstream.cc 

+  4	0.166	346	24	130694	17_intro/header_iomanip.cc -static
+  5	0.178	346	24	131025	17_intro/header_iomanip.cc 

+  3	0.166	346	24	96309	17_intro/header_ios.cc -static
+  3	0.189	346	24	96640	17_intro/header_ios.cc 

+  1	0.165	346	24	20327	17_intro/header_iosfwd.cc -static
+  2	0.217	346	24	20658	17_intro/header_iosfwd.cc 

+  5	0.167	176750	6504	1926006	17_intro/header_iostream.cc -static
+  4	0.180	492	24	128065	17_intro/header_iostream.cc 

+  4	0.169	346	24	126867	17_intro/header_istream.cc -static
+  3	0.177	346	24	127198	17_intro/header_istream.cc 

+  3	0.202	346	24	96317	17_intro/header_ostream.cc -static
+  3	0.177	346	24	96648	17_intro/header_ostream.cc 

+  4	0.166	346	24	126867	17_intro/header_sstream.cc -static
+  4	0.177	346	24	127198	17_intro/header_sstream.cc 

+  4	0.169	346	24	96297	17_intro/header_streambuf.cc -static
+  4	0.177	346	24	96628	17_intro/header_streambuf.cc 

+  10	0.172	176750	6472	2038965	17_intro/headers.cc -static
+  10	0.182	492	28	241415	17_intro/headers.cc 

+  2	0.226	346	24	27529	17_intro/headers_c++.cc -static
+  2	0.177	346	24	27860	17_intro/headers_c++.cc 

+  2	0.166	346	24	27528	17_intro/headers_c.cc -static
+  2	0.181	346	24	27859	17_intro/headers_c.cc 

+  2	0.166	13054	1664	167187	18_support/numeric_limits.cc -static
+  2	0.177	9326	1632	140598	18_support/numeric_limits.cc 

+  3	0.166	20425	1752	211039	20_util/auto_ptr.cc -static
+  3	0.178	16697	1752	184842	20_util/auto_ptr.cc 

-r 6	0.170	39853	1860	587975	21_strings/append.cc -static
+  7	0.233	27182	1728	360211	21_strings/append.cc 

+  8	0.178	39075	1864	543728	21_strings/capacity.cc -static
+  8	0.178	33902	1696	435846	21_strings/capacity.cc 

+  4	0.167	18771	1864	337242	21_strings/char_traits.cc -static
+  4	0.180	13598	1696	227411	21_strings/char_traits.cc 

+  4	0.167	22243	1864	348262	21_strings/compare.cc -static
+  4	0.179	17070	1696	239503	21_strings/compare.cc 

-r 6	0.167	27139	1848	434646	21_strings/ctor_copy_dtor.cc -static
+  6	0.180	21966	1728	326377	21_strings/ctor_copy_dtor.cc 

-r 4	0.170	19603	1860	341226	21_strings/element_access.cc -static
+  4	0.181	14430	1728	232375	21_strings/element_access.cc 

+  5	0.168	183939	6416	1933463	21_strings/find.cc -static
+  4	0.219	17822	1696	237068	21_strings/find.cc 

-r 6	0.167	29875	1848	439202	21_strings/insert.cc -static
+  5	0.178	24702	1728	332113	21_strings/insert.cc 

+  10	0.186	186286	6408	2095956	21_strings/inserters_extractors.cc -static
+  9	0.197	33326	2688	428386	21_strings/inserters_extractors.cc 

+  5	0.169	26931	1864	385234	21_strings/invariants.cc -static
+  5	0.178	21758	1696	277058	21_strings/invariants.cc 

+  5	0.170	33555	1864	409305	21_strings/nonmember.cc -static
+  6	0.221	28382	1696	301108	21_strings/nonmember.cc 

+  4	0.167	20579	1864	344292	21_strings/operations.cc -static
+  4	0.176	15406	1696	235309	21_strings/operations.cc 

+  6	0.169	29731	1864	455083	21_strings/replace.cc -static
+  6	0.177	24558	1696	346845	21_strings/replace.cc 

+  5	0.166	19603	1864	340336	21_strings/rfind.cc -static
+  4	0.176	14430	1696	230765	21_strings/rfind.cc 

-r 5	0.169	22835	1860	385720	21_strings/substr.cc -static
+  4	0.182	17662	1728	277176	21_strings/substr.cc 

+  7	0.177	178446	6464	2015532	22_locale/codecvt_char_char.cc -static
+  6	0.180	11449	1688	319944	22_locale/codecvt_char_char.cc 

+  6	0.167	346	28	185215	22_locale/codecvt_unicode_char.cc -static
+  6	0.176	346	28	185869	22_locale/codecvt_unicode_char.cc 

+  5	0.166	346	28	185221	22_locale/codecvt_unicode_wchar_t.cc -static
+  5	0.176	346	28	185875	22_locale/codecvt_unicode_wchar_t.cc 

+  6	0.167	346	28	185215	22_locale/codecvt_wchar_t_char.cc -static
+  5	0.176	346	28	185869	22_locale/codecvt_wchar_t_char.cc 

+  5	0.168	346	28	185203	22_locale/ctor_copy_dtor.cc -static
+  5	0.176	346	28	185857	22_locale/ctor_copy_dtor.cc 

+  6	0.166	178622	6816	2000897	22_locale/ctype.cc -static
+  6	0.177	10750	2016	307638	22_locale/ctype.cc 

+  6	0.167	180494	6560	1998900	22_locale/ctype_char_members.cc -static
+  6	0.178	12382	1792	295657	22_locale/ctype_char_members.cc 

+  5	0.166	346	28	185217	22_locale/ctype_wchar_t_members.cc -static
+  6	0.175	346	28	185871	22_locale/ctype_wchar_t_members.cc 

+  11	0.166	194238	8328	2212361	22_locale/facet.cc -static
+  11	0.217	43694	5120	559263	22_locale/facet.cc 

+  7	0.170	181310	6592	2036932	22_locale/global_templates.cc -static
+  7	0.177	14974	1856	345358	22_locale/global_templates.cc 

+  7	0.167	181614	6592	2040215	22_locale/operators.cc -static
+  6	0.178	16046	1856	350212	22_locale/operators.cc 

+  7	0.167	181390	6560	2015911	22_locale/static_members.cc -static
+  6	0.178	15598	1824	325226	22_locale/static_members.cc 

-r 7	0.169	187694	6536	2050612	23_containers/bitset_ctor.cc -static
+  7	0.178	22190	1824	356014	23_containers/bitset_ctor.cc 

+  9	0.835	199630	6536	2084157	23_containers/bitset_shift.cc -static
+  8	0.800	32606	1824	386982	23_containers/bitset_shift.cc 

-b 7	0.800	0	0	0	23_containers/map_operators.cc -static
-b 7	0.800	0	0	0	23_containers/map_operators.cc 

+  6	0.000	184974	6440	2032592	23_containers/multiset.cc -static
+  7	0.000	17166	1696	332222	23_containers/multiset.cc 

-b 4	0.000	0	0	0	23_containers/set_operators.cc -static
-b 5	0.000	0	0	0	23_containers/set_operators.cc 

+  4	0.167	20926	1696	287425	23_containers/vector_capacity.cc -static
+  4	0.180	17198	1696	261629	23_containers/vector_capacity.cc 

+  9	0.166	212212	6416	2237305	23_containers/vector_ctor.cc -static
+  9	0.177	44334	1696	537330	23_containers/vector_ctor.cc 

-r 4	0.208	179204	6448	1906500	23_containers/vector_element_access.cc -static
+  4	0.177	11326	1728	206765	23_containers/vector_element_access.cc 

+  5	0.166	29246	1696	422677	23_containers/vector_modifiers.cc -static
+  5	0.177	25518	1696	396881	23_containers/vector_modifiers.cc 

+  6	0.167	184174	6472	2019173	24_iterators/istreambuf_iterator.cc -static
+  6	0.177	22446	2144	335083	24_iterators/istreambuf_iterator.cc 

+  9	0.167	43747	1864	591358	24_iterators/iterator.cc -static
+  9	0.179	38574	1696	482719	24_iterators/iterator.cc 

+  3	0.167	2197	24	92619	25_algorithms/lower_bound.cc -static
+  3	0.177	2197	24	92950	25_algorithms/lower_bound.cc 

+  2	0.169	869	24	61297	25_algorithms/min_max.cc -static
+  3	0.176	869	24	61628	25_algorithms/min_max.cc 

+  8	0.000	181022	6440	2063398	26_numerics/binary_closure.cc -static
+  7	0.000	13417	1688	364953	26_numerics/binary_closure.cc 

+  1	0.166	735	24	29029	26_numerics/buggy_complex.cc -static
+  2	0.177	735	24	29360	26_numerics/buggy_complex.cc 

+  2	0.167	903	24	21543	26_numerics/c_math.cc -static
+  2	0.175	903	24	21930	26_numerics/c_math.cc 

+  7	0.183	194254	6472	2086325	26_numerics/complex_inserters_extractors.cc -static
+  6	0.180	25886	2144	339617	26_numerics/complex_inserters_extractors.cc 

+  2	0.179	1679	24	31553	26_numerics/complex_value.cc -static
+  2	0.176	1679	24	31940	26_numerics/complex_value.cc 

+  6	0.165	14201	1688	263844	26_numerics/valarray.cc -static
+  5	0.176	10473	1688	237736	26_numerics/valarray.cc 

+  8	0.170	188884	6572	2050272	27_io/filebuf.cc -static
+  8	0.218	26894	2080	366575	27_io/filebuf.cc 

+  8	0.167	179284	6464	2022490	27_io/filebuf_members.cc -static
+  7	0.177	15566	1952	333426	27_io/filebuf_members.cc 

+  4	0.165	2283	24	101555	27_io/fpos.cc -static
+  4	0.177	2283	24	101886	27_io/fpos.cc 

+  7	0.396	179108	6464	2019795	27_io/ifstream_members.cc -static
+  7	0.474	15902	1952	331084	27_io/ifstream_members.cc 

+  6	0.166	181758	6472	2002367	27_io/ios_base_callbacks.cc -static
+  6	0.176	18878	1952	314464	27_io/ios_base_callbacks.cc 

+  6	0.168	180686	6504	1995870	27_io/ios_base_members_static.cc -static
+  6	0.178	16750	1984	306481	27_io/ios_base_members_static.cc 

+  6	0.167	180174	6472	2002418	27_io/ios_base_storage.cc -static
+  6	0.178	18222	2144	318015	27_io/ios_base_storage.cc 

+  6	0.166	181774	6472	1998888	27_io/ios_ctor.cc -static
+  5	0.177	18590	1952	310387	27_io/ios_ctor.cc 

+  9	777.000	186478	6536	2086986	27_io/ios_manip_basefield.cc -static
+  8	777.000	26366	2368	407517	27_io/ios_manip_basefield.cc 

+  9	0.000	186766	6536	2091576	27_io/ios_manip_fmtflags.cc -static
+  9	0.000	28062	2464	414766	27_io/ios_manip_fmtflags.cc 

-r 6	0.169	180974	6440	1950801	27_io/ios_members.cc -static
+  4	0.179	14750	1760	255773	27_io/ios_members.cc 

+  3	0.167	346	24	126847	27_io/istream.cc -static
+  4	0.177	346	24	127178	27_io/istream.cc 

+  10	1.000	197454	6952	2092054	27_io/istream_extractor_arith.cc -static
+  10	1.000	40446	3392	419272	27_io/istream_extractor_arith.cc 

+  7	0.167	185950	6472	2011738	27_io/istream_extractor_char.cc -static
+  6	0.177	23678	2080	325453	27_io/istream_extractor_char.cc 

+  9	0.168	186948	6444	2070822	27_io/istream_extractor_other.cc -static
+  8	0.181	25150	2048	385433	27_io/istream_extractor_other.cc 

+  6	0.205	181854	6472	2007589	27_io/istream_manip.cc -static
+  6	0.181	20222	2144	323841	27_io/istream_manip.cc 

+  9	0.167	187950	6408	2078560	27_io/istream_seeks.cc -static
+  9	0.178	30398	2368	401364	27_io/istream_seeks.cc 

+  6	0.166	180670	6472	2001065	27_io/istream_sentry.cc -static
+  5	0.177	17790	2048	312974	27_io/istream_sentry.cc 

+  9	0.199	193246	6440	2093581	27_io/istream_unformatted.cc -static
+  9	0.215	35182	2464	417255	27_io/istream_unformatted.cc 

+  6	0.166	182382	6440	2033973	27_io/istringstream_members.cc -static
+  6	0.178	21758	2144	351965	27_io/istringstream_members.cc 

+  11	0.000	177134	6472	2058354	27_io/narrow_stream_objects.cc -static
+  11	0.000	971	28	262275	27_io/narrow_stream_objects.cc 

+  7	0.471	179252	6464	2019164	27_io/ofstream_members.cc -static
+  7	0.537	15918	1952	330325	27_io/ofstream_members.cc 

+  4	0.167	346	24	96297	27_io/ostream.cc -static
+  4	0.176	346	24	96628	27_io/ostream.cc 

+  10	0.175	191934	6536	2098859	27_io/ostream_inserter_arith.cc -static
+  9	0.185	33390	2560	422008	27_io/ostream_inserter_arith.cc 

+  9	0.344	188766	6408	2087178	27_io/ostream_inserter_char.cc -static
+  9	0.359	32638	2304	412828	27_io/ostream_inserter_char.cc 

+  9	0.175	180814	6408	2047403	27_io/ostream_inserter_other.cc -static
+  8	0.187	22462	2368	369577	27_io/ostream_inserter_other.cc 

+  7	0.166	183886	6472	2036473	27_io/ostream_manip.cc -static
+  7	0.177	24558	2144	356004	27_io/ostream_manip.cc 

+  8	0.169	179134	6408	2040545	27_io/ostream_seeks.cc -static
+  8	0.177	20926	2304	362014	27_io/ostream_seeks.cc 

+  6	0.166	180462	6504	2002209	27_io/ostream_unformatted.cc -static
+  5	0.178	18286	2176	317361	27_io/ostream_unformatted.cc 

+  6	0.166	186958	6664	1984357	27_io/streambuf.cc -static
+  6	0.179	23214	2144	295848	27_io/streambuf.cc 

+  8	0.169	195838	6464	2041612	27_io/stringbuf.cc -static
+  7	0.178	34270	1856	357036	27_io/stringbuf.cc 

+  8	0.170	185070	7048	2059471	27_io/stringstream.cc -static
+  7	0.178	27774	3104	382790	27_io/stringstream.cc 

+  10	0.205	176798	6472	2039168	27_io/wide_stream_objects.cc -static
+  10	0.180	540	28	241618	27_io/wide_stream_objects.cc 

+  7	0.166	176750	6504	2034494	ext/headers.cc -static
+  7	0.178	492	24	236557	ext/headers.cc 

testrun == 1200 seconds



More information about the Libstdc++ mailing list