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]

[COMMITTED PATCH] Avoid C++ tests when the C++ cannot be linked.


In a bootstrapping environment, libstdc++ is likely not to be available
when building libc.  This changes configure to check whether linking an
empty C++ program with ${CXX} works (it won't when libstdc++ is missing),
and elides all the C++ tests when that check fails.

I've verified the check passes on a normal installation and fails in a
partially-installed cross-compilation environment lacking libstdc++.


Thanks,
Roland


2015-03-04  Roland McGrath  <roland@hack.frob.com>

	* configure.ac (libc_cv_cxx_link_ok): New check.
	Reset CXX to empty if it fails to link.
	* configure: Regenerated.
	* dlfcn/Makefile (tests, modules-names): Add bug-atexit3 and
	bug-atexit3-lib only if $(CXX) is nonempty.
	* nptl/Makefile (tests): Likewise for tst-cancel24.
	(tests, tests-static): Likewise for tst-cancel24-static.
	* debug/Makefile (tests): Likewise for tst-chk4, tst-chk5, tst-chk6,
	tst-lfschk4, tst-lfschk5, and tst-lfschk6.

--- a/configure.ac
+++ b/configure.ac
@@ -50,9 +50,18 @@ if test $host != $build; then
 fi
 AC_SUBST(cross_compiling)
 AC_PROG_CPP
+AC_CHECK_TOOL(READELF, readelf, false)
+
 # We need the C++ compiler only for testing.
 AC_PROG_CXX
-AC_CHECK_TOOL(READELF, readelf, false)
+# 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++])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+	       [libc_cv_cxx_link_ok=yes],
+	       [libc_cv_cxx_link_ok=no])
+AC_LANG_POP([C++])])
+AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
 
 if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
   AC_MSG_ERROR([you must configure in a separate build directory])
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -133,10 +133,13 @@ LDFLAGS-tst-backtrace6 = -rdynamic
 
 tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
 	tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
-	tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6 \
 	tst-longjmp_chk2 tst-backtrace2 tst-backtrace3 tst-backtrace4 \
 	tst-backtrace5 tst-backtrace6
 
+ifneq (,$(CXX))
+tests += tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6
+endif
+
 extra-libs = libSegFault libpcprofile
 extra-libs-others = $(extra-libs)
 
--- a/dlfcn/Makefile
+++ b/dlfcn/Makefile
@@ -36,12 +36,12 @@ endif
 ifeq (yes,$(build-shared))
 tests = glrefmain failtest tst-dladdr default errmsg1 tstcxaatexit \
 	bug-dlopen1 bug-dlsym1 tst-dlinfo bug-atexit1 bug-atexit2 \
-	bug-atexit3 tstatexit bug-dl-leaf tst-rec-dlopen
+	tstatexit bug-dl-leaf tst-rec-dlopen
 endif
 modules-names = glreflib1 glreflib2 glreflib3 failtestmod defaultmod1 \
 		defaultmod2 errmsg1mod modatexit modcxaatexit \
 		bug-dlsym1-lib1 bug-dlsym1-lib2 bug-atexit1-lib \
-		bug-atexit2-lib bug-atexit3-lib bug-dl-leaf-lib \
+		bug-atexit2-lib bug-dl-leaf-lib \
 		bug-dl-leaf-lib-cb moddummy1 moddummy2
 
 failtestmod.so-no-z-defs = yes
@@ -57,6 +57,11 @@ tststatic2-ENV = $(tststatic-ENV)
 tststatic3-ENV = $(tststatic-ENV)
 tststatic4-ENV = $(tststatic-ENV)
 tststatic5-ENV = $(tststatic-ENV)
+
+ifneq (,$(CXX))
+tests += bug-atexit3
+modules-names += bug-atexit3-lib
+endif
 endif
 
 extra-test-objs += $(modules-names:=.os)
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -245,8 +245,8 @@ tests = tst-typesizes \
 	tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 tst-cancel10 \
 	tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \
 	tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \
-	tst-cancel21 tst-cancel22 tst-cancel23 tst-cancel24 tst-cancel25 \
-	tst-cancel-self tst-cancel-self-cancelstate \
+	tst-cancel21 tst-cancel22 tst-cancel23 $(if $(CXX),tst-cancel24) \
+	tst-cancel25 tst-cancel-self tst-cancel-self-cancelstate \
 	tst-cancel-self-canceltype tst-cancel-self-testcancel \
 	tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \
 	tst-flock1 tst-flock2 \
@@ -364,14 +364,19 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
 		    $(common-objpfx)libc.a
 
 tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
-		tst-cancel21-static tst-cancel24-static tst-cond8-static \
+		tst-cancel21-static tst-cond8-static \
 		tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
 		tst-sem12-static
-tests += tst-stackguard1-static tst-cancel21-static tst-cancel24-static \
+tests += tst-stackguard1-static tst-cancel21-static \
 	 tst-cond8-static tst-mutex8-static tst-mutexpi8-static \
 	 tst-sem11-static tst-sem12-static
 xtests-static += tst-setuid1-static
 
+ifneq (,$(CXX))
+tests += tst-cancel24-static
+tests-static += tst-cancel24-static
+endif
+
 # These tests are linked with libc before libpthread
 tests-reverse += tst-cancel5 tst-cancel23 tst-vfork1x tst-vfork2x
 


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