[lttng-dev] [PATCH lttng-ust] Fix: Check g++ version before compiling 'hello.cxx' test

Zifei Tong soariez at gmail.com
Sat Jun 15 14:08:29 EDT 2013


Designated initializer support that is required to compile c++
tracepoint probes is only available since g++ 4.7.

Fixes #557

Signed-off-by: Zifei Tong <soariez at gmail.com>
---
 README       |  3 ++-
 configure.ac | 16 ++++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/README b/README
index 1f6b9d2..1c7a2f8 100644
--- a/README
+++ b/README
@@ -111,7 +111,8 @@ USAGE:
   - Enable instrumentation and control tracing with the "lttng" command
     from lttng-tools. See lttng-tools doc/quickstart.txt.
   - Note for C++ support: since LTTng-UST 2.3, both tracepoints and
-    tracepoint probes can be compiled with g++.
+    tracepoint probes can be compiled with g++. To compile tracepoint probes
+    in g++, you need version 4.7 or above.


 ENVIRONMENT VARIABLES:
diff --git a/configure.ac b/configure.ac
index 802ccaa..85a64a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,9 +83,21 @@ AC_CACHE_CHECK([whether the C++ compiler works],
 		[rw_cv_prog_cxx_works],
 		[AC_LANG_PUSH([C++])
 		AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
-				[rw_cv_prog_cxx_works=yes],
+				[check_gcc_cxx_version=yes],
 				[rw_cv_prog_cxx_works=no])
-		AC_LANG_POP([C++])])
+		AC_LANG_POP([C++])
+		if test "$check_gcc_cxx_version" = "yes"; then
+			gcc_cxx_version=`$CXX -dumpversion`
+			gcc_cxx_major_version=$(echo $gcc_cxx_version | sed
's/^\([[0-9]]*\)\.[[0-9]]*.*$/\1/')
+			gcc_cxx_minor_version=$(echo $gcc_cxx_version | sed
's/^[[0-9]]*\.\([[0-9]]*\).*$/\1/')
+			if test "$gcc_cxx_major_version" -gt 4; then
+				rw_cv_prog_cxx_works="yes"
+			elif test "$gcc_cxx_major_version" -eq 4 -a
"$gcc_cxx_minor_version" -ge 7; then
+				rw_cv_prog_cxx_works="yes"
+			else
+				rw_cv_prog_cxx_works="no"
+			fi
+		fi])

 AM_CONDITIONAL([CXX_WORKS], [test "x$rw_cv_prog_cxx_works" = "xyes"])

-- 
1.8.3.1

-- 
Best Regards,
仝子飞 (Zifei Tong)



More information about the lttng-dev mailing list