From 114d578eb437ddf977756a280d4178f6657cee38 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 18 Jan 2017 11:47:44 +0300 Subject: [PATCH] Add configure --enable-gcov option (enable code coverage analysis) * configure.ac (gcov): New --enable-* option. * configure.ac [enable_gcov] (CFLAGS): Add "--coverage" option. * configure.ac [enable_gcov && !enable_shared] (CXXFLAGS): Add "--coverage" option (the shared library build is skipped to workaround a bug in GCC or linker, atlist for gcc-4.8.4/x86_64). * configure.ac [enable_gcov] (CFLAGS, CXXFLAGS): Filter out compiler "-O" options (except for -O0). --- configure.ac | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/configure.ac b/configure.ac index 44851ce8..9e465a52 100644 --- a/configure.ac +++ b/configure.ac @@ -897,6 +897,20 @@ AC_ARG_ENABLE(single-obj-compilation, [single_obj_compilation=yes]) AM_CONDITIONAL([SINGLE_GC_OBJ], [test "$single_obj_compilation" = "yes"]) +AC_ARG_ENABLE(gcov, AC_HELP_STRING([--enable-gcov], + [Turn on code coverage analysis])) +if test "$enable_gcov" = "yes"; then + CFLAGS="$CFLAGS --coverage" + if test "${enable_shared}" = no; then + # FIXME: As of g++-4.8.4/x86_64, in case of shared library build, test_cpp + # linkage fails with "hidden symbol atexit is referenced by DSO" message. + CXXFLAGS="$CXXFLAGS --coverage" + fi + # Turn off optimization to get accurate line numbers. + CFLAGS=`echo "$CFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'` + CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'` +fi + # Atomic Ops # ---------- -- 2.40.0