From patchwork Wed Jul 13 16:13:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 104555 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 E88061007D3 for ; Thu, 14 Jul 2011 02:13:49 +1000 (EST) Received: (qmail 24461 invoked by alias); 13 Jul 2011 16:13:46 -0000 Received: (qmail 24409 invoked by uid 22791); 13 Jul 2011 16:13:32 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtprelay01.ispgateway.de (HELO smtprelay01.ispgateway.de) (80.67.29.23) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Jul 2011 16:13:13 +0000 Received: from [87.180.39.191] (helo=stokes.schwinge.homeip.net) by smtprelay01.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1Qh23j-0001OI-84 for gcc-patches@gcc.gnu.org; Wed, 13 Jul 2011 18:13:11 +0200 Received: (qmail 14068 invoked from network); 13 Jul 2011 16:13:07 -0000 Received: from kepler.schwinge.homeip.net (192.168.111.7) by stokes.schwinge.homeip.net with QMQP; 13 Jul 2011 16:13:07 -0000 Received: (nullmailer pid 8373 invoked by uid 1000); Wed, 13 Jul 2011 16:13:06 -0000 From: Thomas Schwinge To: gcc-patches@gcc.gnu.org Subject: [PATCH] bash vs. dash: Avoid unportable shell feature in gcc/configure.ac User-Agent: Notmuch/0.5-77-g335dd52 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) Date: Wed, 13 Jul 2011 18:13:02 +0200 Message-ID: <87mxgi5fch.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 X-Df-Sender: thomas@schwinge.name Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hallo! Diffing the make log of a build of GCC with SHELL not explicitly set (thus /bin/sh, which is bash) and one with SHELL=/bin/dash, I found the following unexpected difference: -checking assembler for eh_frame optimization... yes +checking assembler for eh_frame optimization... buggy This is from gcc/configure; which invokes acinclude.m4:gcc_GAS_CHECK_FEATURE for the ``eh_frame optimization'' check. Latter case, gcc/config.log: configure:22282: checking assembler for eh_frame optimization configure:22327: /usr/bin/as --32 -o conftest.o conftest.s >&5 conftest.s: Assembler messages: conftest.s: Warning: end of file in string; '"' inserted conftest.s:13: Warning: unterminated string; newline inserted There, the following happens: $ sh # This is bash. sh-4.1$ echo '.ascii "z\0"' .ascii "z\0" This is what GCC expects. However, with dash: $ dash $ echo '.ascii "z\0"' .ascii "z The backslash escape and everything after is cut off. The test in gcc/configure.ac: gcc_GAS_CHECK_FEATURE(eh_frame optimization, gcc_cv_as_eh_frame, [elf,2,12,0],, [ .text [...] .byte 0x1 .ascii "z\0" .byte 0x1 [...] As quickly determined in #gcc with Ian's and Ismail's help, this is unportable usage of the echo builtin (and also at least questionable for /bin/echo), so I'm suggesting the following simple fix: gcc/ * configure.ac (eh_frame optimization): Avoid unportable shell feature. Alternatively, gcc_GAS_CHECK_FEATURE could be changed to emit the temporary file by using a shell here-doc, which is what AC_TRY_COMPILE is doing, for example. Grüße, Thomas diff --git a/gcc/configure.ac b/gcc/configure.ac index c2163bf..73f0209 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2538,7 +2538,7 @@ __FRAME_BEGIN__: .LSCIE1: .4byte 0x0 .byte 0x1 - .ascii "z\0" + .asciz "z" .byte 0x1 .byte 0x78 .byte 0x1a