From patchwork Tue Nov 20 00:18:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Price X-Patchwork-Id: 200218 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]) by ozlabs.org (Postfix) with SMTP id 850BE2C007E for ; Tue, 20 Nov 2012 11:18:26 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sourceware.org; s=default; x=1353975506; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Subscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=TfsgmFsOZ9x+aKVU3fFO o3aeMkA=; b=KQRwk2D3iImOOpqIjixhAMjHFLYhGAmvFaWnqug9RTY73VoPNrCC +qrw2ajumJNGP/gRSxf6klcaJSEmQX+tRF+DEM0+q0qiUxFVOqjmmSBjTe03AVcU md83/5SMNl2CE8l0+RJxCdeI1nNwJLoXMq7NSj7Mlb9r8uhCureKEYU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=sourceware.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=OsPhKwWCBGk3qdz+fyQSbiKCyhzoYuX3DnvoTiCm8ajJgdMcGe26RUx/5P41Ix x5Uls6Yz+8uYSCDGtu12wTJviwhZ0Hu9XFD1j/ql6nfYIziMW6w+DiqM7MbEHyrG PgkWeWdpxRikbc8M88suhevfWLqeklFpH9/l0ucXop2io=; Received: (qmail 9448 invoked by alias); 20 Nov 2012 00:18:11 -0000 Received: (qmail 9362 invoked by uid 22791); 20 Nov 2012 00:18:09 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL, BAYES_05, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, URIBL_DBL_SPAM X-Spam-Check-By: sourceware.org Received: from mail-bk0-f41.google.com (HELO mail-bk0-f41.google.com) (209.85.214.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Nov 2012 00:18:04 +0000 Received: by mail-bk0-f41.google.com with SMTP id jg9so2333772bkc.0 for ; Mon, 19 Nov 2012 16:18:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.8.17 with SMTP id f17mr5299693bkf.110.1353370682592; Mon, 19 Nov 2012 16:18:02 -0800 (PST) Received: by 10.204.178.195 with HTTP; Mon, 19 Nov 2012 16:18:02 -0800 (PST) In-Reply-To: <201211192355.42237.yann.morin.1998@free.fr> References: <201211192355.42237.yann.morin.1998@free.fr> Date: Mon, 19 Nov 2012 16:18:02 -0800 Message-ID: Subject: Re: [PATCH 1 of 1] refine static linking check to better guide user From: Daniel Price To: "Yann E. MORIN" Cc: crossgcc@sourceware.org X-IsSubscribed: yes Mailing-List: contact crossgcc-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: crossgcc-owner@sourceware.org Delivered-To: mailing list crossgcc@sourceware.org Here's a revised version of the patch which also diagnoses missing libstdc++.a, which, at least on my Fedora system, was not installed by default. This fails after several minutes of grinding away, so I think it's better to catch it early and help the user out. Sorry for the noise. -dp On Mon, Nov 19, 2012 at 2:55 PM, Yann E. MORIN wrote: > Daniel, All, > > On Monday 19 November 2012 Daniel Price wrote: >> Here it is again, as an attachment. I cannot (apparently) persuade >> gmail not to wrap lines. Apologies. > > Do not use gmail's web client. It is uterly broken. > Instead, use 'hg email' to send your patches. It can use your gmail > account as smtp server, but ensurss the patches are not mangled. > > I'll look at your patch later. Thank you! > > Regards, > Yann E. MORIN. > > -- > .-----------------.--------------------.------------------.--------------------. > | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | > | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | > | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | > | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | > '------------------------------^-------^------------------^--------------------' diff -r 5df2d60ca847 -r 0e65ef94066c scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Mon Nov 19 15:23:05 2012 -0800 +++ b/scripts/crosstool-NG.sh.in Mon Nov 19 16:13:49 2012 -0800 @@ -421,8 +421,7 @@ where=$(CT_Which "${tool}") fi - # Not all tools are available for all platforms, but some are really, - # bally needed + # Not all tools are available for all platforms, but some are required. if [ -n "${where}" ]; then CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'" printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}" @@ -474,17 +473,75 @@ *) ;; esac + # Now that we've set up $PATH, sanity test that GCC is runnable so that + # the user can troubleshoot problems if not. + CT_DoLog DEBUG "Sanity testing gcc" + gccout="${CT_BUILD_DIR}/.gcc-output" + GCC=${CT_HOST}-gcc + ret=0 + ${GCC} -v > $gccout 2>&1 || ret=$? + if [ $ret != 0 ]; then + CT_DoLog DEBUG "Failed to invoke '${GCC} -v' (exited ${ret}): Output Follows:" + CT_DoLog DEBUG "$(cat ${gccout})" + fi + case $ret in + 0) + ;; + 126) + CT_Abort "${GCC}: cannot execute; check permissions." + ;; + 127) + CT_Abort "${GCC}: not found in PATH; check for metacharacters or other problems in PATH (PATH=${PATH})" + ;; + *) + CT_Abort "Ran '${GCC} -v', but command failed with exit ${ret}" + ;; + esac + rm -f "${gccout}" + + CT_DoLog DEBUG "Testing that gcc can compile a trivial program" + tmp="${CT_BUILD_DIR}/.gcc-test" + # Try a trivial program to ensure the compiler works. + if ! "${CT_HOST}-gcc" -xc - -o "${tmp}" > ${gccout} 2>&1 <<-_EOF_ + int main() {return 0; } + _EOF_ + then + CT_DoLog DEBUG "'${GCC}' failed (exited ${ret}): Output Follows:" + CT_DoLog DEBUG "$(cat ${gccout})" + CT_Abort "Couldn't compile a trivial program using ${CT_HOST}-gcc" + fi + rm -f "${tmp}" "${gccout}" + # Now we know our host and where to find the host tools, we can check # if static link was requested, but only if it was requested if [ "${CT_WANTS_STATIC_LINK}" = "y" ]; then tmp="${CT_BUILD_DIR}/.static-test" - if ! "${CT_HOST}-gcc" -xc - -static -o "${tmp}" >/dev/null 2>&1 <<-_EOF_ + + CT_DoLog DEBUG "Testing that gcc can compile a trivial statically linked program" + if ! "${CT_HOST}-gcc" -xc - -static -o "${tmp}" > ${gccout} 2>&1 <<-_EOF_ int main() { return 0; } _EOF_ then - CT_Abort "Static linking impossible on the host system '${CT_HOST}'" + CT_DoLog DEBUG "'${GCC}' failed (exited ${ret}): Output Follows:" + CT_DoLog DEBUG "$(cat ${gccout})" + CT_Abort "Static linking impossible on the host system '${CT_HOST}'; is libc.a installed?" fi - rm -f "${tmp}" + rm -f "${tmp}" "${gccout}" + fi + + if [ "${CT_CC_STATIC_LIBSTDCXX}" = "y" ]; then + tmp="${CT_BUILD_DIR}/.static-test" + + CT_DoLog DEBUG "Testing that gcc can statically link libstdc++" + if ! "${CT_HOST}-gcc" -xc - -static -lstdc++ -o "${tmp}" > ${gccout} 2>&1 <<-_EOF_ + int main() { return 0; } + _EOF_ + then + CT_DoLog DEBUG "'${GCC}' failed (exited ${ret}): Output Follows:" + CT_DoLog DEBUG "$(cat ${gccout})" + CT_Abort "Failed to statically link to libstdc++ on the host system '${CT_HOST}'; is libstdc++.a installed?" + fi + rm -f "${tmp}" "${gccout}" fi # Help gcc