Boost logo

Boost :

Subject: Re: [boost] [thread][chrono][system] fails to compile with -fno-exceptions
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-07-10 13:43:25


PING!!!

Le 08/07/12 20:54, Vicente J. Botet Escriba a écrit :
> Hi,
>
> I'm trying to make Boost.Thread work when -fno-exceptions is defined
> and I getting a lot of errors on Boost.System
>
>
> cd libs/system/build
>
> bjam toolset=darwin-4.7.0 -j4 cxxflags="-fno-exceptions"
> define=BOOST_NO_EXCEPTION
>
> darwin.compile.c++
> ../../../bin.v2/libs/system/build/darwin-4.7.0/debug/error_code.o
> ../../../libs/system/src/error_code.cpp: In member function ‘virtual
> std::string {anonymous}::generic_error_category::message(int) const’:
> ../../../libs/system/src/error_code.cpp:149:10: error: expected
> ‘catch’ before ‘(’ token
> ../../../libs/system/src/error_code.cpp:149:12: error: expected
> type-specifier before ‘sz’
> ../../../libs/system/src/error_code.cpp:149:12: error: exception
> handling disabled, use -fexceptions to enable
> ../../../libs/system/src/error_code.cpp:149:15: error: expected ‘)’
> before ‘>’ token
> ../../../libs/system/src/error_code.cpp:149:15: error: expected ‘{’
> before ‘>’ token
> ../../../libs/system/src/error_code.cpp:149:15: error: expected
> primary-expression before ‘>’ token
> ../../../libs/system/src/error_code.cpp:149:29: error: expected ‘;’
> before ‘)’ token
> In file included from ../../../libs/system/src/error_code.cpp:19:0:
> ../../../boost/system/error_code.hpp: At global scope:
> ../../../boost/system/error_code.hpp:214:36: warning:
> ‘boost::system::posix_category’ defined but not used [-Wunused-variable]
> ../../../boost/system/error_code.hpp:215:36: warning:
> ‘boost::system::errno_ecat’ defined but not used [-Wunused-variable]
> ../../../boost/system/error_code.hpp:216:36: warning:
> ‘boost::system::native_ecat’ defined but not used [-Wunused-variable]
>
> "/usr/local/gcc-4-7-svn/bin/g++" -ftemplate-depth-128 -O0 -fno-inline
> -Wall -g -dynamic -gdwarf-2 -fexceptions -fPIC -fno-exceptions
> -DBOOST_ALL_NO_LIB=1 -DBOOST_NO_EXCEPTION -DBOOST_SYSTEM_DYN_LINK=1
> -I"../../.." -c -o
> "../../../bin.v2/libs/system/build/darwin-4.7.0/debug/error_code.o"
> "../../../libs/system/src/error_code.cpp"
>
> ...failed darwin.compile.c++
> ../../../bin.v2/libs/system/build/darwin-4.7.0/debug/error_code.o...
> ...skipped
> <p../../../bin.v2/libs/system/build/darwin-4.7.0/debug>libboost_system.dylib
> for lack of
> <p../../../bin.v2/libs/system/build/darwin-4.7.0/debug>error_code.o...
> ...failed updating 1 target...
>
>
> After applying this patch the library builds
>
> Index: ../../../libs/system/src/error_code.cpp
> ===================================================================
> --- ../../../libs/system/src/error_code.cpp (revision 79245)
> +++ ../../../libs/system/src/error_code.cpp (working copy)
> @@ -133,7 +133,9 @@
> }
> }
> std::string msg;
> +# ifndef BOOST_NO_EXCEPTIONS
> try
> +# endif
> {
> msg = ( ( result == invalid_argument ) ? "Unknown error" : bp );
> }
>
>
> cd libs/chrono/build
>
> bjam toolset=darwin-4.7.0 -j4 cxxflags="-fno-exceptions"
> define=BOOST_NO_EXCEPTION
>
> darwin.compile.c++
> ../../../bin.v2/libs/chrono/build/darwin-4.7.0/debug/threading-multi/process_cpu_clocks.o
> In file included from
> ../../../boost/chrono/detail/inlined/process_cpu_clocks.hpp:21:0,
> from ../../../libs/chrono/src/process_cpu_clocks.cpp:17:
> ../../../boost/system/system_error.hpp: In member function ‘virtual
> const char* boost::system::system_error::what() const’:
> ../../../boost/system/system_error.hpp:73:16: error: exception
> handling disabled, use -fexceptions to enable
>
> After applying this patch
>
> Index: ../../../boost/system/system_error.hpp
> ===================================================================
> --- ../../../boost/system/system_error.hpp (revision 79245)
> +++ ../../../boost/system/system_error.hpp (working copy)
> @@ -21,7 +21,7 @@
>
> class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error
> // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown
> from a shared
> - // library can be caught. See svn.boost.org/trac/boost/ticket/3697
> + // library can be caught. See svn.boost.org/trac/boost/ticket/3697
> {
> public:
> system_error( error_code ec )
> @@ -61,13 +61,17 @@
> {
> if ( m_what.empty() )
> {
> +#ifndef BOOST_NO_EXCEPTIONS
> try
> +#endif
> {
> m_what = this->std::runtime_error::what();
> if ( !m_what.empty() ) m_what += ": ";
> m_what += m_error_code.message();
> }
> +#ifndef BOOST_NO_EXCEPTIONS
> catch (...) { return std::runtime_error::what(); }
> +#endif
> }
> return m_what.c_str();
> }
>
> I get
>
> darwin.link.dll
> ../../../bin.v2/libs/chrono/build/darwin-4.7.0/debug/threading-multi/libboost_chrono.dylib
> Undefined symbols for architecture x86_64:
> "boost::throw_exception(std::exception const&)", referenced from:
> boost::chrono::chrono_detail::steady_full_ec(boost::system::error_code&)
> in chrono.o
> boost::chrono::steady_clock::now(boost::system::error_code&) in chrono.o
> boost::chrono::process_real_cpu_clock::now(boost::system::error_code&)
> in process_cpu_clocks.o
> boost::chrono::process_user_cpu_clock::now(boost::system::error_code&)
> in process_cpu_clocks.o
> boost::chrono::process_system_cpu_clock::now(boost::system::error_code&)
> in process_cpu_clocks.o
> boost::chrono::process_cpu_clock::now(boost::system::error_code&) in
> process_cpu_clocks.o
>
> Does this mean that the user needs to link with a static library?
> Is there a way to provide a dynamic library for Boost.Chrono if it is
> up to the user to define boost::throw_exception?
>
> Is there a possibility that Boost.System support this mode? BTW, an
> alternative to redefine the the what function is to pass the string at
> the construction of the exception.
>
>
> Best,
> Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk