diff --git a/.travis.yml b/.travis.yml index b8a55534c..dd89b3aec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ matrix: - os: linux sudo: false compiler: ": clang" - env: JOBS=8 CXX="ccache clang++-3.9 -Qunused-arguments" CC="clang-3.9" TRIGGER=true + env: JOBS=8 CXX="ccache clang++-3.9 -Qunused-arguments" CC="clang-3.9" ENABLE_GLIBC_WORKAROUND=True TRIGGER=true addons: apt: sources: [ 'ubuntu-toolchain-r-test'] @@ -98,7 +98,7 @@ before_script: script: - export SCONSFLAGS='--debug=time' - - configure BENCHMARK=${BENCH} + - configure BENCHMARK=${BENCH} ENABLE_GLIBC_WORKAROUND=${ENABLE_GLIBC_WORKAROUND:-False} - cat config.log # we limit the `make` to 40 min # to ensure that slow builds still upload their diff --git a/SConstruct b/SConstruct index 3cdc268ad..d81154096 100644 --- a/SConstruct +++ b/SConstruct @@ -309,6 +309,7 @@ opts.AddVariables( BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'), BoolVariable('NO_ATEXIT', 'Will prevent Singletons from being deleted atexit of main thread', 'False'), BoolVariable('NO_DLCLOSE', 'Will prevent plugins from being unloaded', 'False'), + BoolVariable('ENABLE_GLIBC_WORKAROUND', "Workaround known GLIBC symbol exports to allow building against libstdc++-4.8 without binaries needing throw_out_of_range_fmt", 'False'), # http://www.scons.org/wiki/GoFastButton # http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'), @@ -1879,6 +1880,9 @@ if not preconfigured: if env['NO_DLCLOSE'] or env['COVERAGE']: env.Append(CPPDEFINES = '-DMAPNIK_NO_DLCLOSE') + if env['ENABLE_GLIBC_WORKAROUND']: + env.Append(CPPDEFINES = '-DMAPNIK_ENABLE_GLIBC_WORKAROUND') + # Mac OSX (Darwin) special settings if env['PLATFORM'] == 'Darwin': pthread = '' diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 4d504a8ff..77a28d654 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -53,6 +53,16 @@ namespace mapnik { template class MAPNIK_DECL singleton; +void freetype_engine::clear() +{ +#ifdef MAPNIK_THREADSAFE + std::lock_guard lock(mutex_); +#endif + global_font_file_mapping_.clear(); + global_memory_fonts_.clear(); +} + + bool freetype_engine::is_font_file(std::string const& file_name) { // only accept files that will be matched by freetype2's `figurefiletype()` diff --git a/src/glibc_workaround.cpp b/src/glibc_workaround.cpp new file mode 100644 index 000000000..c07a22d9a --- /dev/null +++ b/src/glibc_workaround.cpp @@ -0,0 +1,26 @@ +#ifdef __linux__ + +#ifdef MAPNIK_ENABLE_GLIBC_WORKAROUND + +#include + +// https://github.com/bitcoin/bitcoin/pull/4042 +// allows building against libstdc++-dev-4.9 while avoiding +// GLIBCXX_3.4.20 dep +// This is needed because libstdc++ itself uses this API - its not +// just an issue of your code using it, ughhh + +namespace std +{ + +void __throw_out_of_range_fmt(const char *, ...) __attribute__((__noreturn__)); +void __throw_out_of_range_fmt(const char *err, ...) +{ + // Safe and over-simplified version. Ignore the format and print it as-is. + __throw_out_of_range(err); +} +} + +#endif // MAPNIK_ENABLE_GLIBC_WORKAROUND + +#endif // __linux__