Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3196453imu; Mon, 17 Dec 2018 15:17:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ve+YYQmLFPleRX/JpXXEw8mcQ3UnEwM5RTlOO6JX4SO8w4WP5fAakkg4xZU+yL3FyE/TUj X-Received: by 2002:a17:902:bc3:: with SMTP id 61mr14437675plr.15.1545088624032; Mon, 17 Dec 2018 15:17:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545088623; cv=none; d=google.com; s=arc-20160816; b=BW+o8LEuIWviLxTVusQtocTWGRqAXoPkWkEYchtxwF9b1Wcpae2mBUz1HN8ov4BFSQ qPUDT95OlLuc68AJNGXIn6a5nLFQ98YdDv25uhmMehArFlErrOFpCx2eC8Qvg6hftaJ1 +l0eVmY1uOqtFWKYwyLDAxtO1aFnJR4nKClWSRq7KbAAwxMqM+scvybxSBFoggo0mQwl dGA2lLUKTOrvHUmsQKaYkYzMWvTGOdSCuj8YfD3AbIb49mSvWUDnzWB8Dr5HV7R/JKtJ Bioxhu7K6QiXCVn6+O8l367BmHcmSKUiM9vjyk+wZvsal8mgNeHk1TbIYQJhgDcHT02s ueMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sTAKS+Vyc7ODkqW5h+mrhKCUCTFsO23j0Ib/dkzKqV0=; b=Sc31b77Sm4lOlthkD79EmqAtUYM0FsKsEKV1qqXkuCnObGjKsH1JSUczBXGZ/ZfFjx XgLhm5ZX8oluhGpXyXvzGkD4DNTq+RPIDhuQNqG3Ww/d57JgsaJ0cj4mY+mYgwC48s9J 0EhdQd+Zl5Ybo6u1AHAplhpxfdouF+iSw4jQsFGeHYD/rNHOBlPdva77PgJrPNrl1e35 sTEU/kiDGQycZsNz6z5l+tjRyiZuLJNlvlzhGecac09L9kCVVBXleacGiEOrR4FA7cE0 MoG3s9OGuHCYQFX8osBDLgaujHunFxdL5WHhD96e0XScJe9+BvElwnzxh21KgJS1jrgf XZKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f7uyTR8I; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o32si11933466pld.407.2018.12.17.15.16.48; Mon, 17 Dec 2018 15:17:03 -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=@gmail.com header.s=20161025 header.b=f7uyTR8I; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389297AbeLQTfD (ORCPT + 99 others); Mon, 17 Dec 2018 14:35:03 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34876 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727175AbeLQTfD (ORCPT ); Mon, 17 Dec 2018 14:35:03 -0500 Received: by mail-wm1-f68.google.com with SMTP id c126so416125wmh.0; Mon, 17 Dec 2018 11:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sTAKS+Vyc7ODkqW5h+mrhKCUCTFsO23j0Ib/dkzKqV0=; b=f7uyTR8IpNTJQFDNddjUPpaMlMplz3Lj/Ynio1pZvXo++F9VWslCZXEr4r96cOK5dW KBTtyAWfLgDakyQzoyAQYKtMsyVjcyy22Qd+mD0kjmCDqfTNtWY0k+XHxLFOsy+/jI24 a23D3hqw7nXKeSx/1tUmkqk1QFxEuXHqywxhL4yXKyW1Tw4hgSzHl69TF9nItO1BBQ0j sJpHcB8EzKchPyZufOOEtJP8B/Dm/dO2deK6d5jgK78g7seCsPEzVpAUeRBVk7eV1BVV fIQRjlPyIft/wImSpv3sFp1PC9yh1o79FDzSeuKOOVtSO65wkH7WUDWJc9B3o/CSXi/q b6EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sTAKS+Vyc7ODkqW5h+mrhKCUCTFsO23j0Ib/dkzKqV0=; b=lKOa7iFzOf0rgLDeE96MizlAmcuC4mUsngq1/10GCDdJTkcxc07Q9QTnoA1P9+LLq0 NrZXICx/f3DVbXxLnincLNYkDRyYycARSRENi0B+XC4BwVGo5W46HccvD22r1+XHwZNY E3VttJbO5gO8SqLzq/fmXin6U1X/WFFl7Vquf7g5rQDBGuvL1GjcLdDNS6eo5oz/hqpv mIh82+uGgxnrfyD1OkPALPoP8rajOO24HjkXpuVf+zy9Sf4qMxkV30daMyOcERtO+7Wp ++Ft/Lcu6tlHTrftCXedYK2r0AgboygOlX8crQ0bHkFd016pHXJSCi1lvGE23iRYjsQ8 RE6A== X-Gm-Message-State: AA+aEWb+GTVmE46Mx9EaAPfurgxJDBOdC99EDG8M18OFfDsohZwa91Ik reH2LYkA70RBVyogXM1koDI= X-Received: by 2002:a1c:ce0e:: with SMTP id e14mr389555wmg.53.1545075300306; Mon, 17 Dec 2018 11:35:00 -0800 (PST) Received: from flashbox ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id e9sm716361wro.16.2018.12.17.11.34.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Dec 2018 11:34:59 -0800 (PST) Date: Mon, 17 Dec 2018 12:34:58 -0700 From: Nathan Chancellor To: Nicolas Pitre Cc: Russell King , Ard Biesheuvel , Jonathan Corbet , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Tri Vo Subject: Re: [PATCH] ARM: Ensure that NEON code always compiles with Clang Message-ID: <20181217193458.GA6671@flashbox> References: <20181215212304.19390-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 17, 2018 at 01:23:52PM -0500, Nicolas Pitre wrote: > On Sat, 15 Dec 2018, Nathan Chancellor wrote: > > > While building arm32 allyesconfig, I ran into the following errors: > > > > arch/arm/lib/xor-neon.c:17:2: error: You should compile this file with > > '-mfloat-abi=softfp -mfpu=neon' > > > > In file included from lib/raid6/neon1.c:27: > > /home/nathan/cbl/prebuilt/lib/clang/8.0.0/include/arm_neon.h:28:2: > > error: "NEON support not enabled" > > > > Building V=1 showed NEON_FLAGS getting passed along to Clang but > > __ARM_NEON__ was not getting defined. Ultimately, it boils down to Clang > > only defining __ARM_NEON__ when targeting armv7, rather than armv6k, > > which is the '-march' value for allyesconfig. > > > > From lib/Basic/Targets/ARM.cpp in the Clang source: > > > > // This only gets set when Neon instructions are actually available, unlike > > // the VFP define, hence the soft float and arch check. This is subtly > > // different from gcc, we follow the intent which was that it should be set > > // when Neon instructions are actually available. > > if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) { > > Builder.defineMacro("__ARM_NEON", "1"); > > Builder.defineMacro("__ARM_NEON__"); > > // current AArch32 NEON implementations do not support double-precision > > // floating-point even when it is present in VFP. > > Builder.defineMacro("__ARM_NEON_FP", > > "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP)); > > } > > > > Ard Biesheuvel recommended explicitly adding '-march=armv7-a' at the > > beginning of the NEON_FLAGS definitions so that __ARM_NEON__ always gets > > definined by Clang. This doesn't functionally change anything because > > that code will only run where NEON is supported, which is implicitly > > armv7. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/287 > > Suggested-by: Ard Biesheuvel > > Signed-off-by: Nathan Chancellor > > Did you test that this doesn't create issues with gcc e.g. complaints > from the linker that objects have incompatible architecture > specifications or similar annoyance? This already happened in the past > but I forget the exact scenario. If you already did, or after you do > validate with gcc as well, then you may add: > > Acked-by: Nicolas Pitre > > Hi Nicolas, I was 99% sure that I checked GCC before sending this but I just did another run to confirm and everything links successfully. We still use binutils for assembling/linking the kernel so I assume that I would have seen a warning from ld.bfd even with Clang. Thank you for the review! Nathan > > > --- > > Documentation/arm/kernel_mode_neon.txt | 4 ++-- > > arch/arm/lib/Makefile | 2 +- > > arch/arm/lib/xor-neon.c | 2 +- > > lib/raid6/Makefile | 2 +- > > 4 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/Documentation/arm/kernel_mode_neon.txt b/Documentation/arm/kernel_mode_neon.txt > > index 525452726d31..b9e060c5b61e 100644 > > --- a/Documentation/arm/kernel_mode_neon.txt > > +++ b/Documentation/arm/kernel_mode_neon.txt > > @@ -6,7 +6,7 @@ TL;DR summary > > * Use only NEON instructions, or VFP instructions that don't rely on support > > code > > * Isolate your NEON code in a separate compilation unit, and compile it with > > - '-mfpu=neon -mfloat-abi=softfp' > > + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp' > > * Put kernel_neon_begin() and kernel_neon_end() calls around the calls into your > > NEON code > > * Don't sleep in your NEON code, and be aware that it will be executed with > > @@ -87,7 +87,7 @@ instructions appearing in unexpected places if no special care is taken. > > Therefore, the recommended and only supported way of using NEON/VFP in the > > kernel is by adhering to the following rules: > > * isolate the NEON code in a separate compilation unit and compile it with > > - '-mfpu=neon -mfloat-abi=softfp'; > > + '-march=armv7-a -mfpu=neon -mfloat-abi=softfp'; > > * issue the calls to kernel_neon_begin(), kernel_neon_end() as well as the calls > > into the unit containing the NEON code from a compilation unit which is *not* > > built with the GCC flag '-mfpu=neon' set. > > diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile > > index ad25fd1872c7..0bff0176db2c 100644 > > --- a/arch/arm/lib/Makefile > > +++ b/arch/arm/lib/Makefile > > @@ -39,7 +39,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S > > $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S > > > > ifeq ($(CONFIG_KERNEL_MODE_NEON),y) > > - NEON_FLAGS := -mfloat-abi=softfp -mfpu=neon > > + NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon > > CFLAGS_xor-neon.o += $(NEON_FLAGS) > > obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o > > endif > > diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c > > index a6741a895189..4600b62d845f 100644 > > --- a/arch/arm/lib/xor-neon.c > > +++ b/arch/arm/lib/xor-neon.c > > @@ -14,7 +14,7 @@ > > MODULE_LICENSE("GPL"); > > > > #ifndef __ARM_NEON__ > > -#error You should compile this file with '-mfloat-abi=softfp -mfpu=neon' > > +#error You should compile this file with '-march=armv7-a -mfloat-abi=softfp -mfpu=neon' > > #endif > > > > /* > > diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile > > index 2f8b61dfd9b0..bfec7c87c61e 100644 > > --- a/lib/raid6/Makefile > > +++ b/lib/raid6/Makefile > > @@ -25,7 +25,7 @@ endif > > ifeq ($(CONFIG_KERNEL_MODE_NEON),y) > > NEON_FLAGS := -ffreestanding > > ifeq ($(ARCH),arm) > > -NEON_FLAGS += -mfloat-abi=softfp -mfpu=neon > > +NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon > > endif > > CFLAGS_recov_neon_inner.o += $(NEON_FLAGS) > > ifeq ($(ARCH),arm64) > > -- > > 2.20.1 > > > >