[RFC] Reduce code bloat caused by demangler (was: Don't access fpos_t.__state on uClibc w/o wchar support)
Tibor Földes
tfoeldes@comple.at
Mon Sep 29 11:46:00 GMT 2003
Pétur Runólfsson schrieb:
> Bernardo Innocenti wrote:
>
>>Actually, there are bigger outstanding problems in 3.4: the new
>>demangler gets linked in as soon as the program uses exceptions,
>>bringing 200KB worth of code with it.
>
>
> Does the following patch help? This doesn't remove the dependency
> of the demangler on std::string; instead it breaks the dependency
> of std::string on ios_base by moving ios_base::failure into a
> separate source file.
>
> Warning! This patch uncovers a latent bug in locale::classic().
> It seems that locale::classic() depends on ios_base::Init::Init()
> always being called at the beginning of the program. If there is
> enough interest, I'll try to find a fix.
>
> Petur
>
>
> Index: include/stdc++.h
> ===================================================================
> RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/include/stdc++.h,v
> retrieving revision 1.1.1.1
> diff -c -3 -p -r1.1.1.1 stdc++.h
> *** include/stdc++.h 19 Mar 2003 23:03:34 -0000 1.1.1.1
> --- include/stdc++.h 26 Sep 2003 22:33:34 -0000
> ***************
> *** 58,64 ****
> #include <iomanip>
> #include <ios>
> #include <iosfwd>
> - #include <iostream>
> #include <istream>
> #include <iterator>
> #include <limits>
> --- 58,63 ----
> Index: include/bits/ios_base.h
> ===================================================================
> RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/include/bits/ios_base.h,v
> retrieving revision 1.1.1.9
> diff -c -3 -p -r1.1.1.9 ios_base.h
> *** include/bits/ios_base.h 19 Jul 2003 21:05:25 -0000 1.1.1.9
> --- include/bits/ios_base.h 27 Sep 2003 08:50:05 -0000
> ***************
> *** 29,35 ****
> // the GNU General Public License.
>
> //
> ! // ISO C++ 14882: 27.8 File-based streams
> //
>
> /** @file ios_base.h
> --- 29,35 ----
> // the GNU General Public License.
>
> //
> ! // ISO C++ 14882: 27.4 Iostreams base classes
> //
>
> /** @file ios_base.h
> *************** namespace std
> *** 167,173 ****
> #ifdef _GLIBCXX_RESOLVE_LIB_DEFECTS
> //48. Use of non-existent exception constructor
> explicit
> ! failure(const string& __str) throw();
>
> // This declaration is not useless:
> // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
> --- 167,173 ----
> #ifdef _GLIBCXX_RESOLVE_LIB_DEFECTS
> //48. Use of non-existent exception constructor
> explicit
> ! failure(const string& __arg) throw();
>
> // This declaration is not useless:
> // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
> *************** namespace std
> *** 178,185 ****
> what() const throw();
>
> private:
> ! enum { _S_bufsize = 256 };
> ! char _M_name[_S_bufsize];
> #endif
> };
>
> --- 178,184 ----
> what() const throw();
>
> private:
> ! string _M_msg;
> #endif
> };
>
> Index: src/Makefile.am
> ===================================================================
> RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/src/Makefile.am,v
> retrieving revision 1.1.1.10
> diff -c -3 -p -r1.1.1.10 Makefile.am
> *** src/Makefile.am 26 Sep 2003 15:29:49 -0000 1.1.1.10
> --- src/Makefile.am 27 Sep 2003 08:50:27 -0000
> *************** sources = \
> *** 103,108 ****
> --- 103,109 ----
> globals.cc \
> io-inst.cc \
> ios.cc \
> + ios_failure.cc \
> istream-inst.cc \
> limits.cc \
> locale.cc \
> Index: src/Makefile.in
> ===================================================================
> RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/src/Makefile.in,v
> retrieving revision 1.1.1.11
> diff -c -3 -p -r1.1.1.11 Makefile.in
> *** src/Makefile.in 26 Sep 2003 15:29:49 -0000 1.1.1.11
> --- src/Makefile.in 27 Sep 2003 08:51:19 -0000
> *************** sources = \
> *** 262,267 ****
> --- 262,268 ----
> globals.cc \
> io-inst.cc \
> ios.cc \
> + ios_failure.cc \
> istream-inst.cc \
> limits.cc \
> locale.cc \
> *************** am__objects_2 = basic_file.lo c++locale.
> *** 357,363 ****
> am__objects_3 = allocator-inst.lo codecvt.lo complex_io.lo \
> concept-inst.lo ctype.lo demangle.lo ext-inst.lo \
> fstream-inst.lo functexcept.lo globals.lo io-inst.lo ios.lo \
> ! istream-inst.lo limits.lo locale.lo locale-inst.lo \
> localename.lo misc-inst.lo ostream-inst.lo sstream-inst.lo \
> stdexcept.lo stl_tree.lo streambuf-inst.lo string-inst.lo \
> strstream.lo valarray-inst.lo wstring-inst.lo $(am__objects_1) \
> --- 358,364 ----
> am__objects_3 = allocator-inst.lo codecvt.lo complex_io.lo \
> concept-inst.lo ctype.lo demangle.lo ext-inst.lo \
> fstream-inst.lo functexcept.lo globals.lo io-inst.lo ios.lo \
> ! ios_failure.lo istream-inst.lo limits.lo locale.lo locale-inst.lo \
> localename.lo misc-inst.lo ostream-inst.lo sstream-inst.lo \
> stdexcept.lo stl_tree.lo streambuf-inst.lo string-inst.lo \
> strstream.lo valarray-inst.lo wstring-inst.lo $(am__objects_1) \
> Index: src/io-inst.cc
> ===================================================================
> RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/src/io-inst.cc,v
> retrieving revision 1.1.1.2
> diff -c -3 -p -r1.1.1.2 io-inst.cc
> *** src/io-inst.cc 6 Jul 2003 20:51:58 -0000 1.1.1.2
> --- src/io-inst.cc 26 Sep 2003 22:29:30 -0000
> ***************
> *** 1,6 ****
> // Explicit instantiation file.
>
> ! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
> // Free Software Foundation, Inc.
> //
> // This file is part of the GNU ISO C++ Library. This library is free
> --- 1,6 ----
> // Explicit instantiation file.
>
> ! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
> // Free Software Foundation, Inc.
> //
> // This file is part of the GNU ISO C++ Library. This library is free
> ***************
> *** 34,40 ****
>
> #include <ios>
> #include <iomanip>
> ! #include <iostream>
>
> namespace std
> {
> --- 34,40 ----
>
> #include <ios>
> #include <iomanip>
> ! #include <istream>
>
> namespace std
> {
> Index: src/ios.cc
> ===================================================================
> RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/src/ios.cc,v
> retrieving revision 1.1.1.11
> diff -c -3 -p -r1.1.1.11 ios.cc
> *** src/ios.cc 17 Sep 2003 13:13:32 -0000 1.1.1.11
> --- src/ios.cc 27 Sep 2003 08:44:15 -0000
> *************** namespace std
> *** 149,167 ****
> int ios_base::Init::_S_ios_base_init = 0;
> bool ios_base::Init::_S_synced_with_stdio = true;
>
> - ios_base::failure::failure(const string& __str) throw()
> - {
> - strncpy(_M_name, __str.c_str(), _S_bufsize);
> - _M_name[_S_bufsize - 1] = '\0';
> - }
> -
> - ios_base::failure::~failure() throw()
> - { }
> -
> - const char*
> - ios_base::failure::what() const throw()
> - { return _M_name; }
> -
> ios_base::Init::Init()
> {
> if (_S_ios_base_init == 0)
> --- 149,154 ----
> Index: src/ios_failure.cc
> ===================================================================
> RCS file: src/ios_failure.cc
> diff -N src/ios_failure.cc
> *** /dev/null 1 Jan 1970 00:00:00 -0000
> --- src/ios_failure.cc 27 Sep 2003 08:44:13 -0000
> ***************
> *** 0 ****
> --- 1,48 ----
> + // Iostreams base classes -*- C++ -*-
> +
> + // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
> + // Free Software Foundation, Inc.
> + //
> + // This file is part of the GNU ISO C++ Library. This library is free
> + // software; you can redistribute it and/or modify it under the
> + // terms of the GNU General Public License as published by the
> + // Free Software Foundation; either version 2, or (at your option)
> + // any later version.
> +
> + // This library is distributed in the hope that it will be useful,
> + // but WITHOUT ANY WARRANTY; without even the implied warranty of
> + // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + // GNU General Public License for more details.
> +
> + // You should have received a copy of the GNU General Public License along
> + // with this library; see the file COPYING. If not, write to the Free
> + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
> + // USA.
> +
> + // As a special exception, you may use this file as part of a free software
> + // library without restriction. Specifically, if other files instantiate
> + // templates or use macros or inline functions from this file, or you compile
> + // this file and link it with other files to produce an executable, this
> + // file does not by itself cause the resulting executable to be covered by
> + // the GNU General Public License. This exception does not however
> + // invalidate any other reasons why the executable file might be covered by
> + // the GNU General Public License.
> +
> + //
> + // ISO C++ 14882: 27.4.2.1.1 Class ios_base::failure
> + //
> +
> + #include <ios>
> +
> + namespace std
> + {
> + ios_base::failure::failure(const string& __arg) throw()
> + : _M_msg(__arg) { }
> +
> + ios_base::failure::~failure() throw()
> + { }
> +
> + const char*
> + ios_base::failure::what() const throw()
> + { return _M_msg.c_str(); }
> + } // namespace std
>
>
>
More information about the Libstdc++
mailing list