public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compiling only libstdc++-v3 (with debugging symbols)
@ 2011-10-19 12:50 Delcypher
  2011-10-19 13:23 ` Ian Lance Taylor
  0 siblings, 1 reply; 12+ messages in thread
From: Delcypher @ 2011-10-19 12:50 UTC (permalink / raw)
  To: gcc-help

Hi I'm trying to compile libstdc++-v3 with debugging symbols and I'm a
little stuck. I'm trying to follow the documentation
`/libstdc++-v3/doc/html/manual/setup.html' and I'm not finding it very
clear what I'm supposed to do if I want to ONLY build libstdc++-v3 and
NOTHING else.

So far I have

1. Downloaded the entire source tree of the gcc project via svn

$ svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc-root

2. The documentation seems to strongly recommend that my code is NOT
compiled in the source directory so I did the following.

$ mkdir gcc-build
$ cd gcc-build

3. Now here's where I get confused the documentation says "When
configuring libstdc++, you'll have to configure the entire gccsrcdir
directory."

Isn't that going to build everything though? I don't want to do that.
Surely I want to run

$ ../gcc-root/libstdc++-v3/configure --enable-libstdcxx-debug
--prefix=$HOME/local

and NOT (as the documentation suggests)

$ ../gcc-root/configure --enable-languages=c++
--enable-libstdcxx-debug --prefix=$HOME/local

anyway I ran `../gcc-root/libstdc++-v3/configure
--enable-libstdcxx-debug --prefix=$HOME/local'. All the checks passed
a make file was generated in my current directory (gcc-build).

$ ls
config.h  config.log  config.status  doc  include  libsupc++  libtool
Makefile  po  python  scripts  src  stamp-h1  testsuite

4. I tried running make
$ make

and the build fails. The output is shown here http://pastebin.com/p4iD7h4i

The reason I'm trying to do this is so I can build programs on my
system and debug the standard library objects. For example when in gdb
if I try to do the following
gdb) call cout.good()
Couldn't find method std::ostream:;good

I presume this error message is because my version of libstdc++ has no
debugging symbols. I did try compiling with `-D_GLIBCXX_DEBUG' and for
someone reason that I can't explain that made some standard library
objects I declared in the stack accessible via gdb (e.g. if I had an
ifstream object called inputFile) despite the fact my version of
libstdc++ has no debugging symbols at all!

gdb) call inputFile.good()
$1 = true

Without that compiler flag I can't seem to call any of the methods on
standard library objects my code creates.

What am I doing wrong?

Thanks.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 12:50 Compiling only libstdc++-v3 (with debugging symbols) Delcypher
@ 2011-10-19 13:23 ` Ian Lance Taylor
       [not found]   ` <CANNJ_ziT2JqSoRGF9hv3E9QU+PB-AEACwz-8eZkQCqz28LSHcw@mail.gmail.com>
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Lance Taylor @ 2011-10-19 13:23 UTC (permalink / raw)
  To: Delcypher; +Cc: gcc-help

On Wed, Oct 19, 2011 at 5:50 AM, Delcypher <delcypher@gmail.com> wrote:
>
> 3. Now here's where I get confused the documentation says "When
> configuring libstdc++, you'll have to configure the entire gccsrcdir
> directory."
>
> Isn't that going to build everything though? I don't want to do that.
> Surely I want to run
>
> $ ../gcc-root/libstdc++-v3/configure --enable-libstdcxx-debug
> --prefix=$HOME/local
>
> and NOT (as the documentation suggests)
>
> $ ../gcc-root/configure --enable-languages=c++
> --enable-libstdcxx-debug --prefix=$HOME/local

It's hard to know what to say when you decide that the
documentation is wrong.  I understand what you are trying
to do, but it is not supported.


> and the build fails. The output is shown here http://pastebin.com/p4iD7h4i

The failure appears to be that you are compiling libstdc++ with a different
version of g++.  In general you must build libstdc++ with the version of
g++ that it is shipped with.  libstdc++ includes non-standard code which
is dependent on the specific version of the compiler.


> The reason I'm trying to do this is so I can build programs on my
> system and debug the standard library objects. For example when in gdb
> if I try to do the following
> gdb) call cout.good()
> Couldn't find method std::ostream:;good
>
> I presume this error message is because my version of libstdc++ has no
> debugging symbols.

The ordinary build of libstdc++ always builds with debugging symbols.  If you
do not have debugging symbols on your system, it is because the library
has been stripped for some reason.

> I did try compiling with `-D_GLIBCXX_DEBUG' and for
> someone reason that I can't explain that made some standard library
> objects I declared in the stack accessible via gdb (e.g. if I had an
> ifstream object called inputFile) despite the fact my version of
> libstdc++ has no debugging symbols at all!

Many functions in libstdc++ are inlined from header files, and as such are
affected by the use of -g when you compile, rather than whether -g was
used when libstdc++ itself was built.  Note that -D_GLIBCXX_DEBUG
does not affect whether debugging symbols are generated; it produces
a debugging version of the code which adds runtime checks to make
sure that functions are being used correctly.

Ian

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
       [not found]   ` <CANNJ_ziT2JqSoRGF9hv3E9QU+PB-AEACwz-8eZkQCqz28LSHcw@mail.gmail.com>
@ 2011-10-19 15:04     ` Delcypher
  2011-10-19 16:48       ` Jonathan Wakely
  0 siblings, 1 reply; 12+ messages in thread
From: Delcypher @ 2011-10-19 15:04 UTC (permalink / raw)
  To: gcc-help

> It's hard to know what to say when you decide that the
> documentation is wrong.  I understand what you are trying
> to do, but it is not supported.

Sorry I didn't mean to offend.

>> and the build fails. The output is shown here http://pastebin.com/p4iD7h4i
>
> The failure appears to be that you are compiling libstdc++ with a different
> version of g++.  In general you must build libstdc++ with the version of
> g++ that it is shipped with.  libstdc++ includes non-standard code which
> is dependent on the specific version of the compiler.

Okay I've found the correct source tarball that matches the version of
g++ on my system. So now how do I go about building libstdc++ only the
correct way with debugging symbols? Assuming `gcc-root' is the root
source tree as before.

Is running this correct?
$ ../gcc-root/configure --enable-languages=c++
--enable-libstdcxx-debug --prefix=$HOME/local

Will the --enable-libstdcxx-debug option be accepted correctly even
though it's being passed to ../gcc-root/configure rather than
../gcc-root/libstdc++/configure ?

Assuming that's right do I run
$ make all-target-libstdc++-v3

? I found that make target by looking at the script that builds
libstdc++-v3 for my distribution (Arch Linux). If that is the make
target I need to build only libstdc++-v3 then maybe that should be in
the documentation somewhere?


> Many functions in libstdc++ are inlined from header files, and as such are
> affected by the use of -g when you compile, rather than whether -g was
> used when libstdc++ itself was built.  Note that -D_GLIBCXX_DEBUG
> does not affect whether debugging symbols are generated; it produces
> a debugging version of the code which adds runtime checks to make
> sure that functions are being used correctly.

That's good to know.

Thanks for the very informative reply.

All the best,
Dan.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 15:04     ` Delcypher
@ 2011-10-19 16:48       ` Jonathan Wakely
  2011-10-19 16:50         ` Jonathan Wakely
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Wakely @ 2011-10-19 16:48 UTC (permalink / raw)
  To: Delcypher; +Cc: gcc-help

On 19 October 2011 16:03, Delcypher wrote:
>>
>> The failure appears to be that you are compiling libstdc++ with a different
>> version of g++.  In general you must build libstdc++ with the version of
>> g++ that it is shipped with.  libstdc++ includes non-standard code which
>> is dependent on the specific version of the compiler.
>
> Okay I've found the correct source tarball that matches the version of
> g++ on my system. So now how do I go about building libstdc++ only the
> correct way with debugging symbols? Assuming `gcc-root' is the root
> source tree as before.
>
> Is running this correct?
> $ ../gcc-root/configure --enable-languages=c++
> --enable-libstdcxx-debug --prefix=$HOME/local
>
> Will the --enable-libstdcxx-debug option be accepted correctly even
> though it's being passed to ../gcc-root/configure rather than
> ../gcc-root/libstdc++/configure ?

Yes.  That will put unoptimised, unstripped copies of libstdc++.so
etc. in $PREFIX/lib/debug

> Assuming that's right do I run
> $ make all-target-libstdc++-v3
>
> ? I found that make target by looking at the script that builds
> libstdc++-v3 for my distribution (Arch Linux). If that is the make
> target I need to build only libstdc++-v3 then maybe that should be in
> the documentation somewhere?

Why?  I've not heard of anyone trying to build only libstdc++ before,
it's usually built as part of the compiler.

IMHO the documentation is correct - had you followed it instead of
second-guessing it you'd have got what you wanted.

>> Many functions in libstdc++ are inlined from header files, and as such are
>> affected by the use of -g when you compile, rather than whether -g was
>> used when libstdc++ itself was built.  Note that -D_GLIBCXX_DEBUG
>> does not affect whether debugging symbols are generated; it produces
>> a debugging version of the code which adds runtime checks to make
>> sure that functions are being used correctly.
>
> That's good to know.

You really, really don't want to build libstdc++.so itself with
_GLIBCXX_DEBUG defined. It's for you to define when compiling *your*
code.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 16:48       ` Jonathan Wakely
@ 2011-10-19 16:50         ` Jonathan Wakely
  2011-10-19 19:53           ` Delcypher
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Wakely @ 2011-10-19 16:50 UTC (permalink / raw)
  To: Delcypher; +Cc: gcc-help

On 19 October 2011 17:48, Jonathan Wakely wrote:
>
> Why?  I've not heard of anyone trying to build only libstdc++ before,

At least, not since around when GCC 3.0 was released, when
libstdc++-v3 was bundled with gcc, and dependent on a specific
release.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 16:50         ` Jonathan Wakely
@ 2011-10-19 19:53           ` Delcypher
  2011-10-19 20:12             ` Jeffrey Walton
  2011-10-19 22:13             ` Jonathan Wakely
  0 siblings, 2 replies; 12+ messages in thread
From: Delcypher @ 2011-10-19 19:53 UTC (permalink / raw)
  To: gcc-help

On 19 October 2011 17:50, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 19 October 2011 17:48, Jonathan Wakely wrote:
>>
>> Why?  I've not heard of anyone trying to build only libstdc++ before,

My reason is simply that I wanted libstdc++ with debugging symbols on
my machine as my distro (Arch Linux) seems to strip them. It seems
perfectly reasonable to me to want to build only libstdc++ and not the
whole gcc project because building the whole project is a complete
waste of time seeing as I already have the other binaries compiled on
my system from my distribution's packages.

However as Ian very helpfully pointed out, I can only do this if I
have the source code for libstdc++ that matches the version of g++ on
my system. In other words I need to use the same source that my distro
used to build my packages. It turned out my distribution requires me
to modify the script that builds the gnu-libs package to not strip the
debugging symbols, then compile, rebuild the gnu-libs package and then
install this package. I did this and it showed quite nicely how my
distribution builds its package containing libstdc++ .

Dan.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 19:53           ` Delcypher
@ 2011-10-19 20:12             ` Jeffrey Walton
  2011-10-19 22:20               ` Jonathan Wakely
  2011-10-19 22:13             ` Jonathan Wakely
  1 sibling, 1 reply; 12+ messages in thread
From: Jeffrey Walton @ 2011-10-19 20:12 UTC (permalink / raw)
  To: Delcypher; +Cc: gcc-help

On Wed, Oct 19, 2011 at 3:53 PM, Delcypher <delcypher@gmail.com> wrote:
> On 19 October 2011 17:50, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> On 19 October 2011 17:48, Jonathan Wakely wrote:
>>>
>>> Why?  I've not heard of anyone trying to build only libstdc++ before,
>
> My reason is simply that I wanted libstdc++ with debugging symbols on
> my machine as my distro (Arch Linux) seems to strip them. It seems
> perfectly reasonable to me to want to build only libstdc++ and not the
> whole gcc project because building the whole project is a complete
> waste of time seeing as I already have the other binaries compiled on
> my system from my distribution's packages.
Does Arch Linux not offer devel and debug packages for libstdc++? I
would hope they don't just discard it.

Debian, Ubuntu, Fedora, et al, offer them as a separate install, but
they are available.
$ dpkg -l | grep -i libstdc++*
ii  libstdc++6                            4.4.3-4ubuntu5
                   The GNU Standard C++ Library v3
ii  libstdc++6-4.4-dev                    4.4.3-4ubuntu5
                   The GNU Standard C++ Library v3 (development

Jeff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 19:53           ` Delcypher
  2011-10-19 20:12             ` Jeffrey Walton
@ 2011-10-19 22:13             ` Jonathan Wakely
  1 sibling, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2011-10-19 22:13 UTC (permalink / raw)
  To: Delcypher; +Cc: gcc-help

On 19 October 2011 20:53, Delcypher wrote:
> On 19 October 2011 17:50, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> On 19 October 2011 17:48, Jonathan Wakely wrote:
>>>
>>> Why?  I've not heard of anyone trying to build only libstdc++ before,
>
> My reason is simply that I wanted libstdc++ with debugging symbols on
> my machine as my distro (Arch Linux) seems to strip them. It seems
> perfectly reasonable to me to want to build only libstdc++ and not the
> whole gcc project because building the whole project is a complete
> waste of time seeing as I already have the other binaries compiled on
> my system from my distribution's packages.

I understand that, and it is perfectly reasonable, but it's not a
common case, so changing the docs to support a rare use case doesn't
make a lot of sense.

If we documented every unusual scenario the docs would be cluttered
with info that's irrelevant to 99% of people.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 20:12             ` Jeffrey Walton
@ 2011-10-19 22:20               ` Jonathan Wakely
  2011-10-19 22:25                 ` Delcypher
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Wakely @ 2011-10-19 22:20 UTC (permalink / raw)
  To: noloader; +Cc: Delcypher, gcc-help

On 19 October 2011 21:12, Jeffrey Walton wrote:
> Does Arch Linux not offer devel and debug packages for libstdc++? I
> would hope they don't just discard it.
>
> Debian, Ubuntu, Fedora, et al, offer them as a separate install, but
> they are available.
> $ dpkg -l | grep -i libstdc++*
> ii  libstdc++6                            4.4.3-4ubuntu5
>                   The GNU Standard C++ Library v3
> ii  libstdc++6-4.4-dev                    4.4.3-4ubuntu5
>                   The GNU Standard C++ Library v3 (development


I don't know about Ubuntu's packages, but the Fedora libstdc++-devel
package does not include the libs built by configuring with
--enable-libstdcxx-debug

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 22:20               ` Jonathan Wakely
@ 2011-10-19 22:25                 ` Delcypher
  2011-10-19 23:49                   ` Jonathan Wakely
  2011-10-20  0:02                   ` Ian Lance Taylor
  0 siblings, 2 replies; 12+ messages in thread
From: Delcypher @ 2011-10-19 22:25 UTC (permalink / raw)
  To: gcc-help

As far as I know Arch Linux does not provide debugging versions of the
libraries it uses.

Package search:
http://www.archlinux.org/packages/?sort=&q=libstdc%2B%2B&maintainer=&last_update=&flagged=&limit=50

Information about getting debugging info in Arch Linux:
https://wiki.archlinux.org/index.php/Debug_-_Getting_Traces

It's not a huge problem now as I've managed to build libstdc++ with
debug symbols. It is a little annoying though.

Out of interest when you do build using --enable-libstdcxx-debug . How
do you tell g++ to use the separately built debugging libraries?

Dan.


On 19 October 2011 23:19, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 19 October 2011 21:12, Jeffrey Walton wrote:
>> Does Arch Linux not offer devel and debug packages for libstdc++? I
>> would hope they don't just discard it.
>>
>> Debian, Ubuntu, Fedora, et al, offer them as a separate install, but
>> they are available.
>> $ dpkg -l | grep -i libstdc++*
>> ii  libstdc++6                            4.4.3-4ubuntu5
>>                   The GNU Standard C++ Library v3
>> ii  libstdc++6-4.4-dev                    4.4.3-4ubuntu5
>>                   The GNU Standard C++ Library v3 (development
>
>
> I don't know about Ubuntu's packages, but the Fedora libstdc++-devel
> package does not include the libs built by configuring with
> --enable-libstdcxx-debug
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 22:25                 ` Delcypher
@ 2011-10-19 23:49                   ` Jonathan Wakely
  2011-10-20  0:02                   ` Ian Lance Taylor
  1 sibling, 0 replies; 12+ messages in thread
From: Jonathan Wakely @ 2011-10-19 23:49 UTC (permalink / raw)
  To: Delcypher; +Cc: gcc-help

On 19 October 2011 23:25, Delcypher wrote:
>
> Out of interest when you do build using --enable-libstdcxx-debug . How
> do you tell g++ to use the separately built debugging libraries?

Using LD_LIBRARY_PATH, see
http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Compiling only libstdc++-v3 (with debugging symbols)
  2011-10-19 22:25                 ` Delcypher
  2011-10-19 23:49                   ` Jonathan Wakely
@ 2011-10-20  0:02                   ` Ian Lance Taylor
  1 sibling, 0 replies; 12+ messages in thread
From: Ian Lance Taylor @ 2011-10-20  0:02 UTC (permalink / raw)
  To: Delcypher; +Cc: gcc-help

Delcypher <delcypher@gmail.com> writes:

> Out of interest when you do build using --enable-libstdcxx-debug . How
> do you tell g++ to use the separately built debugging libraries?

It's gdb that you need to tell about the libraries.  When everything is
configured properly, you don't need to tell gdb anything.  Otherwise,
use "set debug-file-directory" to tell gdb where to look for the debug
files.  See the gdb manual for details.

Ian

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-10-20  0:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-19 12:50 Compiling only libstdc++-v3 (with debugging symbols) Delcypher
2011-10-19 13:23 ` Ian Lance Taylor
     [not found]   ` <CANNJ_ziT2JqSoRGF9hv3E9QU+PB-AEACwz-8eZkQCqz28LSHcw@mail.gmail.com>
2011-10-19 15:04     ` Delcypher
2011-10-19 16:48       ` Jonathan Wakely
2011-10-19 16:50         ` Jonathan Wakely
2011-10-19 19:53           ` Delcypher
2011-10-19 20:12             ` Jeffrey Walton
2011-10-19 22:20               ` Jonathan Wakely
2011-10-19 22:25                 ` Delcypher
2011-10-19 23:49                   ` Jonathan Wakely
2011-10-20  0:02                   ` Ian Lance Taylor
2011-10-19 22:13             ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).