Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4593212pja; Thu, 21 Nov 2019 22:29:16 -0800 (PST) X-Google-Smtp-Source: APXvYqztt0RQmcF0JF7oa/iCXIrJtNJ5n5bUqRHpsgCzID+PTo32QgnXDP3h275u5ombv0PiRl/d X-Received: by 2002:a17:906:4a0c:: with SMTP id w12mr20025694eju.306.1574404156823; Thu, 21 Nov 2019 22:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574404156; cv=none; d=google.com; s=arc-20160816; b=Fx/H3g8dnbkZv6AjuwgFvnDdI0XCNCrSqhlPkzoeIvD9jqsiKJr7QpO/7wMZ4PPIKx 4CUjjBlioseG9lPXP5G2ZNat/ceiXFentBN7HtuDD1prG1VMVKIvIObHmPp0ouYWsAgZ I/Hq4wgNpL0IMMXrhAP4PPS8InvE1Uj/GlGRjJjqPtvdOMmm1KMZtoO5GOD48frzDSXT gZGw1rA5SpNpagt4kcoE56TXuAvwwccW2ZTXOqFEbsUdrA9nt+wZklyFh82eB7fGdISx sFsBpFBKFFO6X6tGI7FRFu0pFjv1RXb3MzlklIILwJq4yfSdY8FerryC0FPmspxOgypq QB/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hv99ZPkbPHYXDMKF1iJv2I4lWRpnTTyd+Ih/liTrp4E=; b=Kv2vkZcThmx4/b6LkGtuTYRIdVqUMjvvCS3hx73AgT4mKYEj/oXlkvgufHrWSqfRIM mLGoy6pAkiKDq+udl5IPxonk3qwgjl4/JZNokV58LSKqXWIH2SV2ylQPMCLwAFBHZC6I O2LXmkKs6mWjCJTeGDODZkQRKd9ldcmP0ERx7rWJZHcn0UhdR4Yx1vSxkZXT8cw5sxte BvlE3kNkAkqUDpJxKxdh/+UKmn/Pqv6ALwpG1CXg0Wb+PQl4zeiXUdkm2BbVxVJmD6FD m5Ll81cT8BwtyHqnXGFYPvQlDz+lVmEZc2R61TiXlsv1cNrxCXl8Cft++rK2yChxSAvv TEjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AoW2zRTy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jo17si1827925ejb.312.2019.11.21.22.28.46; Thu, 21 Nov 2019 22:29:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AoW2zRTy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728599AbfKVGYb (ORCPT + 99 others); Fri, 22 Nov 2019 01:24:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:56502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728126AbfKVFv0 (ORCPT ); Fri, 22 Nov 2019 00:51:26 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B546B2070E; Fri, 22 Nov 2019 05:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401885; bh=0BKgJK0ru3iRADVaPyo5g95TkJZb3iLxgNnyE9BBUxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AoW2zRTySCjlKux1l/KduFivVCCph+/7xCyk79eWIPcvBjX0uIgqZJDPnHVLOiTpi V6wWoThpderv6ki1R/7a1iIBh65ssmAdxnrH4b2z3d76Yc4KL9uR5OlY3TFMzahvGX E2bB4JKO/7Xgakr9JX88zyP4gD3/559C20Jwv3Zo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Joel Stanley , Nick Desaulniers , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 4.19 119/219] powerpc/32: Avoid unsupported flags with clang Date: Fri, 22 Nov 2019 00:47:31 -0500 Message-Id: <20191122054911.1750-112-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joel Stanley [ Upstream commit 72e7bcc2cdf82bf03caaa5e6c9b0134c2fc2ee7d ] When building for ppc32 with clang these flags are unsupported: -ffixed-r2 and -mmultiple llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on when building for SVR4ABI and !ppc64: // The SVR4 ABI reserves r2 and r13 if (Subtarget.isSVR4ABI()) { // We only reserve r2 if we need to use the TOC pointer. If we have no // explicit uses of the TOC pointer (meaning we're a leaf function with // no constant-pool loads, etc.) and we have no potential uses inside an // inline asm block, then we can treat r2 has an ordinary callee-saved // register. const PPCFunctionInfo *FuncInfo = MF.getInfo(); if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm()) markSuperRegs(Reserved, PPC::R2); // System-reserved register markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register } This means we can safely omit -ffixed-r2 when building for 32-bit targets. The -mmultiple/-mno-multiple flags are not supported by clang, so platforms that might support multiple miss out on using multiple word instructions. We wrap these flags in cc-option so that when Clang gains support the kernel will be able use these flags. Clang 8 can then build a ppc44x_defconfig which boots in Qemu: make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- ppc44x_defconfig ./scripts/config -e CONFIG_DEVTMPFS -d DEVTMPFS_MOUNT make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- qemu-system-ppc -M bamboo \ -kernel arch/powerpc/boot/zImage \ -dtb arch/powerpc/boot/dts/bamboo.dtb \ -initrd ~/ppc32-440-rootfs.cpio \ -nographic -serial stdio -monitor pty -append "console=ttyS0" Link: https://github.com/ClangBuiltLinux/linux/issues/261 Link: https://bugs.llvm.org/show_bug.cgi?id=39556 Link: https://bugs.llvm.org/show_bug.cgi?id=39555 Signed-off-by: Joel Stanley Reviewed-by: Nick Desaulniers Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index c4c03992ee828..dfcb698ec8f3b 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -145,7 +145,14 @@ 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) -CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD) +# Clang unconditionally reserves r2 on ppc32 and does not support the flag +# https://bugs.llvm.org/show_bug.cgi?id=39555 +CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2) + +# Clang doesn't support -mmultiple / -mno-multiple +# https://bugs.llvm.org/show_bug.cgi?id=39556 +CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD)) + CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) ifdef CONFIG_PPC_BOOK3S_64 -- 2.20.1