]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use the CXX compiler only if it can create dynamic and static programs
authorFlorian Weimer <fweimer@redhat.com>
Mon, 26 Oct 2015 08:41:10 +0000 (09:41 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 26 Oct 2015 08:41:10 +0000 (09:41 +0100)
* configure.ac (CXX): Clear the variable if the C++ toolchain does
not support static linking.
* configure: Regenerate.

ChangeLog
configure
configure.ac

index 041a6eb4f069fbc55c18d289ebcd6f8d29a38309..30d6dd9c8d9f2e636b6de68bbe6bec100bfe96d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-26  Florian Weimer  <fweimer@redhat.com>
+
+       * configure.ac (CXX): Clear the variable if the C++ toolchain does
+       not support static linking.
+       * configure: Regenerate.
+
 2015-10-23  Joseph Myers  <joseph@codesourcery.com>
 
        * math/libm-test.inc (check_float_internal): Do not special-case
index 8aea9925aa18a95cd2fa1501627bacfbce52724e..ff3ad55b1d283669b9d78f0af73447a932de0e13 100755 (executable)
--- a/configure
+++ b/configure
@@ -3173,6 +3173,7 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
+# Default, dynamic case.
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -3191,6 +3192,30 @@ else
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+# Static case.
+old_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -static"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <iostream>
+
+int
+main()
+{
+  std::cout << "Hello, world!";
+  return 0;
+}
+
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+else
+  libc_cv_cxx_link_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LDFLAGS="$old_LDFLAGS"
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
index e502aa5db2fe1d114f95b2e5ca718bd5c45e8095..3c7f6c00963c8cecf2e91730b786f17b95ae235c 100644 (file)
@@ -57,9 +57,26 @@ AC_PROG_CXX
 # It's useless to us if it can't link programs (e.g. missing -lstdc++).
 AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
 AC_LANG_PUSH([C++])
+# Default, dynamic case.
 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
               [libc_cv_cxx_link_ok=yes],
               [libc_cv_cxx_link_ok=no])
+# Static case.
+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_link_ok=no])
+LDFLAGS="$old_LDFLAGS"
 AC_LANG_POP([C++])])
 AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])