[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1] make: ensure a consistent C++ standard use
On older compilers (such as g++ 4.8), the default C++ standard is set to
gnu++98. When compiling libabigail with --enable-cxx11=yes, src/ and
tests/ where compiled with the correct flag, while tools/ was compiled
without specifying a standard. With a compiler falling back to gnu++98
that leads to unresolved references when linking the tools against the
libabigail library. Fix that by consistently using the std= flag across
the code base.
* configure.ac: add -std=c++11 flag to CXXFLAGS when compiling
for C++11
* src/Makefile.am: drop now obsolete setting of the -std flag
* tests/Makefile.am: likewise
Reported-by: Chun-Hung Wu <Chun-hung.Wu@mediatek.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
---
configure.ac | 4 ++++
src/Makefile.am | 1 -
tests/Makefile.am | 1 -
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index afcc1db065e9..54ab695ae1e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -607,6 +607,10 @@ if test x$ENABLE_UBSAN = xyes; then
CXXFLAGS="$CXXFLAGS -fsanitize=undefined"
fi
+if test x$ENABLE_CXX11 = xyes; then
+ CXXFLAGS="$CXXFLAGS -std=c++11"
+fi
+
dnl Check if several decls and constant are defined in dependant
dnl libraries
HAS_EM_AARCH64=no
diff --git a/src/Makefile.am b/src/Makefile.am
index 7c02d538c50d..1d0e2dcecdee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,6 @@ if ENABLE_CXX11
CXX11_SOURCES = abg-viz-common.cc \
abg-viz-dot.cc \
abg-viz-svg.cc
-AM_CXXFLAGS += "-std=c++11"
else
CXX11_SOURCES =
endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2104300aed22..14e83608b0e5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,7 +13,6 @@ AM_CXXFLAGS = $(VISIBILITY_FLAGS)
CXX11_TESTS =
if ENABLE_CXX11
CXX11_TESTS += runtestsvg
-AM_CXXFLAGS += "-std=c++11"
endif
FEDABIPKGDIFF_TEST =
--
2.22.0.657.g960e92d24f-goog