From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4862C4167B for ; Mon, 4 Dec 2023 22:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbjLDWdP (ORCPT ); Mon, 4 Dec 2023 17:33:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjLDWdN (ORCPT ); Mon, 4 Dec 2023 17:33:13 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4AFFA9 for ; Mon, 4 Dec 2023 14:33:19 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5180C433C7; Mon, 4 Dec 2023 22:33:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701729199; bh=WfQFLken07ph4TbDrqs4sN/0bpMdipRIiq7jjcv/vSk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B9DIk1Nk/8NJjq/KZyxdt6AZYF+a6MSTTeH3x79nl/D1W9vijfBDTfmP7H94tTiNP oXn+NHnSRRl+31vMtcQSmZ4EILPBFkjoel3Taq0gXeIpLBTCK4Moa0wFdn3GUpc7/r UHH9hUqAxxQxA5w9h+6IIfGTa6wGs6FJEV3X9tDeBkltGRtdtNpY+YMzIH+2htoQS+ +Raf1k8khKq6vkFLdInzannJfWydc1XUIZn+0AaO8VL2DFSZtfOmRi1sc5XCC5k+rw RxdlSO7r4xsyRTuXfWfY4RvD9cdbA1A78He44wKqkD37D9sY1/5tZx1Z4sRk04eE+A CI248su1mCbRA== Date: Mon, 4 Dec 2023 15:33:17 -0700 From: Nathan Chancellor To: Naresh Kamboju Cc: clang-built-linux , Linux ARM , open list , Linux Regressions , lkft-triage@lists.linaro.org, Russell King - ARM Linux , Arnd Bergmann , Nick Desaulniers , Sylvestre Ledru Subject: Re: clang-nightly: vdso/compat_gettimeofday.h:152:15: error: instruction variant requires ARMv6 or later Message-ID: <20231204223317.GA2053629@dev-arch.thelio-3990X> References: <20231204181304.GA2043538@dev-arch.thelio-3990X> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231204181304.GA2043538@dev-arch.thelio-3990X> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 04, 2023 at 11:13:04AM -0700, Nathan Chancellor wrote: > Hi Naresh, > > On Mon, Dec 04, 2023 at 05:33:26PM +0530, Naresh Kamboju wrote: > > Following build errors noticed on Linux next-20231204 tag with clang-nightly > > for arm and arm64. > > > > ## Test Regressions (compared to next-20231201) > > * arm64, build > > - clang-nightly-defconfig > > - clang-nightly-defconfig-40bc7ee5 > > - clang-nightly-lkftconfig > > - clang-nightly-lkftconfig-kselftest > > > > * arm, build > > - clang-nightly-allnoconfig > > - clang-nightly-axm55xx_defconfig > > - clang-nightly-bcm2835_defconfig > > - clang-nightly-clps711x_defconfig > > - clang-nightly-defconfig > > - clang-nightly-exynos_defconfig > > - clang-nightly-imx_v6_v7_defconfig > > - clang-nightly-keystone_defconfig > > - clang-nightly-lkftconfig > > - clang-nightly-lkftconfig-kselftest > > - clang-nightly-omap2plus_defconfig > > - clang-nightly-pxa910_defconfig > > - clang-nightly-s3c6400_defconfig > > - clang-nightly-s5pv210_defconfig > > - clang-nightly-sama5_defconfig > > - clang-nightly-shmobile_defconfig > > - clang-nightly-tinyconfig > > - clang-nightly-u8500_defconfig > > - clang-nightly-vexpress_defconfig > > > > > > Reported-by: Linux Kernel Functional Testing > > > > > > Build log on arm64: > > --------- > > In file included from lib/vdso/gettimeofday.c:5: > > In file included from include/vdso/datapage.h:135: > > arch/arm64/include/asm/vdso/compat_gettimeofday.h:152:15: error: > > instruction variant requires ARMv6 or later > > 152 | asm volatile("mov %0, %1" : "=r"(ret) : "r"(_vdso_data)); > > | ^ > > :1:2: note: instantiated into assembly here > > 1 | mov r4, r1 > > | ^ > > In file included from :3: > > lib/vdso/gettimeofday.c:139:3: error: invalid instruction > > 139 | smp_rmb(); > > | ^ > > > > Build log on arm: > > --------- > > In file included from arch/arm/vfp/vfpmodule.c:23: > > arch/arm/include/asm/cp15.h:101:2: error: instruction requires: data-barriers > > 101 | isb(); > > | ^ > > This is caused by a change to Debian's LLVM that changes the internal > defaults of the arm-linux-gnueabi and arm-linux-gnueabihf tuples: > > https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/commit/907baf024b9a5a1626893d9e731b6c79ccf45c87 > > We use arm-linux-gnueabi for the kernel (see scripts/Makefile.clang) so > now we have a hardcoded armv5te CPU, even if we are building for armv7 > or such. > > I am still investigating into what (if anything) can be done to resolve > this on the kernel side. We could potentially revert commit > ddc72c9659b5 ("kbuild: clang: do not use CROSS_COMPILE for target > triple") but I am not sure that will save us from that change, as > tuxmake's CROSS_COMPILE=arm-linux-gnueabihf will cause us to have an > armv7 CPU even though we may not be building for armv7. Okay, this is a pretty awful situation the more I look into it :( The arm64 compat vDSO build is easy enough to fix because we require use of the integrated assembler, which means we can add '-mcpu=generic' (the default in LLVM for those files based on my debugging) to those files and be done with it: diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile index 1f911a76c5af..5f5cb722cfc2 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -9,6 +9,10 @@ include $(srctree)/lib/vdso/Makefile ifeq ($(CONFIG_CC_IS_CLANG), y) CC_COMPAT ?= $(CC) CC_COMPAT += --target=arm-linux-gnueabi +# Some distributions (such as Debian) change the default CPU for the +# arm-linux-gnueabi target triple, which can break the build. Explicitly set +# the CPU to generic, which is the default for Linux in LLVM. +CC_COMPAT += -mcpu=generic else CC_COMPAT ?= $(CROSS_COMPILE_COMPAT)gcc endif The failures for all the ARCH=arm configurations appear to be much more difficult to fix because the default CPU value changes based on the '-march' value, which basically means that we would have to hardcode LLVM's default CPU logic into the kernel's Makefile, which is just not maintainable in my opinion. Just doing a multi_v7_defconfig build of arch/arm/ shows the value returned from ARM::getARMCPUForArch() in llvm/lib/TargetParser/ARMTargetParser.cpp can vary between "arm7tdmi" or "generic". Supplying '-mcpu=generic' explicitly won't work with LLVM_IAS=0 because GNU as does not support it and clang just happily passes it along, even though it does not do that in the implicit default case. Sylvestre, I strongly believe you should consider reverting that change or give us some compiler flag that allows us to fallback to upstream LLVM's default CPU selection logic. I think that hardcoding Debian's architecture defintions based on the target triple into the compiler could cause issues for other projects as well. For example, '--target=arm-linux-gnueabi -march=armv7-a' won't actually target ARMv7: $ echo 'int main(void) { asm("dsb"); return 0; }' | \ clang --target=arm-linux-gnueabi -march=armv7-a \ -x c -c -o /dev/null -v - ... "/usr/bin/clang-17" -cc1 -triple armv7-unknown-linux-gnueabi ... ... vs. $ echo 'int main(void) { asm("dsb"); return 0; }' | \ clang --target=arm-linux-gnueabi -march=armv7-a \ -x c -c -o /dev/null -v - ... "/bin/clang-18" -cc1 -triple armv5e-unknown-linux-gnueabi ... ... Cheers, Nathan