From patchwork Thu Sep 4 20:58:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 386018 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 E0B4F140183 for ; Fri, 5 Sep 2014 06:58:58 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:date:to:cc:subject:mime-version :content-type:content-transfer-encoding:message-id; q=dns; s= default; b=l1M6iXHUIIj/qBGOW1hLQB5DuZAppB1CtH28fDuaHpOwNCiSOkmdf axX/vX8v9Aa8S2/pUGUqFpRZZXL4IIXNkwW+4+htHj9b+KZ2F//ivsX2FZF/l9pM Xx6HevRbfaZ6ZP2Bfen2RbQZibxTM14YSMIMbmfZz8Vb+d6wKbKQIo= 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:from:date:to:cc:subject:mime-version :content-type:content-transfer-encoding:message-id; s=default; bh=GJ3ndh1hsTvl/cXhkRpzS4pc13k=; b=UakURBPyKTt2Q6gT4RR1Gqh+XbQ+ t4St894tTFdTXd7SH77QyuuTR5Fr52XWK5/sCh8jada6pUnNIE/vPePyNO1TUaH6 NQATx3C0uNkENGwvLLzeSF6KZd0g0Q6P9Wzx6LKj6OMFD+42fOpeZMI2rDbid6im DZnjJ5PoTzX4peI= Received: (qmail 20601 invoked by alias); 4 Sep 2014 20:58:50 -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 20586 invoked by uid 89); 4 Sep 2014 20:58:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com From: "Steve Ellcey " Date: Thu, 4 Sep 2014 13:58:39 -0700 To: CC: , Subject: [PATCH] Cleanup MIPS preconfigure script User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-ID: <6b5ce132-2a69-4ee9-aaa5-d07792e72b50@BAMAIL02.ba.imgtec.org> I would like to simplify the MIPS preconfigure script. Right now it looks at the GCC flags and tries to determine what it should set 'machine' to based on those flags (and os_config). I would like to run the compiler and check what macros are set and use that to set the machine variable instead. This seems safer since right now a platform that generated the n64 ABI by default (as an example) might not work correctly because the '-mabi=64' flag would not need to appear in $CFLAGS to generate n64 code. Other platforms like arm, m68k, powerpc, and tile are already using this technique of calling the compiler and checking macros and the macros I am checking on MIPS (_MIPS_SIM, _MIPS_ISA, and __mips16) are already used in various glibc source files. Note that I removed the reference to kern64 since it no longer exists and I removed the addition of $machine from the end of the 'machine=' line for mips32 as there did not seem to be any reason for it. Tested with mips-mti-linux-gnu and mips-linux-gnu and mips64-linux-gnu builds. OK to checkin? Steve Ellcey sellcey@mips.com 2014-09-04 Steve Ellcey * sysdeps/mips/preconfigure: Modify ABI tests. diff --git a/sysdeps/mips/preconfigure b/sysdeps/mips/preconfigure index b215eb2..df958d6 100644 --- a/sysdeps/mips/preconfigure +++ b/sysdeps/mips/preconfigure @@ -1,34 +1,25 @@ -case "$machine" in -mips64*) base_machine=mips64 - case "$CC $CFLAGS $CPPFLAGS " in - *" -mabi=n32 "*) mips_cc_abi=n32 ;; - *" -mabi=64 "*|*" -mabi=n64 "*) mips_cc_abi=64 ;; - *" -mabi=32 "*|*" -mabi=o32 "*) mips_cc_abi=32 ;; - *) mips_cc_abi=default ;; - esac - case $config_os in - *abin32*) mips_config_abi=n32 ;; - *abi64*|*abin64*) mips_config_abi=64 ;; - *abi32*|*abio32*) mips_config_abi=32 ;; - *) mips_config_abi=$mips_cc_abi ;; - esac - case $mips_config_abi in - default) machine=mips/mips64/n32 mips_config_abi=n32 ;; - n32) machine=mips/mips64/n32 ;; - 64) machine=mips/mips64/n64 ;; - 32) machine=mips/mips32/kern64 ;; - esac - machine=$machine/$config_machine - if test $mips_config_abi != $mips_cc_abi; then - # This won't make it to config.make, but we want to - # set this in case configure tests depend on it. - CPPFLAGS="$CPPFLAGS -mabi=$mips_config_abi" - fi - ;; -mips*) base_machine=mips - case "$CC $CFLAGS $CPPFLAGS " in - *" -mips16 "*) machine=mips/mips32/mips16/$machine ;; - *) machine=mips/mips32/$machine ;; - esac - ;; -esac + +abiflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define _MIPS_SIM \(.*\)/\1/p'` +isaflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define _MIPS_ISA \(.*\)/\1/p'` +mips16flag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __mips16 \(.*\)/\1/p'` + +if test "$isaflag" = "_MIPS_ISA_MIPS64"; then + base_machine=mips64 + if test "$abiflag" = "_ABIO32" ; then + machine=mips/mips32 + elif test "$abiflag" = "_ABIN32" ; then + machine=mips/mips64/n32 + elif test "$abiflag" = "_ABI64" ; then + machine=mips/mips64/n64 + else + as_fn_error $? "Unable to determine ABI." "$LINENO" 5 + fi +else + base_machine=mips + if test "$mips16flag" = "1" ; then + machine=mips/mips32/mips16 + else + machine=mips/mips32 + fi +fi +machine=$machine/$config_machine