From ff7f8557e34111883595827dc1f438bdf315df49 Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Mon, 2 Oct 2017 12:17:34 -0700 Subject: [PATCH] Workaround GLIBC 4.9 importing one useless (to us) symbol that causes a version update. --- .travis.yml | 8 ++++---- include/util/glibc_workaround.hpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 include/util/glibc_workaround.hpp diff --git a/.travis.yml b/.travis.yml index 272a4f87b..b53fc370d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -187,7 +187,7 @@ matrix: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-4.9-dev'] - env: CLANG_VERSION='4.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 + env: CLANG_VERSION='4.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 CXXFLAGS='-include util/glibc_workaround.hpp' install: - pushd ${OSRM_BUILD_DIR} - | @@ -210,7 +210,7 @@ matrix: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-4.9-dev'] - env: CLANG_VERSION='4.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 + env: CLANG_VERSION='4.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 CXXFLAGS='-include util/glibc_workaround.hpp' install: - pushd ${OSRM_BUILD_DIR} - | @@ -233,7 +233,7 @@ matrix: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-4.9-dev'] - env: CLANG_VERSION='4.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="6" + env: CLANG_VERSION='4.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="6" CXXFLAGS='-include util/glibc_workaround.hpp' install: - pushd ${OSRM_BUILD_DIR} - | @@ -256,7 +256,7 @@ matrix: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['libstdc++-4.9-dev'] - env: CLANG_VERSION='4.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="6" + env: CLANG_VERSION='4.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="6" CXXFLAGS='-include util/glibc_workaround.hpp' install: - pushd ${OSRM_BUILD_DIR} - | diff --git a/include/util/glibc_workaround.hpp b/include/util/glibc_workaround.hpp new file mode 100644 index 000000000..e9d4daf8c --- /dev/null +++ b/include/util/glibc_workaround.hpp @@ -0,0 +1,31 @@ +#ifndef GLIBC_WORKAROUND_H +#define GLIBC_WORKAROUND_H + +// 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 + +// Note: only necessary on Linux +#ifdef __linux__ +#define WORKAROUND +#warning building with workaround +#else +#warning not building with workaround +#endif + +#ifdef WORKAROUND +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 // WORKAROUND + +#endif // GLIBC_WORKAROUND_H \ No newline at end of file