This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Detect if the C++ toolchain does not support -static


Previously, this caused a failure of âmake checkâ before reporting the
result totals.

Checked with and without libstdc++-static installed.  The test case is
marked UNSUPPORTED as expected, and still runs if it can be compiled and
linked.

Florian
2015-10-23  Florian Weimer  <fweimer@redhat.com>

	* configure.ac (libc_cv_cxx_static): New test for checking the C++
	compiler supports static linking.
	* configure: Regenerated.
	* config.make.in (have-cxx-static): New variable.
	* nptl/Makefile [!CXX] (tests-unsupported): Remove
	tst-cancel24-static.
	[!have-cxx-static] (tests-unsupported): Add tst-cancel24-static.

diff --git a/config.make.in b/config.make.in
index a791922..e8f2d65 100644
--- a/config.make.in
+++ b/config.make.in
@@ -66,6 +66,7 @@ bind-now = @bindnow@
 have-hash-style = @libc_cv_hashstyle@
 use-default-link = @use_default_link@
 output-format = @libc_cv_output_format@
+have-cxx-static = @libc_cv_cxx_static@
 have-cxx-thread_local = @libc_cv_cxx_thread_local@
 
 multi-arch = @multi_arch@
diff --git a/configure.ac b/configure.ac
index e502aa5..8e1a754 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1815,6 +1815,27 @@ fi
 dnl C++ feature tests.
 AC_LANG_PUSH([C++])
 
+AC_CACHE_CHECK([whether the C++ can create static programs],
+	       libc_cv_cxx_static, [
+
+old_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -static"
+AC_LINK_IFELSE([AC_LANG_SOURCE([
+#include <iostream>
+
+int
+main()
+{
+  std::cout << "Hello, world!";
+  return 0;
+}
+])],
+	       [libc_cv_cxx_static=yes],
+	       [libc_cv_cxx_static=no])
+])
+AC_SUBST(libc_cv_cxx_static)
+LDFLAGS="$old_LDFLAGS"
+
 AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
 	       libc_cv_cxx_thread_local, [
 old_CXXFLAGS="$CXXFLAGS"
diff --git a/nptl/Makefile b/nptl/Makefile
index 311b1a7..962bd74 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -405,8 +405,14 @@ endif
 
 ifeq (,$(CXX))
 # These tests require a C++ compiler and runtime.
-tests-unsupported += tst-cancel24 tst-cancel24-static tst-once5
+tests-unsupported += tst-cancel24 tst-once5
 endif
+
+ifneq ($(have-cxx-static),yes)
+# These tests require C++ support with static liking.
+tests-unsupported += tst-cancel24-static
+endif
+
 # These tests require a C++ compiler and runtime with thread_local support.
 ifneq ($(have-cxx-thread_local),yes)
 tests-unsupported += tst-thread_local1
-- 
2.4.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]