From patchwork Wed Mar 4 21:55:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 446447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F607140161 for ; Thu, 5 Mar 2015 08:56:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=SF5ns4ju; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=wtbZ7ioAXcewmAsEg0F7NHunbqy+c2FbwYYEi1158GIKPj WObm8EzsbE2eoaGXbrQ4MiqB3hzQQl+frRfBI7TJr3yv/FKbJtDgKNFM/kHwRZfP ZTygCJokXZeg8t9r9ajSkNKpPtgziOwvORCBhUPwndlf8l4W7RMFZMEW3kGLM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=VdN0AAoR8B3+7XW2a5SyraTyz00=; b=SF5ns4jukxx8kcCfPhyK jnN4YXZhpKThVwAV5KncmeHIIicUZQJMhYQuc7QSAJAhSKgOJ4Z/D1exJtkOFuJm lNTC6KqyfDpSIASz9WiYN/SC7mU3fO2mHTn9VDwukGjFa1EbKXMzspIjlES8LQ5W Uby8VN0stK/Y5xIFkhKqXtU= Received: (qmail 54881 invoked by alias); 4 Mar 2015 21:55:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 54819 invoked by uid 89); 4 Mar 2015 21:55:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] Avoid C++ tests when the C++ cannot be linked. Message-Id: <20150304215551.7E6E22C3B7B@topped-with-meat.com> Date: Wed, 4 Mar 2015 13:55:51 -0800 (PST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=pO4aJ7EVsMddx8kx1nMA:9 a=CjuIK1q_8ugA:10 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 * 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