[PATCH] Slightly better way to __USE_MALLOC

Benjamin Kosnik bkoz@redhat.com
Tue Oct 8 23:49:00 GMT 2002


This is a very interesting patch. I'll let Phil and Loren comment, but I
think this is a good idea. Thanks for sharing it.

You might want to document the --enable flag in configopts.html. Notice
that most of the ABI breaking configure flags are explicitly marked.
This option should be as well.

> Hi, all..  When debugging recently, I found it necessary to use a 
> __USE_MALLOCed version of the library.  Having followed the
> discussions about this topic a while back, I was aware that doing this
> is somewhat clumsy and (perhaps) error-prone.  After I had actually
> rebuilt the library (and found my bug quite quickly with "mpatrol",
> BTW), 

mpatrol?

> I'm no configure wizard, but I think I managed to hack together
> a patch that creates a new "--enable-use-malloc=yes" feature.  I
> changed __USE_MALLOC to be _GLIBCPP_USE_MALLOC in the process, and
> eliminated the "#if defined" check in c++config because I think the
> linker will always notice if you mismatch allocation mechanisms
> between library and application.

This is acceptable to me.

> I plan to use this with my build system to let me do something like
> 
>   g++ -D_GLIBCPP_USE_MALLOC -L$prefix/.../lib/debug
> 
> by placing a "use-malloc"-built version of the library in the debug
> directory inside the compiler's installation.  Someone more familiar
> with configure could probably make this happen automatically (by
> building and installing the library twice) when --enable-use-malloc
> was enabled (or perhaps set to "as-alternate" or something).

Hmmm. This is another interesting idea.

At some point, something like this should be done in a more general way
so that an un-optimized, debug version of libstdc++ could be built and
lurk for later use. It seems to be generally useful, both for debugging
and use with other tools like valgrind, etc.

> 2002-10-08  Brad Spencer <spencer@infointeractive.com>
> 
>         * acconfig.h, acinclude.m4, config.h.in, configure.in,
>         include/backward/alloc.h, include/bits/c++config,
>         include/bits/stl_alloc.h, src/stl-inst.cc: Changed
>         __USE_MALLOC to _GLIBCPP_USE_MALLOC and added 
>         --enable-use-malloc to configure.

Looks pretty good to me.

-benjamin



More information about the Libstdc++ mailing list