From patchwork Sun May 5 06:39:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 241503 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D9A6D2C00CF for ; Sun, 5 May 2013 16:39:46 +1000 (EST) 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:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=tIk1InZuLL9vhWnLSMPYgmH2TP6hDG jUagzC6Rww6QLbcyaBlRHqyurQ/ZQW1+56+hAXwbUedAoZXFiErMjqp2NVFpiv/R K1HoFTtdAOAaBNr/IFJfJytbx3r/hmj57WnHldn+yFrVHghMeN55GuvQriuXCRaE 68GVqD0eL/DUY= 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:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=G5YQWS3xFvztRwkW9O13PJL0xQ8=; b=W3qZ S8HYxJ4dm6QSHEidJs4CMoFSKlyBRwXTRJ9pOYgUaAEHbkyIcpknA6dYHs2xUCG6 4pvSiFLxUzTIw5WFfiMU0KXgT0nHVlobWYffsKwrtkA4EHbVjeLhH16rCheXBuBc B6AJNlFx/vDhw4Q03UaKaBbIh/Fv93IKBgTcK1w= Received: (qmail 26310 invoked by alias); 5 May 2013 06:39:40 -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 26300 invoked by uid 89); 5 May 2013 06:39:40 -0000 X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 05 May 2013 06:39:38 +0000 Received: by mail-pa0-f42.google.com with SMTP id bj3so1537879pad.1 for ; Sat, 04 May 2013 23:39:37 -0700 (PDT) X-Received: by 10.68.170.66 with SMTP id ak2mr20509848pbc.123.1367735977219; Sat, 04 May 2013 23:39:37 -0700 (PDT) Received: from bubble.grove.modra.org ([101.166.26.37]) by mx.google.com with ESMTPSA id to7sm20197015pab.0.2013.05.04.23.39.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 May 2013 23:39:36 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id DE38DEA2C6B; Sun, 5 May 2013 16:09:30 +0930 (CST) Date: Sun, 5 May 2013 16:09:30 +0930 From: Alan Modra To: gcc-patches@gcc.gnu.org, David Edelsohn Subject: Re: powerpc64le-linux support Message-ID: <20130505063930.GY5221@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org, David Edelsohn References: <20130424104744.GO22536@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130424104744.GO22536@bubble.grove.modra.org> User-Agent: Mutt/1.5.21 (2010-09-15) This tidies endian selection. Prior to this change, if you gave a little-endian gcc the -mcall-aixdesc option, gcc would operate big-endian but the assembler in little-endian. Which was confusing to say the least. The sysv4.h changes below don't actually make any substantive changes in the specs file, except to always add a default endian option to ASM_SPEC. I think that's wise given a bi-endian binutils can be built with either endian default. The linux64.h changes are a little more substantive in order to cure the mixed endian problem. The endian rules are: a) Specify -mbig/-mlittle/-mbig-endian/-mlitte-endian and that's what you get, otherwise, b) specify any of the -mcall options except the -mcall-sysv variants and you get an endian appropriate to the -mcall, mostly big, otherwise c) you get the default endian for your toolchain which depends on configure options. Something to consider for the future is making more of the -mcall options endian agnostic, like -mcall-sysv. Tested with a number of powerpc ELF builds. * config/rs6000/sysv4.h (ENDIAN_SELECT): Define, extracted from (ASM_SPEC): ..here. Emit DEFAULT_ASM_ENDIAN too. (DEFAULT_ASM_ENDIAN): Define. (CC1_SPEC, LINK_TARGET_SPEC): Use ENDIAN_SELECT. * config/rs6000/linux64.h (ASM_SPEC32): Remove endian options. Update -K PIC clause from sysv4.h. (ASM_SPEC_COMMON): Use ENDIAN_SELECT. (LINK_OS_LINUX_EMUL32, LINK_OS_LINUX_EMUL64): Likewise. Index: gcc/config/rs6000/sysv4.h =================================================================== --- gcc/config/rs6000/sysv4.h (revision 198274) +++ gcc/config/rs6000/sysv4.h (working copy) @@ -517,19 +523,28 @@ while (0) #endif +/* Select one of BIG_OPT, LITTLE_OPT or DEFAULT_OPT depending + on various -mbig, -mlittle and -mcall- options. */ +#define ENDIAN_SELECT(BIG_OPT, LITTLE_OPT, DEFAULT_OPT) \ +"%{mlittle|mlittle-endian:" LITTLE_OPT ";" \ + "mbig|mbig-endian:" BIG_OPT ";" \ + "mcall-aixdesc|mcall-freebsd|mcall-netbsd|" \ + "mcall-openbsd|mcall-linux:" BIG_OPT ";" \ + "mcall-i960-old:" LITTLE_OPT ";" \ + ":" DEFAULT_OPT "}" + +#if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) +#define DEFAULT_ASM_ENDIAN " -mlittle" +#else +#define DEFAULT_ASM_ENDIAN " -mbig" +#endif + #undef ASM_SPEC #define ASM_SPEC "%(asm_cpu) \ %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \ %{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \ -%{memb|msdata=eabi: -memb} \ -%{mlittle|mlittle-endian:-mlittle; \ - mbig|mbig-endian :-mbig; \ - mcall-aixdesc | \ - mcall-freebsd | \ - mcall-netbsd | \ - mcall-openbsd | \ - mcall-linux :-mbig; \ - mcall-i960-old :-mlittle}" +%{memb|msdata=eabi: -memb}" \ +ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) #define CC1_ENDIAN_BIG_SPEC "" @@ -547,17 +562,10 @@ #endif /* Pass -G xxx to the compiler and set correct endian mode. */ -#define CC1_SPEC "%{G*} %(cc1_cpu) \ -%{mlittle|mlittle-endian: %(cc1_endian_little); \ - mbig |mbig-endian : %(cc1_endian_big); \ - mcall-aixdesc | \ - mcall-freebsd | \ - mcall-netbsd | \ - mcall-openbsd | \ - mcall-linux : -mbig %(cc1_endian_big); \ - mcall-i960-old : -mlittle %(cc1_endian_little); \ - : %(cc1_endian_default)} \ -%{meabi: %{!mcall-*: -mcall-sysv }} \ +#define CC1_SPEC "%{G*} %(cc1_cpu)" \ + ENDIAN_SELECT(" %(cc1_endian_big)", " %(cc1_endian_little)", \ + " %(cc1_endian_default)") \ +"%{meabi: %{!mcall-*: -mcall-sysv }} \ %{!meabi: %{!mno-eabi: \ %{mrelocatable: -meabi } \ %{mcall-freebsd: -mno-eabi } \ @@ -601,11 +609,8 @@ %{symbolic:-Bsymbolic -G -dy -z text }" /* Override the default target of the linker. */ -#define LINK_TARGET_SPEC "\ -%{mlittle: --oformat elf32-powerpcle } %{mlittle-endian: --oformat elf32-powerpcle } \ -%{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \ - %{mcall-i960-old: --oformat elf32-powerpcle} \ - }}}}" +#define LINK_TARGET_SPEC \ + ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") /* Any specific OS flags. */ #define LINK_OS_SPEC "\ Index: gcc/config/rs6000/linux64.h =================================================================== --- gcc/config/rs6000/linux64.h (revision 198274) +++ gcc/config/rs6000/linux64.h (working copy) @@ -180,20 +183,14 @@ #endif #define ASM_SPEC32 "-a32 \ -%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \ -%{memb} %{!memb: %{msdata=eabi: -memb}} \ -%{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \ - %{mcall-freebsd: -mbig} \ - %{mcall-i960-old: -mlittle} \ - %{mcall-linux: -mbig} \ - %{mcall-netbsd: -mbig} \ -}}}}" +%{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \ +%{memb|msdata=eabi: -memb}" #define ASM_SPEC64 "-a64" #define ASM_SPEC_COMMON "%(asm_cpu) \ -%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \ -%{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}" +%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \ + ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) #undef SUBSUBTARGET_EXTRA_SPECS #define SUBSUBTARGET_EXTRA_SPECS \ @@ -373,11 +376,19 @@ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64) #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) -#define LINK_OS_LINUX_EMUL32 "%{!mbig: %{!mbig-endian: -m elf32lppclinux}}%{mbig|mbig-endian: -m elf32ppclinux}" -#define LINK_OS_LINUX_EMUL64 "%{!mbig: %{!mbig-endian: -m elf64lppc}}%{mbig|mbig-endian: -m elf64ppc}" +#define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \ + " -m elf32lppclinux", \ + " -m elf32lppclinux") +#define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \ + " -m elf64lppc", \ + " -m elf64lppc") #else -#define LINK_OS_LINUX_EMUL32 "%{!mlittle: %{!mlittle-endian: -m elf32ppclinux}}%{mlittle|mlittle-endian: -m elf32lppclinux}" -#define LINK_OS_LINUX_EMUL64 "%{!mlittle: %{!mlittle-endian: -m elf64ppc}}%{mlittle|mlittle-endian: -m elf64lppc}" +#define LINK_OS_LINUX_EMUL32 ENDIAN_SELECT(" -m elf32ppclinux", \ + " -m elf32lppclinux", \ + " -m elf32ppclinux") +#define LINK_OS_LINUX_EMUL64 ENDIAN_SELECT(" -m elf64ppc", \ + " -m elf64lppc", \ + " -m elf64ppc") #endif #define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \