[PPL-devel] Re: Feature request: optionally compile with support for exceptions

Roberto Bagnara bagnara at cs.unipr.it
Tue Oct 23 11:13:36 CEST 2001


"Niels Möller" wrote:
> 
> Roberto Bagnara <bagnara at cs.unipr.it> writes:
> 
> > it would be nice to be able to write `--enable-exceptions' in the
> > GMP configure command line so that, if GMP is compiled with GCC,
> > the `-fexceptions' option is used.  This is necessary to have,
> > e.g., `bad_alloc' thrown when virtual memory is exhausted and most
> > serious C++ GMP users will want to do that.  Of course, the default
> > can/should be `--disable-exceptions'.
> 
> I think that having compile time options that change these kinds of
> behaviour is asking for trouble. Sooner or later you'll have a system
> where GMP is installed, and you don't know which way it was compiled,
> or you have both variants installed in different places and
> accidentally link with the wrong one. And it probably gets even worse
> with dynamic linking.
> 
> If you want exception raising to be optional, I think you should put
> the two variants into different namespaces, and then you can have
> compile time options for building either or both variants.
> 
> An alternative is of course to "always" build with exceptions, and say
> that the GMP C++ ABI includes raising exceptions under certain
> circumastances. You could leave a compile time option for disabling
> exceptions (changing the ABI), but then you'd have to shoot any
> distributor that ships GMP libraries compiled in that incompatible
> way.

Dear Niels,

what I am asking for is a feature and I am willing to do everything it
requires to minimize the chance of troubles.  That is why I sent a
message to this list.  The feature is very important for our
application (a C++ library for the manipulation of convex polyhedra)
and I believe it is important for all those C++ applications where the
exhaustion of virtual memory cannot simply be handled by writing a
message and aborting.  The feature is so important that I have already
done the modifications I am proposing to GMP 3.1.1.  What I would like
to avoid is having to distribute tar archives and RPMs of the modified
version to the users of our library.

I realize that there is a potential for troubles but I also believe
that solutions can be found.  For the people doing `make install' we
could make sure the exceptions-enabled versions of GMP are installed
under the basename, say `libgmp_e'.  This is not uncommon: on the
Red Hat system I am using I have both the packages

glibc-devel-2.2.4-19
glibc-profile-2.2.4-19

installed.  The first contains /usr/lib/libc.a (the standard thing)
while the second has /usr/lib/libc_p.a (the same library compiled
with the profiling options).  The same can be done for shared
libraries, of course.

> (And at last, you should be able to get what you want with
> 
>   CXXFLAGS=-fexceptions && ./configure && make
> 
> without using any new configure options).

No, CXXFLAGS has nothing to do with what we are talking about.
In fact

1) GMP is written in C;
2) -fexceptions is the GCC default for the compilation of C++ sources,
   so it will be OK even when GMP will include the new C++ interface.

Perhaps you meant

   CFLAGS=-fexceptions && ./configure && make

but this is also a very bad idea in GMP 3.1.1 (the current release),
since `-fexceptions' will _replace_ any other compilation option so
that a good portion of the nice work done by the configure script
is simply lost.  In other words, on the machine I am using this very
moment, I would compile GMP with `-fexceptions' instead of
`-g -O -fomit-frame-pointer -mcpu=pentiumpro', and these (apart
from the strange coexistence of `-g' and `-fomit-frame-pointer')
are also compilation options I definitely want.
All the best,

    Roberto

-- 
Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it



More information about the PPL-devel mailing list