From patchwork Wed May 16 14:14:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 914655 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40mGlq2nSMz9s1d for ; Thu, 17 May 2018 00:19:35 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QwzkBDh+"; 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 40mGlq1J9vzF14t for ; Thu, 17 May 2018 00:19:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QwzkBDh+"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QwzkBDh+"; dkim-atps=neutral Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (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 40mGfq0t8ZzDr4q for ; Thu, 17 May 2018 00:15:14 +1000 (AEST) Received: by mail-pl0-x244.google.com with SMTP id u6-v6so504273pls.9 for ; Wed, 16 May 2018 07:15:14 -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=1GeBK5SSztMEHl9rgjJyLefK/ad1o6jtXXL8fkHGm5M=; b=QwzkBDh+jN+u0a5XOk40sxbua60Izl5xrS95HDiCqolxnYpHH4KwHYU9QemCsQhWKa uf46EOa/EZOyZo46s9voM3w7DcexiT7A2Y75ccm7ClpXsZ1zjBoaqwRPU2xmtYxmX/8g 3ubugCGf+GRAIMvpO/+E1sOacVCVL8qKap44TyU2Txe+LgHf3QwXyGMFYx0/FVjnt4z+ vd2klPjBWw17RcKYlcjpKLv190RlUNN0eM7uAB18V3sdi3xoXkqkvIwe8vLW4iq6hJMe U/qmlePxzuV1KKmKA/TBNSBdHpVfyh8F9/pVon8W8esVXO+QvNuxP+IkU999lPhifnSz MUhg== 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=1GeBK5SSztMEHl9rgjJyLefK/ad1o6jtXXL8fkHGm5M=; b=mMLWhMw2r/K6srZcfmsuKZNi9Qzi+DcltHOcTzyFR4Qbpl10K7vQ5R2WxEc6Hu4M69 7zEZ69Th6KXGR1h5UCTE008pUUcz7cvMD6ZYAjw9gt6KkGVw0aSTkRdcaDij6gur0itA l8xBv6I94IebhYoBYuzwix9CJ0JkByffRJfRZYk98KkR2mDF9dYPUQmJYeI8n/bueS+O Nbq7MDkziiK25cSB9JBFkh1LjJ59pIxLZC+6xEZWBRbsmqtogL/qsw7fJN2fBQxSupJa MUx3QkO5xBjc3uBAIIv30eitnPpJa4jnJGs+7CiNOIEdoQdr20qk+t6PfzlBQrloqmu0 D+Fw== X-Gm-Message-State: ALKqPwfwD0j1F4A2qtKPx2QF2vRZ3KXO1ZqP0KQuasV6sYFXEuWeBd99 ctJP5T1BCJ9qSpcFU9LEW4I= X-Google-Smtp-Source: AB8JxZqigzwlU+6VGc+WGlouavKlrKF9h1htmy8HzIbe5n85DiezI3FC7SYhydEU1u/tuUjVIo+Vdw== X-Received: by 2002:a17:902:265:: with SMTP id 92-v6mr1121494plc.368.1526480113247; Wed, 16 May 2018 07:15:13 -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 h130-v6sm7365162pfc.98.2018.05.16.07.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 07:15:12 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Subject: [PATCH v4 1/4] powerpc/kbuild: set default generic machine type for 32-bit compile Date: Thu, 17 May 2018 00:14:55 +1000 Message-Id: <20180516141458.18996-2-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516141458.18996-1-npiggin@gmail.com> References: <20180516141458.18996-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linuxppc-dev@lists.ozlabs.org, Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Some 64-bit toolchains uses the wrong ISA variant for compiling 32-bit kernels, even with -m32. Debian's powerpc64le is one such case, and that is because it is built with --with-cpu=power8. So when cross compiling a 32-bit kernel with a 64-bit toolchain, set -mcpu=powerpc initially, which is the generic 32-bit powerpc machine type and scheduling model. CPU and platform code can override this with subsequent -mcpu flags if necessary. This is not done for 32-bit toolchains otherwise it would override their defaults, which are presumably set appropriately for the environment (moreso than a 64-bit cross compiler). This fixes a lot of build failures due to incompatible assembly when compiling 32-bit kernel with th Debian powerpc64le 64-bit toolchain. Cc: Segher Boessenkool Signed-off-by: Nicholas Piggin --- arch/powerpc/Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 95813df90801..15ca4bafad82 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -24,9 +24,20 @@ ifeq ($(HAS_BIARCH),y) ifeq ($(CROSS32_COMPILE),) CROSS32CC := $(CC) -m32 KBUILD_ARFLAGS += --target=elf32-powerpc + +ifdef CONFIG_PPC32 +# These options will be overridden by any -mcpu option that the CPU +# or platform code sets later on the command line, but they are needed +# to set a sane 32-bit cpu target for the 64-bit cross compiler which +# may default to the wrong ISA. +KBUILD_CFLAGS += -mcpu=powerpc +KBUILD_AFLAGS += -mcpu=powerpc +endif + endif endif + export CROSS32CC CROSS32AR ifeq ($(CROSS_COMPILE),) From patchwork Wed May 16 14:14:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 914659 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40mGrn5M1bz9s3B for ; Thu, 17 May 2018 00:23:53 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CzErw6HO"; 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 40mGrm6gcDzDsQ6 for ; Thu, 17 May 2018 00:23:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CzErw6HO"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::243; helo=mail-pl0-x243.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CzErw6HO"; dkim-atps=neutral Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) (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 40mGft6CYNzF14v for ; Thu, 17 May 2018 00:15:18 +1000 (AEST) Received: by mail-pl0-x243.google.com with SMTP id t12-v6so506546plo.7 for ; Wed, 16 May 2018 07:15:18 -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=YSwvxCxV9zP5V8oBGnYbbEnrr2b/Qjc4ApvIbDwdDSs=; b=CzErw6HOycwEsFUNKbLJ1BMaG6gYHpJSI/S0ypNGp1f6UdgWUAjPM+x3i2tFrSx1PI Xz4hId3FnoaPLaE1VSdRowJHK4qQWNT3FuRgzcv1h9klG5ZXMvafoMntMHLLEazN3Uc8 95JNDF/nk777IyXfiOi8OrKuebovliPsrX60AZ8Ee+byIP+dBRChSSxffjpY/4J28ZJi H6TEQbhNuP1WriK+JuDVpGC0qO+x+nag/ixAIzgbJbAkd/wxRQ4yNcMtYBIJlFR3LxvI N/2FbKthrEGrQ1IA3DpJXBOAtx0r+29jEpx8jqchUMEPrNAcoH0fIlB1iBYpQBzLFmBC aGRg== 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=YSwvxCxV9zP5V8oBGnYbbEnrr2b/Qjc4ApvIbDwdDSs=; b=lmpysjbl8aLgjrno3JIgUc0CeDmBDe6QnfJv/10rEyOhS6fbgSjAZjQkqTuzx8Oefr lRw7f/9gELqbKG8aVP/zB4CJc22/PTAEF89+teirG1kW7Vc8DBgWsFEehz4efRaeDVs4 QuKo8rd0ZHW56fpvEXtzbwtqekhsfGAvFrQ4p13bCaeNd8DPY03oDgQkKzM9VVt6A96u aDCrOFQMHVdzWYU82+XD4BhJDoF7Ah0f+ArseauCAvAHaCIDAbYFGOWWGmWsa/3qhLSJ JRotEZ9k9UEY885OTe6YtKO7jBuzLKnZm60MVahsTTP3ndNdiX2sEXPVkHJucs3s1AGk Ji7g== X-Gm-Message-State: ALKqPwefwFUWguZCHC6+Iz5oJZhk9/ZiCajv9eQrkaUdxegc8wyUtuQD yntO5YDSgQLx3Y7i7Y2vELM= X-Google-Smtp-Source: AB8JxZpr3tTi2pbcHYj1jfr7/9Rfg4T2/L0iWBxmkio/OHHDpEHscvIxgK/2cvIV0zhurGPzLWdrLA== X-Received: by 2002:a17:902:268:: with SMTP id 95-v6mr1157225plc.386.1526480116961; Wed, 16 May 2018 07:15:16 -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 h130-v6sm7365162pfc.98.2018.05.16.07.15.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 07:15:16 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Subject: [PATCH v4 2/4] powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile Date: Thu, 17 May 2018 00:14:56 +1000 Message-Id: <20180516141458.18996-3-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516141458.18996-1-npiggin@gmail.com> References: <20180516141458.18996-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linuxppc-dev@lists.ozlabs.org, Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Switch VDSO32 build over to use CROSS32_COMPILE directly, and have it pass in -m32 after the standard c_flags. This allows endianness overrides to be removed and the endian and bitness flags moved into standard flags variables. Signed-off-by: Nicholas Piggin --- arch/powerpc/Makefile | 10 ---------- arch/powerpc/boot/Makefile | 16 +++++++++++----- arch/powerpc/kernel/vdso32/Makefile | 15 +++++++++++---- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 15ca4bafad82..167b26a0780c 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -17,14 +17,8 @@ HAS_BIARCH := $(call cc-option-yn, -m32) # Set default 32 bits cross compilers for vdso and boot wrapper CROSS32_COMPILE ?= -CROSS32CC := $(CROSS32_COMPILE)gcc -CROSS32AR := $(CROSS32_COMPILE)ar - ifeq ($(HAS_BIARCH),y) ifeq ($(CROSS32_COMPILE),) -CROSS32CC := $(CC) -m32 -KBUILD_ARFLAGS += --target=elf32-powerpc - ifdef CONFIG_PPC32 # These options will be overridden by any -mcpu option that the CPU # or platform code sets later on the command line, but they are needed @@ -33,13 +27,9 @@ ifdef CONFIG_PPC32 KBUILD_CFLAGS += -mcpu=powerpc KBUILD_AFLAGS += -mcpu=powerpc endif - endif endif - -export CROSS32CC CROSS32AR - ifeq ($(CROSS_COMPILE),) KBUILD_DEFCONFIG := $(shell uname -m)_defconfig else diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index 26d5d2a5b8e9..49767e06202c 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -23,19 +23,23 @@ all: $(obj)/zImage compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ +ifdef CROSS32_COMPILE + BOOTCC := $(CROSS32_COMPILE)gcc + BOOTAR := $(CROSS32_COMPILE)ar +else + BOOTCC := $(CC) + BOOTAR := $(AR) +endif + BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -Os -msoft-float -pipe \ -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ -D$(compress-y) -BOOTCC := $(CC) ifdef CONFIG_PPC64_BOOT_WRAPPER BOOTCFLAGS += -m64 else BOOTCFLAGS += -m32 -ifdef CROSS32_COMPILE - BOOTCC := $(CROSS32_COMPILE)gcc -endif endif BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include) @@ -49,6 +53,8 @@ endif BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc +BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) + ifdef CONFIG_DEBUG_INFO BOOTCFLAGS += -g endif @@ -202,7 +208,7 @@ quiet_cmd_bootas = BOOTAS $@ cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< quiet_cmd_bootar = BOOTAR $@ - cmd_bootar = $(CROSS32AR) -cr$(KBUILD_ARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ + cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ $(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE $(call if_changed_dep,bootcc) diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile index b8c434d1d459..50112d4473bb 100644 --- a/arch/powerpc/kernel/vdso32/Makefile +++ b/arch/powerpc/kernel/vdso32/Makefile @@ -8,8 +8,15 @@ obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o \ # Build rules -ifeq ($(CONFIG_PPC32),y) -CROSS32CC := $(CC) +ifdef CROSS32_COMPILE + VDSOCC := $(CROSS32_COMPILE)gcc +else + VDSOCC := $(CC) +endif + +CC32FLAGS := +ifdef CONFIG_PPC64 +CC32FLAGS += -m32 endif targets := $(obj-vdso32) vdso32.so vdso32.so.dbg @@ -45,9 +52,9 @@ $(obj-vdso32): %.o: %.S FORCE # actual build commands quiet_cmd_vdso32ld = VDSO32L $@ - cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) + cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) quiet_cmd_vdso32as = VDSO32A $@ - cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $< + cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< # install commands for the unstripped file quiet_cmd_vdso_install = INSTALL $@ From patchwork Wed May 16 14:14:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 914669 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40mH0c1xK2z9s2L for ; Thu, 17 May 2018 00:30:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ytl0rZOi"; 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 40mH0b6NlGzF13r for ; Thu, 17 May 2018 00:30:39 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ytl0rZOi"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::241; helo=mail-pg0-x241.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ytl0rZOi"; dkim-atps=neutral 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 40mGfz0fBtzF1KG for ; Thu, 17 May 2018 00:15:22 +1000 (AEST) Received: by mail-pg0-x241.google.com with SMTP id v7-v6so375357pgs.0 for ; Wed, 16 May 2018 07:15:22 -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=F/tqM1BZOACDSv8gFkl2RxYhPBI36mVx+/i4FmXK1CQ=; b=Ytl0rZOi6bP8iKRZBFpKmMZcdBsn12mi9l1sqSdv3XPqKd5YhLH7z7hXWZchbM8dMa e5sNMBHtqe22f6fXqf+K2AmqDNLLpqMVmXYYhkhGYIJV9RwzAuAlOvaa6bJit6o363vb +IMg060uaIhYEhS+J7wr8Av3w0q6IqedQpE597qxhXqK4Cjr3tl+EPec2hKdAMO+BbyE tw6pAAcXy3bzglz8djvX9ZYGg/zRtvj6mgT/rpKCX1pWn/7zaAOXlGoSyUyKFSldS2iX GAT8q2D6CzAFNFWDcHZLLdxLE+Ax3NhAkpsVD3Cek17n0aCWqj/8NmyHjX321WsKmyMs hBpw== 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=F/tqM1BZOACDSv8gFkl2RxYhPBI36mVx+/i4FmXK1CQ=; b=czqWzlzCiDQNXQxsW/aNvP1Z4O0TF1GLi0pkWDHVcumdEIPyKkBZOJY2vZlHT+mr8L 51xopiFEV1J9bOID9frHYLip2DYW1CPKIBR3FDwZrYXoAsFpxyJun5qU6AxEZ+EJWa1l 3zmGN8YEVaBml31An0gDaocLQhDq9yxJmpWtYLhc1JXOFc4hTpMooweQMIgRCT8wez+D KFl9IKzmPpdiL3GKdOPjkL/9POEfrmrX1mflVH74KDOiyAvN1WD1HZgicmPPUUbHSbGS eJktsos0NmpA0hEf/hn1G1EEi5aWXP5PLb3dlBq7WEzpEAfBFGRQwXf/rBdd9V/M4cEP KGNw== X-Gm-Message-State: ALKqPwdBDsQYfudby2Y0oZN8WSZWvEt4N2qT8cMGQipAXaTtfpvYSsSq cvVNk/AIqvMTbi0it3zHTq8= X-Google-Smtp-Source: AB8JxZrnTTCjy2MCjlhqT2BwmyqNLXLk0GOIzOq1dkQthQuo844WBJkTk1VNFL6IaUj+SMiHGKshEg== X-Received: by 2002:a62:578e:: with SMTP id i14-v6mr1158260pfj.119.1526480120847; Wed, 16 May 2018 07:15:20 -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 h130-v6sm7365162pfc.98.2018.05.16.07.15.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 07:15:19 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Subject: [PATCH v4 3/4] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS Date: Thu, 17 May 2018 00:14:57 +1000 Message-Id: <20180516141458.18996-4-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516141458.18996-1-npiggin@gmail.com> References: <20180516141458.18996-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linuxppc-dev@lists.ozlabs.org, Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 these flags works for this purpose. Unfortunately that is not compatible with the way the proposed new Kconfig macro language implementation, which gets confused by the the $(CC) environment variable changing. After previous patches in this series, these flags can be carefully passed in using the usual kbuild flags variables instead. Acked-by: Steven Rostedt (VMware) Signed-off-by: Nicholas Piggin --- Since v3: - Added 32/64 flags to recordmcount.pl invocation of the toolchain, similarly to BE/LE. This fixes problems with toolchain default target bitness != kernel target bitness. I kept Steven's ack because it's much the same powerpc specific change, okay? - Added a similar fix for mismatched toolchain default endianness or bitness to the gcc-check-mprofile-kernel.sh script. This was pulled in from patch 4 and improved (added comment and endianness flags). arch/powerpc/Makefile | 16 +++++++++------- .../powerpc/tools/gcc-check-mprofile-kernel.sh | 12 ++++++++---- scripts/recordmcount.pl | 18 +++++++++++++++++- 3 files changed, 34 insertions(+), 12 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/arch/powerpc/tools/gcc-check-mprofile-kernel.sh b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh index 061f8035bdbe..a7dd0e5d9f98 100755 --- a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh +++ b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh @@ -7,17 +7,21 @@ set -o pipefail # To debug, uncomment the following line # set -x +# -mprofile-kernel is only supported on 64le, so this should not be invoked +# for other targets. Therefore we can pass in -m64 and -mlittle-endian +# explicitly, to take care of toolchains defaulting to other targets. + # Test whether the compile option -mprofile-kernel exists and generates # profiling code (ie. a call to _mcount()). echo "int func() { return 0; }" | \ - $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ - grep -q "_mcount" + $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \ + 2> /dev/null | grep -q "_mcount" # Test whether the notrace attribute correctly suppresses calls to _mcount(). echo -e "#include \nnotrace int func() { return 0; }" | \ - $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ - grep -q "_mcount" && \ + $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \ + 2> /dev/null | grep -q "_mcount" && \ exit 1 echo "OK" diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 191eb949d52c..fe06e77c15eb 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -266,13 +266,29 @@ if ($arch eq "x86_64") { $objcopy .= " -O elf32-sh-linux"; } elsif ($arch eq "powerpc") { + my $ldemulation; + $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; # See comment in the sparc64 section for why we use '\w'. $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:"; $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; + if ($endian eq "big") { + $cc .= " -mbig-endian "; + $ld .= " -EB "; + $ldemulation = "ppc" + } else { + $cc .= " -mlittle-endian "; + $ld .= " -EL "; + $ldemulation = "lppc" + } if ($bits == 64) { - $type = ".quad"; + $type = ".quad"; + $cc .= " -m64 "; + $ld .= " -m elf64".$ldemulation." "; + } else { + $cc .= " -m32 "; + $ld .= " -m elf32".$ldemulation." "; } } elsif ($arch eq "arm") { From patchwork Wed May 16 14:14:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 914672 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40mH3k47Z7z9s1d for ; Thu, 17 May 2018 00:33:22 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HkUz7uR9"; 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 40mH3k0sl5zF13T for ; Thu, 17 May 2018 00:33:22 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HkUz7uR9"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::241; helo=mail-pf0-x241.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HkUz7uR9"; dkim-atps=neutral Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::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 40mGg257hrzF157 for ; Thu, 17 May 2018 00:15:26 +1000 (AEST) Received: by mail-pf0-x241.google.com with SMTP id f189-v6so425674pfa.7 for ; Wed, 16 May 2018 07:15:26 -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=g/pYbuViNnp0SE7Hjw64GcuUQ5rV99c8aseSn7D5pDE=; b=HkUz7uR9EnjWrygmwvTpVjeLDvpnjQSjRA/llwj1Vr1Lu79bpUKSMVyOr9Rq4MABJf rvqEHOtveHm/9h1wwsqYwugBT+HGGzdrIe712tYqUTojjPBy4aMNPCJwLw2Uqb7bUZG5 nxHhsqDgPchQO1GzhjvzD4gc9oSjUJWmWRNwxWsiCEPppkSlB6aJoefXV/YQY3curon/ KJmG2YMXhYabLAcaoEpGDhMQ+5t2JhEZv17Ogi+Fa6HGW/ceQYaJshoz+y2zuwNRX0BK /rXdOJm3JW/C/UkANiucBSp9/p4wCik8n7h3z3XaQp3csqT3AlXKzpz36FB88gfMjvdC 2Z8w== 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=g/pYbuViNnp0SE7Hjw64GcuUQ5rV99c8aseSn7D5pDE=; b=THKGyj7JwgCsuXMIhrmEtcdfQ9zOGcDyZZjUmH7UdYbvGL1dwpstiWb/4fQ9e7zjLY 2qJG+l2ReKr3FtRr4Ffsk0UG1uy/tFf2nLuXuNSsNlQam/k76bA3coKh60q9gOP0fC1g Ts7IxuKFdVLlYMXo/vVCA/0MYXzZtWlhLkLRoEBnZCDXxwiBVZpx3mIU6fUw7muSulUT O44izAeCyMeZx6xYQdV1gjOcgEJqyV5UCW9Ii/K0oQulTJL/o4EdiWJLkDKUvKe9AX72 VUV+8XNsPiQfkgJYe6WSMvg+EglLwisEsv1V+m0F8ZYSUByhw2iDNZwBAms+n5vWJub1 k4Aw== X-Gm-Message-State: ALKqPwfU/FQ+feddqbdwDgSlYD4ELA8aLjT9bGZoYs33K3YRfah5CdCZ n+EceSc31X3k/ORaEbIpK2M= X-Google-Smtp-Source: AB8JxZo4Gq5BY5UpMqRLeF0XaFMHOT/tgM+H3n9GkSqdMi7KZI4unifAmOhOChBYS9QrwZx+luxC5g== X-Received: by 2002:a63:9a49:: with SMTP id e9-v6mr901463pgo.251.1526480124505; Wed, 16 May 2018 07:15:24 -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 h130-v6sm7365162pfc.98.2018.05.16.07.15.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 07:15:23 -0700 (PDT) From: Nicholas Piggin To: linux-kbuild@vger.kernel.org Subject: [PATCH v4 4/4] powerpc/kbuild: move -mprofile-kernel check to Kconfig Date: Thu, 17 May 2018 00:14:58 +1000 Message-Id: <20180516141458.18996-5-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516141458.18996-1-npiggin@gmail.com> References: <20180516141458.18996-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , linuxppc-dev@lists.ozlabs.org, Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This eliminates the workaround that requires disabling -mprofile-kernel by default in Kconfig. [ Note: this depends on https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kconfig-shell-v3 ] Signed-off-by: Nicholas Piggin Signed-off-by: Nicholas Piggin --- Since v3: - Moved a stray hunk back to patch 3 where it belongs. arch/powerpc/Kconfig | 16 +--------------- arch/powerpc/Makefile | 14 ++------------ 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 512fcc177c87..af527f894f9b 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -460,23 +460,9 @@ config LD_HEAD_STUB_CATCH If unsure, say "N". -config DISABLE_MPROFILE_KERNEL - bool "Disable use of mprofile-kernel for kernel tracing" - depends on PPC64 && CPU_LITTLE_ENDIAN - default y - help - Selecting this options disables use of the mprofile-kernel ABI for - kernel tracing. That will cause options such as live patching - (CONFIG_LIVEPATCH) which depend on CONFIG_DYNAMIC_FTRACE_WITH_REGS to - be disabled also. - - If you have a toolchain which supports mprofile-kernel, then you can - disable this. Otherwise leave it enabled. If you're not sure, say - "Y". - config MPROFILE_KERNEL depends on PPC64 && CPU_LITTLE_ENDIAN - def_bool !DISABLE_MPROFILE_KERNEL + def_bool $(success $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__) config IOMMU_HELPER def_bool PPC64 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 6faf1d6ad9dd..8f7a64fe7370 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -161,18 +161,8 @@ CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64 endif ifdef CONFIG_MPROFILE_KERNEL - ifeq ($(shell $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__),OK) - CC_FLAGS_FTRACE := -pg -mprofile-kernel - KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL - else - # If the user asked for mprofile-kernel but the toolchain doesn't - # support it, emit a warning and deliberately break the build later - # with mprofile-kernel-not-supported. We would prefer to make this an - # error right here, but then the user would never be able to run - # oldconfig to change their configuration. - $(warning Compiler does not support mprofile-kernel, set CONFIG_DISABLE_MPROFILE_KERNEL) - CC_FLAGS_FTRACE := -mprofile-kernel-not-supported - endif + CC_FLAGS_FTRACE := -pg -mprofile-kernel + KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL endif CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)