Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1705996imu; Sat, 26 Jan 2019 08:51:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN7CISaUNAE1ydqDyt9jRwsGUdSnymjgm8HQjlFUt1UaVpxnLM5EStV4bxFdQFLZffdWqejU X-Received: by 2002:a63:3d49:: with SMTP id k70mr13943316pga.191.1548521467296; Sat, 26 Jan 2019 08:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548521467; cv=none; d=google.com; s=arc-20160816; b=ZvB+/Jfp5nidR6nXVtly+gfkfC0Jl9r/MfrCJ8J7WVtGr/Yr0LA6Po3uORAvnjLXoG u7O2dz4Zxqn6vCrfsm6tRLLjfDfmUEL5vEdgEUOD66+tv22VSiIhpPfCz1R1SZ7BqVJx SSAe2IMsFEtnnsOJ/sIg3N5io79Q1+WZmuGMsXipecGqeSo4tCfEBqvZCCvI+c6T8M0Q avpNWN8p7+F9vp72hzXgfGmSxEMKjOaMNqK6eplAJooXv0efSga26wcFqQXT7v9CxhWJ fqB3yA/r/L22R1rT72N0wd4MQyn3KqyUNXebvSgpNCyWv/nDFHQ0lIzlBVtH+C6gRomz DU1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=zmrneEBPESZO4rZ5YaNDNI0pxmdcbOzgYqXq0Y2bbBQ=; b=YNCEhn7KVV03237OYrNHwqdBF1qT7TENyJZ7Bo6ljcoSsrsTyO6sOgQsUC1JKDHwMD x3NTLfUiT0pApKXVBwTieNC3+Cuw2WQuPqblHpQE4hkrrf1TzS2teeUH0HqiQlFBt4tf vceAAwETkLNcYk0DvHNltLXTs6PAgrNuwa2jrM3hsyK7MbuB23R6g2dP7kfX3gtro+Ls HgzGGcQ1qDUA4Qd5kPRkYflZSqgwqjRlWG5t8sxxIu3A0JDdEHzIDaww36c3CMlf5P14 3JpQlhkWUUy8d2lS/vgvjvZiSE/gwC025iNtpV0TJULgV4HSV445VocCZHfbqhihSkjN lE+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=eaqcRrV1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d15si9037450pgt.498.2019.01.26.08.50.52; Sat, 26 Jan 2019 08:51:07 -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=@agner.ch header.s=dkim header.b=eaqcRrV1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726165AbfAZQsh (ORCPT + 99 others); Sat, 26 Jan 2019 11:48:37 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:52262 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbfAZQsh (ORCPT ); Sat, 26 Jan 2019 11:48:37 -0500 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 5C3ED5C00D5; Sat, 26 Jan 2019 17:48:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1548521313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zmrneEBPESZO4rZ5YaNDNI0pxmdcbOzgYqXq0Y2bbBQ=; b=eaqcRrV1MQrUTIEgZuuch0+kNMaNqiI4CuhxKMKO3iMcoleILAHFNsxr6aIOqFz4xogg6u 6eByMgx1djO69qnxID8p8zgVQiWGOdGQEYJ8aaflfOcrJ5/iqyd6XlUOnEnw+O4IDqZ/bm gqZzaUfWYW6MHs2pQBZOtfPmSglyr00= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Sat, 26 Jan 2019 17:48:33 +0100 From: Stefan Agner To: Nathan Chancellor Cc: Russell King , Ard Biesheuvel , Jonathan Corbet , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tri Vo , Nicolas Pitre , Nick Desaulniers , Nicolas Pitre Subject: Re: [PATCH RESEND] ARM: Ensure that NEON code always compiles with Clang In-Reply-To: <20190126040111.9013-1-natechancellor@gmail.com> References: <20181215212304.19390-1-natechancellor@gmail.com> <20190126040111.9013-1-natechancellor@gmail.com> Message-ID: <20e649cde3fadfa63d7ae9fefbda4915@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26.01.2019 05:01, 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 > Acked-by: Nicolas Pitre > Reviewed-by: Nick Desaulniers > --- > > Resending with Nicolas's ack and Nick's review, to give others a chance > to pitch in with review/testing before submitting it to the patch > system (specifically Stefan, sorry I should have included you in the > previous posting). No worries. Looks good to me. Reviewed-by: Stefan Agner -- Stefan > > With this patch and: > * A tip of tree LLVM build (I used apt.llvm.org) > * Clang GCOV support: > https://lore.kernel.org/lkml/20190122233749.42220-1-trong@android.com/ > * Two minor hacks for unrelated issues that are still being worked through: > * > https://raw.githubusercontent.com/nathanchance/patches/c313b2fa0efb/linux/build-hax/0003-DO-NOT-UPSTREAM-ARM-Don-t-select-HAVE_FUNCTION_TRACE.patch > (see https://github.com/ClangBuiltLinux/linux/issues/35) > * > https://gist.githubusercontent.com/nathanchance/b2f5a4015abade1a41e78d5fc3235c5b/raw/744321882ab05511331f26896bad7c9f0056a6a5/gistfile1.txt > (see https://github.com/ClangBuiltLinux/linux/issues/325) > > I can build and link a little endian allyesconfig ARM kernel. This > patch alone works with GCC 8.2.0 and binutils 2.31.1. > > 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 2c40aeab3eaa..c691b901092f 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 4e90d443d1b0..e723eacf7868 100644 > --- a/lib/raid6/Makefile > +++ b/lib/raid6/Makefile > @@ -39,7 +39,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)