Commit 4ddbd80e authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Introduce libvcsn-common-ex.la in addition to libvcsn-common.la

to decide whether exceptions should be used in preconditions.

This fixes errors in taf-kit's test-suite when compiled with GCC
4.4.  The code was making the bogus assumption that the inline
function trap() was not inlined in the context libraries (compiled
without exceptions) and could therefore be overwritten as a weak
symbol in TAF-Kit (to use exceptions).

* include/vaucanson/misc/contract.hh (vcsn::misc::contract::trap):
Leave only a declaration and move the definition...
* src/misc/contract.cc: ... in this new file.
* lib/src/libcommon.mk: Adjust for contract.cc and build two
libraries: libvcsn-common.la (with abort()) and
libvcsn-common-ex.la (with exceptions).
* data/automata/char-b/Makefile.am,
data/automata/char-fmp-b/Makefile.am,
data/automata/char-z/Makefile.am, taf-kit/src/Makefile.am,
vaucanswig/meta/Makefile.am, src/tests/sanity/Makefile.am,
src/tests/xml/Makefile.am: Link with libvcsn-common.la or
libvcsn-common-ex.la.
* taf-kit/src/common.hh (EXCEPTION_TRAPS): Remove #define.
* src/bench/common/bench.mk (AM_CPPFLAGS): Remove useless
-DEXCEPTION_TRAPS.
* vaucanswig/expand.sh: Likewise.
* src/tests/check/Makefile.am: Build libcheck.la instead
of libcheck.a, so we can depend on libvcsn-common-ex.la
* src/tests/check/check.mk: Use libcheck.la and
libvcsn-common-ex.la.
* src/tests/test-suites/test-suite.mk: Don't define
EXCEPTION_TRAPS and don't add libvcsn-common-ex.la to LDADD
(check.mk already does it).
parent d8c81c6a
2009-05-13 Alexandre Duret-Lutz <adl@va-et-vient.net>
Introduce libvcsn-common-ex.la in addition to libvcsn-common.la
to decide whether exceptions should be used in preconditions.
This fixes errors in taf-kit's test-suite when compiled with GCC
4.4. The code was making the bogus assumption that the inline
function trap() was not inlined in the context libraries (compiled
without exceptions) and could therefore be overwritten as a weak
symbol in TAF-Kit (to use exceptions).
* include/vaucanson/misc/contract.hh (vcsn::misc::contract::trap):
Leave only a declaration and move the definition...
* src/misc/contract.cc: ... in this new file.
* lib/src/libcommon.mk: Adjust for contract.cc and build two
libraries: libvcsn-common.la (with abort()) and
libvcsn-common-ex.la (with exceptions).
* data/automata/char-b/Makefile.am,
data/automata/char-fmp-b/Makefile.am,
data/automata/char-z/Makefile.am, taf-kit/src/Makefile.am,
vaucanswig/meta/Makefile.am, src/tests/sanity/Makefile.am,
src/tests/xml/Makefile.am: Link with libvcsn-common.la or
libvcsn-common-ex.la.
* taf-kit/src/common.hh (EXCEPTION_TRAPS): Remove #define.
* src/bench/common/bench.mk (AM_CPPFLAGS): Remove useless
-DEXCEPTION_TRAPS.
* vaucanswig/expand.sh: Likewise.
* src/tests/check/Makefile.am: Build libcheck.la instead
of libcheck.a, so we can depend on libvcsn-common-ex.la
* src/tests/check/check.mk: Use libcheck.la and
libvcsn-common-ex.la.
* src/tests/test-suites/test-suite.mk: Don't define
EXCEPTION_TRAPS and don't add libvcsn-common-ex.la to LDADD
(check.mk already does it).
2009-05-13 Alexandre Duret-Lutz <adl@lrde.epita.fr>
 
Rename libkrat_exp.la as libvcsn_common.la, and move lib/krat_exp/
......
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 The
## Vaucanson Group.
##
## This program is free software; you can redistribute it and/or
......@@ -14,6 +14,8 @@
include $(top_srcdir)/vaucanson.mk
LDADD = $(top_builddir)/lib/libvcsn-common.la
noinst_PROGRAMS = a1 b1 divkbaseb ladybird double_ring
nodist_char_b_automata_DATA = \
......
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 The
## Vaucanson Group.
##
## This program is free software; you can redistribute it and/or
......@@ -14,6 +14,8 @@
include $(top_srcdir)/vaucanson.mk
LDADD = $(top_builddir)/lib/libvcsn-common.la
noinst_PROGRAMS = t1 u1 quotkbaseb
nodist_char_fmp_b_automata_DATA = \
......
......@@ -14,6 +14,8 @@
include $(top_srcdir)/vaucanson.mk
LDADD = $(top_builddir)/lib/libvcsn-common.la
# Z automata.
noinst_PROGRAMS = c1 d2
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The Vaucanson Group.
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -29,13 +29,6 @@
# include <iostream>
# include <string>
# ifdef EXCEPTION_TRAPS
# include <sstream>
# include <stdexcept>
# else // ! EXCEPTION_TRAPS
# include <cstdlib>
# endif // EXCEPTION_TRAP
namespace vcsn {
namespace misc {
namespace contract {
......@@ -117,27 +110,9 @@ namespace vcsn {
/** @} */
/// Internal function to report errors in failed contract macros.
inline
void trap (const char *file, int line,
const char *location,
const std::string& message)
{
# ifdef EXCEPTION_TRAPS
std::ostringstream os;
os << file << ':' << line << ':'
<< (location ? location : "")
<< (location ? ": " : " ")
<< message;
throw std::logic_error (os.str ());
# else // ! EXCEPTION_TRAPS
std::cerr << file << ':' << line << ':'
<< (location ? location : "")
<< std::endl
<< '\t' << message
<< std::endl;
abort ();
# endif // EXCEPTION_TRAPS
}
const std::string& message);
template<typename T>
struct fail;
......
......@@ -38,7 +38,20 @@ $(FROM_KRAT_EXP_BISON_YY_OTHERS): $(FROM_KRAT_EXP_BISON_YY_MAIN)
EXTRA_DIST = src/krat_exp/$(KRAT_EXP_BISON_YY)
common_sources = \
$(FROM_KRAT_EXP_BISON_YY) \
src/misc/contract.cc
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib/krat_exp \
-I$(top_builddir)/include \
-I$(top_srcdir)/include
lib_LTLIBRARIES += libvcsn-common.la
libvcsn_common_la_CXXFLAGS = $(CXXFLAGS) -I$(top_srcdir)/src/lib/krat_exp
libvcsn_common_la_LIBADD = $(LIBOBJS)
libvcsn_common_la_SOURCES = $(FROM_KRAT_EXP_BISON_YY)
libvcsn_common_la_LIBADD = $(LIBOBJS)
libvcsn_common_la_SOURCES = $(common_sources)
lib_LTLIBRARIES += libvcsn-common-ex.la
libvcsn_common_ex_la_CPPFLAGS = $(AM_CPPFLAGS) -DEXCEPTION_TRAPS
libvcsn_common_ex_la_LIBADD = $(LIBOBJS)
libvcsn_common_ex_la_SOURCES = $(common_sources)
// contract.cc: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 The
// Vaucanson Group.
//
// This program 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
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
#include <vaucanson/misc/contract.hh>
# ifdef EXCEPTION_TRAPS
# include <sstream>
# include <stdexcept>
# else // ! EXCEPTION_TRAPS
# include <cstdlib>
# endif // EXCEPTION_TRAP
namespace vcsn {
namespace misc {
namespace contract {
void
trap (const char *file, int line,
const char *location,
const std::string& message)
{
# ifdef EXCEPTION_TRAPS
std::ostringstream os;
os << file << ':' << line << ':'
<< (location ? location : "")
<< (location ? ": " : " ")
<< message;
throw std::logic_error (os.str ());
# else // ! EXCEPTION_TRAPS
std::cerr << file << ':' << line << ':'
<< (location ? location : "")
<< std::endl
<< '\t' << message
<< std::endl;
abort ();
# endif // EXCEPTION_TRAPS
}
}
}
}
......@@ -3,6 +3,5 @@
include $(top_srcdir)/vaucanson.mk
AM_CPPFLAGS += -I$(top_srcdir)/src/bench -I$(top_builddir)/src/bench
AM_CPPFLAGS += -DEXCEPTION_TRAPS
AM_CPPFLAGS += -DVCSN_SRC_DIR=\"'\$(top_srcdir)'\"
AM_CPPFLAGS += -DNDEBUG -O3 -DVCSN_BENCH
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 The Vaucanson Group.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009 The Vaucanson Group.
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
......@@ -15,8 +15,10 @@ include $(top_srcdir)/src/tests/check/check-flags.mk
# It should be check_LIBRARIES, but this is safer, in case we want to
# run check in a specific subdir.
noinst_LIBRARIES = libcheck.a
noinst_LTLIBRARIES = libcheck.la
libcheck_a_SOURCES = \
libcheck_la_SOURCES = \
tester.cc \
unique.cc
libcheck_a_LIBADD = $(top_builddir)/lib/libvcsn-common-ex.la
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Vaucanson Group.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 The Vaucanson Group.
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
......@@ -22,7 +22,9 @@
LAZY_TEST_SUITE = 1
include $(top_srcdir)/src/tests/check/check-flags.mk
LDADD = $(top_builddir)/src/tests/check/libcheck.a
LDADD = \
$(top_builddir)/src/tests/check/libcheck.la \
$(top_builddir)/lib/libvcsn-common-ex.la
TESTS = $(EXTRA_PROGRAMS)
# Automake does not automatically clean EXTRA_PROGRAMS.
......
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The Vaucanson Group.
## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 The Vaucanson Group.
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
......@@ -16,6 +16,7 @@ EXTRA_DIST = generate_files.sh hhck.pl
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \
$(BOOST_CPPFLAGS) -DVCSN_SANITY_CHECK
AM_CXXFLAGS = $(CXXFLAGS_STRICT)
LDADD = $(top_builddir)/lib/libvcsn-common.la
# FIXME: Currently files are generated in srcdir, they should be in builddir,
# and generated from the Makefile.am.
......
......@@ -17,9 +17,7 @@ include $(top_srcdir)/src/tests/check/check.mk
TESTS += failcomp.sh
EXTRA_DIST = failcomp.sh
AM_CPPFLAGS += $(BOOST_CPPFLAGS) -DEXCEPTION_TRAPS -DVCSN_SRC_DIR=\"'$(top_srcdir)'\"
LDADD += $(top_builddir)/lib/libvcsn-common.la
AM_CPPFLAGS += $(BOOST_CPPFLAGS) -DVCSN_SRC_DIR=\"'$(top_srcdir)'\"
TESTS_ENVIRONMENT = CXX="$(CXX)" \
CXXFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS)"
......
......@@ -14,6 +14,8 @@
include $(top_srcdir)/vaucanson.mk
include $(top_srcdir)/build-aux/check.mk
LDADD = $(top_builddir)/lib/libvcsn-common.la
AM_CPPFLAGS += $(XSD_CPPFLAGS)
TESTS_ENVIRONMENT = srcdir=$(srcdir)
......@@ -90,7 +92,6 @@ int_z_trans_tester_SOURCES = xml_int_z_trans_tester.cc
geometry_tester_SOURCES = xml_geometry_tester.cc
label_node_tester_SOURCES = xml_label_node_tester.cc
label_node_tester_LDADD = $(top_builddir)/lib/libvcsn-common.la
## ------------------------ ##
## Running the test suite. ##
......
......@@ -183,7 +183,7 @@ vcsn_char_zmax_SOURCES = $(COMMON_SOURCES) \
vcsn_char_zmax_CPPFLAGS = $(AM_CPPFLAGS) -DCONTEXT=z_max_plus_automaton -DVCSN_USE_LIB
vcsn_char_zmax_LDADD = $(LDADD) $(top_builddir)/lib/libvcsn-z-max.la
LDADD = $(top_builddir)/gnulib/libgnu.la $(top_builddir)/lib/libvcsn-common.la
LDADD = \
$(top_builddir)/gnulib/libgnu.la \
$(top_builddir)/lib/libvcsn-common-ex.la
AM_CPPFLAGS += -I$(top_srcdir)/gnulib
......@@ -50,9 +50,6 @@
# define VCSN_USE_INTERFACE_ONLY 1
# endif /* 0 */
/* Turn VCSN traps into exception. */
# define EXCEPTION_TRAPS 1
# include <string>
// Use a global timer and bencher.
......
......@@ -230,7 +230,7 @@ cat <<EOF
INCLUDES = -I\$(PYTHON_INCLUDEDIR) -I\$(srcdir)/../src -I\$(srcdir)/../meta \\
-I\$(top_srcdir)/include -I\$(top_builddir)/include
AM_CPPFLAGS = \$(BOOST_CPPFLAGS) -DINTERNAL_CHECKS -DSTRICT -DEXCEPTION_TRAPS -DVCSN_DEFAULT_GRAPH_IMPL=listg
AM_CPPFLAGS = \$(BOOST_CPPFLAGS) -DINTERNAL_CHECKS -DSTRICT -DVCSN_DEFAULT_GRAPH_IMPL=listg
AM_CXXFLAGS = \$(CXXFLAGS_DEBUG)
AM_LDFLAGS = -avoid-version
......
## Vaucanson, a generic library for finite state machines.
## Copyright (C) 2003, 2004, 2006, 2008 The Vaucanson Group.
## Copyright (C) 2003, 2004, 2006, 2008, 2009 The Vaucanson Group.
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
......@@ -29,3 +29,4 @@ lib_LTLIBRARIES = libvv.la
libvv_la_SOURCES = vcontext.cc vauto.cc
libvv_la_CPPFLAGS = -DVCSN_DEFAULT_GRAPH_IMPL=listg
libvv_la_LIBADD = $(top_builddir)/lib/libvcsn-common-ex.la
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment