diff mbox

Detect if the C++ toolchain does not support -static

Message ID 562A4EDC.9030203@redhat.com
State New
Headers show

Commit Message

Florian Weimer Oct. 23, 2015, 3:14 p.m. UTC
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

Comments

Roland McGrath Oct. 23, 2015, 6:19 p.m. UTC | #1
Why not just clear CXX and call this a "C++ not available" case?
Florian Weimer Oct. 23, 2015, 6:21 p.m. UTC | #2
On 10/23/2015 08:19 PM, Roland McGrath wrote:
> Why not just clear CXX and call this a "C++ not available" case?

I have no preference either way.

Florian
Roland McGrath Oct. 23, 2015, 6:30 p.m. UTC | #3
> On 10/23/2015 08:19 PM, Roland McGrath wrote:
> > Why not just clear CXX and call this a "C++ not available" case?
> 
> I have no preference either way.

Then let's keep it simpler for now.  Just change the criteria in the
configure check, and don't add any new degrees of freedom.
diff mbox

Patch

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