From patchwork Sun Nov 27 02:46:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 699601 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tRDkq28wwz9vDc for ; Sun, 27 Nov 2016 13:48:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nCGMwJoc"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3tRDkq0m2mzDvtL for ; Sun, 27 Nov 2016 13:48:03 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nCGMwJoc"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3tRDjC508YzDvpJ for ; Sun, 27 Nov 2016 13:46:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nCGMwJoc"; dkim-atps=neutral Received: by mail-pg0-x241.google.com with SMTP id x23so9313213pgx.3 for ; Sat, 26 Nov 2016 18:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=dTmoEDWHvd/yht5OpcaxpOQ1VLQ0JMNnbvsiXz9dGnk=; b=nCGMwJoctoJXTGp1HSL9wcFrxrHVtajyIm+KAflACA36NOWQ+aY5ELc7URgl4dx41F KHy11sJbVqsLxFcPloe2UhUqlH6FW+A8SYZZ0DpD5hG4z/l5Z/a+Gn2e0u1xnw+KkOS5 gwQofYQ+SJ95poK2i795pKA95osX+FNyZdJSRezmS/N4g0rU9smQymYfUW1J7vB0tM/1 r2/MZu38GWKqdRQbpi8g4BRd0aGASN7xO8vuSCCmMBWppsPbB+LBHhL6SzRXLnMxKaiq XBGTJ6FGKx7lQfsc9EzZfxNflcq1NbgIIIBUKLzDaxPzWTFim/vuWORixLH04P9uhorR uxRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=dTmoEDWHvd/yht5OpcaxpOQ1VLQ0JMNnbvsiXz9dGnk=; b=haWniPVOKVRfE7hlXe+HpalCEktRKnd0qPm8Uiya6oYrS0J5js53svjDwC0Jttvkhu /vSO9muSHDahO2pCCHo/qJT6CAmNhI4zNFIxBRbenWvyu0+rJupFphyNDP8Bt6x+RvqX Zog5v4iNbzo5GN2Od1o8RZsOySKviEhiCkqAAg9AZdo/y7cdUrozK34AFMXtGQryjvCX jkfV2YABayyBdMK8F3BXd0/PYCQbqcyZnFpi3MQK74Whv/AtfrreHHLV7JBDg67e9LCv zYis53DwiRmE2vTKEey7RQntmJE3C4KFhauZfYbbB2eT+VKmllb2GESK0XCyFDBTJ9s0 KhNg== X-Gm-Message-State: AKaTC039a716ib/IOTytG2BUPGYMGkU6BfAXwtWUmPckvTtckqYZvvUVd1RUv2DBMiRqlQ== X-Received: by 10.99.44.84 with SMTP id s81mr27772014pgs.153.1480214797059; Sat, 26 Nov 2016 18:46:37 -0800 (PST) Received: from roar.ozlabs.ibm.com (27-33-21-189.tpgi.com.au. [27.33.21.189]) by smtp.gmail.com with ESMTPSA id w16sm59556363pgc.30.2016.11.26.18.46.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Nov 2016 18:46:36 -0800 (PST) Date: Sun, 27 Nov 2016 13:46:20 +1100 From: Nicholas Piggin To: Michael Ellerman Subject: Re: [PATCH 2/3] powerpc: allow compilation on cross-endian toolchain Message-ID: <20161127134620.74007843@roar.ozlabs.ibm.com> In-Reply-To: <87lgw6snp4.fsf@concordia.ellerman.id.au> References: <20161123130209.1667-1-npiggin@gmail.com> <20161123130209.1667-3-npiggin@gmail.com> <20161124200423.45c5ec87@roar.ozlabs.ibm.com> <87lgw6snp4.fsf@concordia.ellerman.id.au> Organization: IBM X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, Alan Modra Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sat, 26 Nov 2016 18:30:15 +1100 Michael Ellerman wrote: > Nicholas Piggin writes: > > On Thu, 24 Nov 2016 00:02:08 +1100 > > diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile > > index 617dece..8828807 100644 > > --- a/arch/powerpc/Makefile > > +++ b/arch/powerpc/Makefile > > @@ -73,13 +73,18 @@ MULTIPLEWORD := -mmultiple > > endif > > > > cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) > > +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) > > +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc) > > This blew up the world: > > http://kisskb.ellerman.id.au/kisskb/head/1ba4cb3d67e181bdc9a911d7be81f64e3d7597d2/ > > Successful: 24% 63/258 > > I suspect you need to make -mcall-aixdesc 64-bit only. Yes, I forgot 32-bit will pick those up. 3rd time's a charm, this compiles 64 bit be/le and 32-bit now. Tested-by: Naveen N. Rao --- Subject: [PATCH] powerpc: allow compilation on cross-endian toolchain GCC can compile with either endian, but the ABI version always defaults to the default endian. Alan Modra says: you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc generate powerpc64 code The opposite is true for powerpc64 when generating -mlittle it requires -mabi=elfv2 to generate v2 ABI. This change adds ABI annotations together with endianness. The kernel with ELFv2 ABI also uses -mcall-aixdesc, but boot/ does not. Signed-off-by: Nicholas Piggin --- arch/powerpc/Makefile | 11 ++++++++++- arch/powerpc/boot/Makefile | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 617dece..a60c9c6 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -72,8 +72,15 @@ GNUTARGET := powerpc MULTIPLEWORD := -mmultiple endif -cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) +ifdef CONFIG_PPC64 +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc) +aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) +aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 +endif + cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) ifneq ($(cc-name),clang) cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align endif @@ -113,7 +120,9 @@ ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc)) AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2) else +CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc) +AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) endif CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc)) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index eae2dc8..7c46cf3 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -28,14 +28,16 @@ BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -isystem $(shell $(CROSS32CC) -print-file-name=include) \ -D$(compress-y) +# PPC64_BOOT_WRAPPER is little-endian specific. ifdef CONFIG_PPC64_BOOT_WRAPPER BOOTCFLAGS += -m64 +BOOTCFLAGS += $(call cc-option,-mabi=elfv2) endif + ifdef CONFIG_CPU_BIG_ENDIAN BOOTCFLAGS += -mbig-endian else BOOTCFLAGS += -mlittle-endian -BOOTCFLAGS += $(call cc-option,-mabi=elfv2) endif BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc