From patchwork Mon Nov 19 22:40:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Price X-Patchwork-Id: 200208 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 F10DC2C0079 for ; Tue, 20 Nov 2012 09:40:47 +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=1353969648; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Subscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=eQ/p8vRfWDiATUa/1t8TL+TvLHw=; b=jt9WcFOopWOkE7R a+hlc5exkvhMNghJOw6rW5YzGJdq/SXumrS1F07jsH+Z+mUwKx/L1r6+Qc921acg cJcu6GeBN3/mjt6ZYcQiWhkJ/yCX00QyK32Onp6BRWcOfAwX1zwuU86imrzafvGQ T3KzmUmrJmZO5r+T7sXyWz4+FtIc= 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:Date:Message-ID:Subject:From:To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=oFbtiDhN38QZrWlPN90EDtME58cC/ztXY2hoXGF209h9vnZEaHLl6mYgiJkK4u 9geIsm3iDTEUbcV+xsM/rodQZNsTRMUo3gDnCeKXDrPbEgNrtVve4GBlhQ3wuqZw JKNJsD3ZY2pSEFa1jumsYM/AtNxgTfyntqCYgY48BEQ4c=; Received: (qmail 26665 invoked by alias); 19 Nov 2012 22:40:35 -0000 Received: (qmail 26630 invoked by uid 22791); 19 Nov 2012 22:40:33 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE 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; Mon, 19 Nov 2012 22:40:29 +0000 Received: by mail-bk0-f41.google.com with SMTP id jg9so2316166bkc.0 for ; Mon, 19 Nov 2012 14:40:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.149.85 with SMTP id s21mr5222339bkv.37.1353364827783; Mon, 19 Nov 2012 14:40:27 -0800 (PST) Received: by 10.204.178.195 with HTTP; Mon, 19 Nov 2012 14:40:27 -0800 (PST) Date: Mon, 19 Nov 2012 14:40:27 -0800 Message-ID: Subject: [PATCH 1 of 1] refine static linking check to better guide user From: Daniel Price To: 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 An IRC discussion with Yann last week led to a request that I submit a patch which covers a series of blunders I made as a novice user of crosstool. One was that I didn't have static libc installed on my host system, and was stymied by the wording of the message: "Static linking impossible on the host system" (solution: install the static glibc package). Two was that I had a misconfigured directory structure which had a ':' in it-- this causes $PATH to be misparsed, and, ironically, trips the "Static linking impossible" message all over again. Via google, I have noticed that the "static linking" error message has come up a number of times, and this patch hopefully will help to clarify for the user what they might need to do to make crosstool work for them by first proving that gcc is present, can compile a trivial program, and can compile trivial static binaries. I also adjusted the error messages somewhat in order to provide some hints if things go wrong. Comments appreciated; I made a number of editorial decisions which perhaps not everyone would agree with. Also, my ability to test this on a variety of hosts is very limited. Thanks, -dp # HG changeset patch # User Daniel Price # Date 1353364265 28800 # Node ID fe774e44305a643f553b509a147e7fc78ed7d3dd # Parent 1c68438f44f74e7fcf761838271f1e4d156ceeda scripts: refine static linking check to better guide the user Signed-off-by: Daniel Price CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'" printf "#${BANG}${CT_CONFIG_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_BUILDTOOLS_PREFIX_DIR}/bin/${!v}-${tool}" @@ -475,17 +474,60 @@ *) ;; 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 # Help gcc --- Daniel.Price@gmail.com; Twitter: @danielbprice -- For unsubscribe information see http://sourceware.org/lists.html#faq diff -r 1c68438f44f7 -r fe774e44305a scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Fri Nov 16 14:59:27 2012 +0100 +++ b/scripts/crosstool-NG.sh.in Mon Nov 19 14:31:05 2012 -0800 @@ -422,8 +422,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