From patchwork Mon May 14 03:52:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 10396699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C74DE6038F for ; Mon, 14 May 2018 03:52:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA6BB29094 for ; Mon, 14 May 2018 03:52:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADF7E29097; Mon, 14 May 2018 03:52:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A4AE29094 for ; Mon, 14 May 2018 03:52:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751022AbeENDw4 (ORCPT ); Sun, 13 May 2018 23:52:56 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43088 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbeENDwz (ORCPT ); Sun, 13 May 2018 23:52:55 -0400 Received: by mail-pg0-f66.google.com with SMTP id p8-v6so1346603pgq.10 for ; Sun, 13 May 2018 20:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1DpBbVzLH3A2W7R6UrwQlfSoKDRJkfBRx3YafYLvjF4=; b=FpPfsGY0xkpMEAQBVpHpRSGCmOS6XYZNZSvXi9u6Mg8xBnfU94U3Z9tHaHmZO3zknx vZjPwOay/RL8nfRnwqsPKR9K3Fpy2LoXqQcxmN23lIa1gUiXsRVUn+Rx1x5kMwLYNL2y 1dty3QDQDqbnMturs5NrX67CyRGYrP/aUphACc+ounKHFjPguW8W5AiqDB0IbFflHNf7 MiJ1JBWLqyyCI75s3RgSlwUpFSE4KMWtI9h0a6nlp6cagemHSLXnd769FJNdUoBotzFm fG831NENeBX19ZUje7uVU92NwOHyqDNLyHRJJ2NcuTn4716l8CxERhYUQ4CeeuWdMLtl CQag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1DpBbVzLH3A2W7R6UrwQlfSoKDRJkfBRx3YafYLvjF4=; b=ltx2Vi/1SQbC7l2q9pljwltz0yOg+dZYyv6wxCJdGRTlEYFE8Cz4JeT35nbnQosjJs FMC2GDGr5xJq3gZphLUqnK7HHP4nwpSGjSLUmsiY4/aT2WCp3EDjJzuDWV/LS5Igq4Gu mF3h517liYUeiQwN8jny11drHIBRtAcNR1HpVl3PlbLqyRWlHkBEKZAvquJ0zzIGVPu4 ftYSg8cf6NvYFuroAYhtCJ8Iz1P60SZnII9gRi+NC4ijDu9ahYcaMrqpQl5ETfHM6xfB tBC5iUknheroW+SPg7L8fJlPEekU89XJSbSN+tt9PTTu2yDaTN72SIpqFQmqJx9Z4z1N lFHQ== X-Gm-Message-State: ALKqPwe9fXIAQfMCIK5ibW7nfwLrtkCTDFje6eB75/cdIGSxI6+mh9sl ZtscD1aLxvocoRxE3A4j9quGcg== X-Google-Smtp-Source: AB8JxZr9RpoPXE+Y5OZbaHhBrXPk+swPOTUTHNYEmuG31qQNa+pT3ve3dTku+WTKkFf3c26z30aKZQ== X-Received: by 2002:a62:965c:: with SMTP id c89-v6mr8674607pfe.37.1526269974665; Sun, 13 May 2018 20:52:54 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id d71-v6sm15668943pfd.48.2018.05.13.20.52.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 May 2018 20:52:53 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Cc: Nicholas Piggin , linuxppc-dev@lists.ozlabs.org, Masahiro Yamada , Segher Boessenkool , Steven Rostedt Subject: [PATCH v3 3/4] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS Date: Mon, 14 May 2018 13:52:27 +1000 Message-Id: <20180514035228.21316-4-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514035228.21316-1-npiggin@gmail.com> References: <20180514035228.21316-1-npiggin@gmail.com> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The powerpc toolchain can compile combinations of 32/64 bit and big/little endian, so it's convenient to consider, e.g., `CC -m64 -mbig-endian` To be the C compiler for the purpose of invoking it to build target artifacts. So overriding the the CC variable to include thse flags works for this purpose. Unfortunately that is not compatible with the way the proposed new Kconfig macro language will work. After previous patches in this series, these flags can be carefully passed in using flags instead. Signed-off-by: Nicholas Piggin --- Since v2: - removed extra -EB in the recordmcount script (thanks mpe) arch/powerpc/Makefile | 16 +++++++++------- scripts/recordmcount.pl | 7 +++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 167b26a0780c..6faf1d6ad9dd 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -75,13 +75,15 @@ endif endif ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) -override LD += -EL +KBUILD_CFLAGS += -mlittle-endian +LDFLAGS += -EL LDEMULATION := lppc GNUTARGET := powerpcle MULTIPLEWORD := -mno-multiple KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) else -override LD += -EB +KBUILD_CFLAGS += $(call cc-option,-mbig-endian) +LDFLAGS += -EB LDEMULATION := ppc GNUTARGET := powerpc MULTIPLEWORD := -mmultiple @@ -94,19 +96,19 @@ 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 +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) +cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ifeq ($(HAS_BIARCH),y) -override AS += -a$(BITS) -override LD += -m elf$(BITS)$(LDEMULATION) -override CC += -m$(BITS) +KBUILD_CFLAGS += -m$(BITS) +KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) +LDFLAGS += -m elf$(BITS)$(LDEMULATION) KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) endif diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 191eb949d52c..3c67304a7425 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -274,6 +274,13 @@ if ($arch eq "x86_64") { if ($bits == 64) { $type = ".quad"; } + if ($endian eq "big") { + $cc .= " -mbig-endian "; + $ld .= " -EB "; + } else { + $cc .= " -mlittle-endian "; + $ld .= " -EL "; + } } elsif ($arch eq "arm") { $alignment = 2;