From patchwork Mon Feb 23 17:17:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 442619 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 3A5EB14016A for ; Tue, 24 Feb 2015 04:17:55 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=c+CamBU3wKlGjy1PGpn3VkaPSVRRr 0yFF7XCvhS8KcMt9HTaikBCh6zWtAlWwEkYxOEHN8ze1A+/eZdDEfA7FjnvalpSn kyuGqvsgRJPkrjt+j8dQPDAx8Dyxw5gwUmCPNwobacysVYerntCqLz7ZStDLAiRG YGDlNsqULGZ7yk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=PfBtW2+h1/+COewhOAsrrMBuXH8=; b=Rpi 9nrjRgTGs/feGfgwxm36G/w6zoXavza82INuwl1xQaxv38BXDTxlriEG59UaCHs4 wHGfVF56Hh/Gvw2k+2gfzEfqBQ7ut0gSun2+FnSOTPaGG47ojsVfSNP3ZudEKW24 aO5UhvdkELYVuoInUaMKdyIT1lBEmByVlL82RW+w= Received: (qmail 20893 invoked by alias); 23 Feb 2015 17:17:48 -0000 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 Received: (qmail 20880 invoked by uid 89); 23 Feb 2015 17:17:47 -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, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Feb 2015 17:17:46 +0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 23 Feb 2015 09:13:29 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([172.25.70.151]) by orsmga003.jf.intel.com with ESMTP; 23 Feb 2015 09:08:44 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id A4A1F200ACC; Mon, 23 Feb 2015 09:17:43 -0800 (PST) Date: Mon, 23 Feb 2015 09:17:43 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org, GNU C Library Cc: binutils@sourceware.org, config-patches@gnu.org Subject: [PATCH] PR bootstrap/65176: config.guess failed to guess machine with 64-bit kernel and 32-bit user space Message-ID: <20150223171743.GA32755@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) 32-bit and x32 user-space environments may be running under Linux/x86-64 kernel. Using "uname -m" isn't sufficient to properly detect the canonical system name for 32-bit and x32 user-space environments. This patch checks if compiler is configured for 64-bit, 32-bit or x32 objects under Linux/x86-64 kernel. Tested with 64-bit, 32-bit and x32 user-space environments under Linux/x86-64 kernel. I am not sure if this will ever be accepted in upstream since the config.guess maintainer doesn't want to add a new use of set_cc_for_build to config.guess. set_cc_for_build is used for Linux: case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; Adding another use for Linux/x86-64 solves this issue. I'd like to see this fixed in gcc, binutils and glibc even if it won't be fixed in upstream. Thanks. H.J. --- PR bootstrap/65176 * config.guess (x86_64:Linux:*:*): Check if compiler is configured for 64-bit, 32-bit or x32 objects. --- config.guess | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/config.guess b/config.guess index dbfb978..e5a2d41 100755 --- a/config.guess +++ b/config.guess @@ -1021,7 +1021,26 @@ EOF echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + eval $set_cc_for_build + LINUX_MACHINE="i686" + LINUX_LIBC=${LIBC} + # If there is a compiler, see if it is configured for 64-bit, + # 32-bit or x32 objects. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __x86_64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + LINUX_MACHINE="x86_64" + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LINUX_LIBC=gnux32 + fi + fi + fi + echo ${LINUX_MACHINE}-unknown-linux-${LINUX_LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC}