Only build and tested by self tests if a g++ with C++x0 is available.
Almost empty C++ program, can be extended to test more features.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2012-07-24 Mark Wielaard <mjw@redhat.com>
+
+ * configure.ac: Add AX_CXX_COMPILE_STDCXX_0X check.
+
2012-07-24 Mark Wielaard <mjw@redhat.com>
* TODO: Add note on shdrs after elf_cntl (ELF_C_FDREAD).
AC_PROG_YACC
AM_PROG_LEX
+# Check whether we can use g++ with -std=c++0x for the test.
+AC_PROG_CXX
+AX_CXX_COMPILE_STDCXX_0X
+AM_CONDITIONAL(HAVE_STDCXX_0X, test "x$ax_cv_cxx_compile_cxx0x_cxx" == "xyes")
+
AC_CACHE_CHECK([for gcc with C99 support], ac_cv_c99, [dnl
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=gnu99"
+2012-07-24 Mark Wielaard <mjw@redhat.com>
+
+ * ax_cxx_compile_stdcxx_0x.m4: Add from autoconf-archive.
+
2010-04-14 Roland McGrath <roland@redhat.com>
* gettext.m4: Upgrade to gettext-0.17.
--- /dev/null
+# ============================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_0x.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+# AX_CXX_COMPILE_STDCXX_0X
+#
+# DESCRIPTION
+#
+# Check for baseline language coverage in the compiler for the C++0x
+# standard.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 7
+
+AU_ALIAS([AC_CXX_COMPILE_STDCXX_0X], [AX_CXX_COMPILE_STDCXX_0X])
+AC_DEFUN([AX_CXX_COMPILE_STDCXX_0X], [
+ AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
+ ax_cv_cxx_compile_cxx0x_native,
+ [AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = static_cast<check_type&&>(c);],,
+ ax_cv_cxx_compile_cxx0x_native=yes, ax_cv_cxx_compile_cxx0x_native=no)
+ AC_LANG_RESTORE
+ ])
+
+ AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
+ ax_cv_cxx_compile_cxx0x_cxx,
+ [AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=c++0x"
+ AC_TRY_COMPILE([
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = static_cast<check_type&&>(c);],,
+ ax_cv_cxx_compile_cxx0x_cxx=yes, ax_cv_cxx_compile_cxx0x_cxx=no)
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
+ ])
+
+ AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
+ ax_cv_cxx_compile_cxx0x_gxx,
+ [AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=gnu++0x"
+ AC_TRY_COMPILE([
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = static_cast<check_type&&>(c);],,
+ ax_cv_cxx_compile_cxx0x_gxx=yes, ax_cv_cxx_compile_cxx0x_gxx=no)
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
+ ])
+
+ if test "$ax_cv_cxx_compile_cxx0x_native" = yes ||
+ test "$ax_cv_cxx_compile_cxx0x_cxx" = yes ||
+ test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
+ AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
+ fi
+])
+2012-07-24 Mark Wielaard <mjw@redhat.com>
+
+ * testfile-cxx-various.bz2: New testfile.
+ * cxx-various.cxx: New test source.
+ * Makefile.am (cxx_various_SOURCES): New.
+ (HAVE_STDCXX_0X): Add cxx-various and -std=c++0x if exists.
+ (EXTRA_DIST): Add cxx-various.cxx and testfile-cxx-various.bz2.
+ * test-subr.sh: Add testfile-cxx-various and cxx-various to
+ self_test_files if they exist.
+
2012-07-19 Mark Wielaard <mjw@redhat.com>
* run-readelf-unknown-self.sh: New test.
TESTS += $(asm_TESTS)
endif
+if HAVE_STDCXX_0X
+check_PROGRAMS += cxx-various
+AM_CXXFLAGS = -std=c++0x
+cxx_various_SOURCES = cxx-various.cc
+endif
EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-show-die-info.sh run-get-files.sh run-get-lines.sh \
run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \
run-readelf-test4.sh run-readelf-twofiles.sh \
run-readelf-unknown-self.sh \
+ cxx-various.cc testfile-cxx-various.bz2 \
run-bug1-test.sh testfile28.bz2 testfile28.rdwr.bz2 \
testfile29.bz2 testfile29.rdwr.bz2 \
testfile30.bz2 testfile31.bz2 testfile32.bz2 testfile33.bz2 \
--- /dev/null
+/* Test program for testing C++11 features are recognized.
+ Copyright (C) 2012 Red Hat, Inc.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+// NOTE this file is the source of the binary testfile-cxx-various created
+// with g++ -std=c++0x -g -o testfile-cxx-various cxx-various.cc
+//
+// When you edit this file to add more C++ contructs either create
+// a new source file, or regenerate the binary test file. We always
+// want to include the source code of all our test binaries.
+
+#include <iostream>
+using namespace std;
+
+// Make sure we recognize the encoding of some of the standard types.
+// char16_t and char_32_t use DW_ATE_UTF.
+char c;
+signed char sc;
+unsigned char uc;
+int i;
+float f;
+double d;
+wchar_t wc;
+char16_t c16;
+char32_t c32;
+long l;
+
+long
+standard_types_func (char ac, signed char asc, unsigned char auc,
+ int ai, float af, double ad, wchar_t awc,
+ char16_t ac16, char32_t ac32, long al)
+{
+ c = ac;
+ sc = asc;
+ uc = auc;
+ i = ai;
+ f = af;
+ d = ad;
+ wc = awc;
+ c16 = ac16;
+ c32 = ac32;
+ l = al;
+ return ac + asc + auc + ai + af + ad + awc + ac16 + ac32 + al;
+}
+
+int main ()
+{
+ long answer;
+ answer = standard_types_func (1, 2, 3, 4, 5.0, 6.0, 7, 8, 9, -10L);
+ cout << "answer: " << answer << endl;
+ return 0;
+}
../src/size ../src/strip ../libelf/libelf.so ../libdw/libdw.so \
../libasm/libasm.so ../backends/libebl_*.so`
+# Prebuild binary in case we don't have a C++11 capable compiler around.
+extra_self_test_files=testfile-cxx-various
+self_test_files="$self_test_files $extra_self_test_files"
+
+# This file might not exist if we don't have a C++ compiler around.
+if test -f cxx-various; then
+ self_test_files="$self_test_files cxx-various"
+fi
+
# Provide a command to run on all self-test files with testrun.
testrun_on_self()
{
exit_status=0
+ testfiles $extra_self_test_files
for file in $self_test_files; do
testrun $* $file \
|| { echo "*** failure in $* $file"; exit_status=1; }
{
exit_status=0
+ testfiles $extra_self_test_files
for file in $self_test_files; do
testrun $* $file > /dev/null \
|| { echo "*** failure in $* $file"; exit_status=1; }
exit_status=0
tempfiles self_matches.in self_matches.out
+ testfiles $extra_self_test_files
for file in $self_test_files; do
testrun "$@" $file > self_matches.in
# egrep should fail to match anything, but we also want to show