Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1211126rwi; Fri, 14 Oct 2022 14:52:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6w6IiWIz1jOQt6n5b1aKfuZF/lFifxDp0vTw4JzCkpwlpU4ayg4LCLG4hiZgGH18IuCINz X-Received: by 2002:a17:907:3f92:b0:78e:2eb5:6aec with SMTP id hr18-20020a1709073f9200b0078e2eb56aecmr15143ejc.85.1665784325834; Fri, 14 Oct 2022 14:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665784325; cv=none; d=google.com; s=arc-20160816; b=CLB+6NssTgZX/BE9uZaTK1y4TsBt06V1R5GXNDhsF4MPtu2q5Mo35ps6NA0be9Xsib BObcA04nnAunpg2DMasrRikQu2yRqv5L0KrOZVuSf0P7btDKUFN/xJh1VOhm21GGy6QD jJVOlo9eEzU6E3D5vQTd5TQsfxVKRGR+NSN0sxQkhPu1y92WeS2aCxYe4p+B+nr0rNmI XwBjn3yvPHlov3isOPM+9GnDFjq6ewDT/8ARsw2w4RQHLzftkDc5Zq1Q1cj1oCniks01 2bqjW/0BcZxOOOKzUsF/vxq7iZRhJLzqVwRG+wTrXmptF84xeJCjgWdnbO8OfwtsI5b3 WR4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nAjmPgnu8ctKXph8Grz3r0/X7LhCq1ea8ZPMjiQeNlE=; b=yERIE5B3PTBKNbONmPc4U8icjhmRMZok/gZsw2+ryn7sLFAhfFEiGiTxC8g8K0zmSu mQumYNkqdYq/I4aceCw2cNSuHgrm20H9xmd/SwPXJaaX4Ilqn47tDZFFvIAFwV6rvJRx 1z/urU+8OZ/8tnNIqybnrAi+C/vARH1VnsnHhelDSHT5B1Gsfb97L/Bx6Gs8XdGVI9K4 qRXVXNfejTmEMxjpPBWFqdQIuGtZoqFyfOGmLtIIWp+1vS28zXmDH/Qf+hRaMqJy7asu KfYkX+5sAG/FWOsQfCBJmEXWvlNHG3V5hnSXXDXbUgmmoNniKDx2nqxN/X+EdMtYIO4I 03hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fim6nGXa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk38-20020a1709077fa600b0078d9be7f100si3473055ejc.852.2022.10.14.14.51.40; Fri, 14 Oct 2022 14:52:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fim6nGXa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229826AbiJNVVN (ORCPT + 99 others); Fri, 14 Oct 2022 17:21:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229819AbiJNVVK (ORCPT ); Fri, 14 Oct 2022 17:21:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1EDE24943 for ; Fri, 14 Oct 2022 14:21:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2722CB82276 for ; Fri, 14 Oct 2022 21:21:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D8D3C433C1; Fri, 14 Oct 2022 21:21:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665782464; bh=W830SBSAHyVTFgK+oBOpumaz6zT/ESPPX+briRUidUU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fim6nGXadK0daKWDcTjB7DuqqVbheHWqI2TI75c7Me6Bb8S3vzMN3U0upV68UhufP 1i7dZ5O2wpChIqZQ8dIRaqGak5vjcw//6u3ymWrLr5ASvqHi1OP9fhCGw1IXIRiGuB Jj/Pbgff2MKLGb9XsIkR+e/T/z8JaWIgnDbnE44NcbbyJNjMnKikDazX9GyZyienZm OcwMSL3Jfb0MAwa7tLS6E0Cd2uPt6gSOPs3C/FQxDuGaHrsRmiwL3hsQPeTr36nSph B5VbR3/aRiTs+aFh+VkfhAA4ZxcQpaZk66qpJro2r0Z9yEm5bSAZ/8Jq5tbBrgKWnG 98SFTw/7J2ndg== Date: Fri, 14 Oct 2022 14:21:02 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Russell King , Arnd Bergmann , Ard Biesheuvel , Masahiro Yamada , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH v4 4/4] ARM: pass -march= only to compiler Message-ID: References: <20221014201354.3190007-1-ndesaulniers@google.com> <20221014201354.3190007-5-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221014201354.3190007-5-ndesaulniers@google.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 14, 2022 at 01:13:54PM -0700, Nick Desaulniers wrote: > When both -march= and -Wa,-march= are specified for assembler or > assembler-with-cpp sources, GCC and Clang will prefer the -Wa,-march= > value but Clang will warn that -march= is unused. > > warning: argument unused during compilation: '-march=armv6k' > [-Wunused-command-line-argument] > > This is the top group of warnings we observe when using clang to > assemble the kernel via `ARCH=arm make LLVM=1`. > > Split the arch-y make variable into two, so that -march= flags only get > passed to the compiler, not the assembler. -D flags are added to > KBUILD_CPPFLAGS which is used for both C and assembler-with-cpp sources. > > Clang is trying to warn that it doesn't support different values for > -march= and -Wa,-march= (like GCC does, but the kernel doesn't need this) > though the value of the preprocessor define __thumb2__ is based on > -march=. Make sure to re-set __thumb2__ via -D flag for assembler > sources now that we're no longer passing -march= to the assembler. Set > it to a different value than the preprocessor would for -march= in case > -march= gets accidentally re-added to KBUILD_AFLAGS in the future. > Thanks to Ard and Nathan for this suggestion. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1315 > Link: https://github.com/ClangBuiltLinux/linux/issues/1587 > Link: https://github.com/llvm/llvm-project/issues/55656 > Suggested-by: Ard Biesheuvel > Suggested-by: Nathan Chancellor > Signed-off-by: Nick Desaulniers This passed through my build matrix on top of commit dca45efbe3c8 ("Merge tag 'sound-fix-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound") and I saw no additional warnings/errors: Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor > --- > Changes v3 -> v4: > * Add -D__thumb2__=2 to KBUILD_AFLAGS as per in-person discussion with > Ard and Nathan, and their SB tags. > * Reword commit message. > > arch/arm/Makefile | 36 +++++++++++++++++++++++++----------- > 1 file changed, 25 insertions(+), 11 deletions(-) > > diff --git a/arch/arm/Makefile b/arch/arm/Makefile > index ee888070b2ff..b58998749ead 100644 > --- a/arch/arm/Makefile > +++ b/arch/arm/Makefile > @@ -60,21 +60,34 @@ endif > KBUILD_CFLAGS += $(call cc-option,-fno-ipa-sra) > > # This selects which instruction set is used. > +arch-$(CONFIG_CPU_32v7M) :=-march=armv7-m > +arch-$(CONFIG_CPU_32v7) :=-march=armv7-a > +arch-$(CONFIG_CPU_32v6) :=-march=armv6 > +# Only override the compiler option if ARMv6. The ARMv6K extensions are > +# always available in ARMv7 > +ifeq ($(CONFIG_CPU_32v6),y) > +arch-$(CONFIG_CPU_32v6K) :=-march=armv6k > +endif > +arch-$(CONFIG_CPU_32v5) :=-march=armv5te > +arch-$(CONFIG_CPU_32v4T) :=-march=armv4t > +arch-$(CONFIG_CPU_32v4) :=-march=armv4 > +arch-$(CONFIG_CPU_32v3) :=-march=armv3m > + > # Note that GCC does not numerically define an architecture version > # macro, but instead defines a whole series of macros which makes > # testing for a specific architecture or later rather impossible. > -arch-$(CONFIG_CPU_32v7M) :=-D__LINUX_ARM_ARCH__=7 -march=armv7-m > -arch-$(CONFIG_CPU_32v7) :=-D__LINUX_ARM_ARCH__=7 -march=armv7-a > -arch-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 -march=armv6 > -# Only override the compiler opt:ion if ARMv6. The ARMv6K extensions are > +cpp-$(CONFIG_CPU_32v7M) :=-D__LINUX_ARM_ARCH__=7 > +cpp-$(CONFIG_CPU_32v7) :=-D__LINUX_ARM_ARCH__=7 > +cpp-$(CONFIG_CPU_32v6) :=-D__LINUX_ARM_ARCH__=6 > +# Only override the compiler option if ARMv6. The ARMv6K extensions are > # always available in ARMv7 > ifeq ($(CONFIG_CPU_32v6),y) > -arch-$(CONFIG_CPU_32v6K) :=-D__LINUX_ARM_ARCH__=6 -march=armv6k > +cpp-$(CONFIG_CPU_32v6K) :=-D__LINUX_ARM_ARCH__=6 > endif > -arch-$(CONFIG_CPU_32v5) :=-D__LINUX_ARM_ARCH__=5 -march=armv5te > -arch-$(CONFIG_CPU_32v4T) :=-D__LINUX_ARM_ARCH__=4 -march=armv4t > -arch-$(CONFIG_CPU_32v4) :=-D__LINUX_ARM_ARCH__=4 -march=armv4 > -arch-$(CONFIG_CPU_32v3) :=-D__LINUX_ARM_ARCH__=3 -march=armv3m > +cpp-$(CONFIG_CPU_32v5) :=-D__LINUX_ARM_ARCH__=5 > +cpp-$(CONFIG_CPU_32v4T) :=-D__LINUX_ARM_ARCH__=4 > +cpp-$(CONFIG_CPU_32v4) :=-D__LINUX_ARM_ARCH__=4 > +cpp-$(CONFIG_CPU_32v3) :=-D__LINUX_ARM_ARCH__=3 > > # This selects how we optimise for the processor. > tune-$(CONFIG_CPU_ARM7TDMI) :=-mtune=arm7tdmi > @@ -119,15 +132,16 @@ AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) > > ifeq ($(CONFIG_THUMB2_KERNEL),y) > CFLAGS_ISA :=-mthumb -Wa,-mimplicit-it=always $(AFLAGS_NOWARN) > -AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb > +AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb -D__thumb2__=2 > else > CFLAGS_ISA :=$(call cc-option,-marm,) $(AFLAGS_NOWARN) > AFLAGS_ISA :=$(CFLAGS_ISA) > endif > > # Need -Uarm for gcc < 3.x > +KBUILD_CPPFLAGS +=$(cpp-y) > KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm > -KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float > +KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) -Wa,$(arch-y) $(tune-y) -include asm/unified.h -msoft-float > > CHECKFLAGS += -D__arm__ > > -- > 2.38.0.413.g74048e4d9e-goog >