Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5731092rwb; Tue, 1 Aug 2023 07:12:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2aynnne1gvY3IDuup3OGlGi10ydShj/99zb3HWnagKmWByCGHRZId4u107/Y24TkhfMw0 X-Received: by 2002:a05:6a20:1446:b0:13d:c12a:b988 with SMTP id a6-20020a056a20144600b0013dc12ab988mr6597574pzi.46.1690899156540; Tue, 01 Aug 2023 07:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690899156; cv=none; d=google.com; s=arc-20160816; b=FchWwcRDsmoUVXSCJUL3k6RLDUiaAoAtkJ+V8Be7nDwAuIpwM5EkI3iIMfwbe9fWCX WScBy68G/42HinLVWhD5k83Ai5ROWWTOFO+x9ZLccFSyEaU9Xptl3Y3K62uQq1urtvVL 40Lm3KZ8pnu9xgVI6W4e0D5VPeZez//RNKDmf5F3/MrSTzsIC0U6FXDp83H3Nj2WnJG2 CgEhNy/x9CsuWb8qnjza8WfybgO+YtUEd4PzD1G784ppKj2WclyFqfzjU6lkkSmoeep5 fASFLazUtHm53rmJOABZ9PyBwQHsafdGAZwzO6185sdMPFCoS3/5fziatdDfgfCyoWz2 /6tg== 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=bSm87dvEHn9CsXYdZ55R4IZ7miF+11Rs80JfUiz52R4=; fh=QEskit0jhLG3sus5DR3y1EOo6fKk+Z0Rslwln+TxyzQ=; b=DT/sBPszUhhR1QVzF/eewVTkxKLGtOfWmettUMrFAqLlneARBnfxMqApTUS5NVZI0N qbkUeROrJ0lvQLl3PudBq1pZgWqovKm7pfWfuzylcJn8HtNgFkNFcqkcEi3ieVJhEnoh iHYMf0fxUCKQytI4wxgSNItF28E5lXhqTs7nRkElWaELrNfCnyABVBvXk0YdsTqj30cz jjDK5aDmz243svEsgubarD0Pb4p+Ekd882hw8ZuVSg2GKfotzz0AdSB1IKMIBE/c1OQZ yBsjS0petwhhZlshZUAS4sSLkt4vvq7dx3h09JkddWxk99gJnGTC4tpOcGIiuRxS6FLd zyUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GNLgLd+D; 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 dw19-20020a056a00369300b00686bb182af7si9294808pfb.46.2023.08.01.07.12.24; Tue, 01 Aug 2023 07:12:36 -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=GNLgLd+D; 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 S232499AbjHANkk (ORCPT + 99 others); Tue, 1 Aug 2023 09:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231229AbjHANkj (ORCPT ); Tue, 1 Aug 2023 09:40:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17909139 for ; Tue, 1 Aug 2023 06:40:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 872D96157C for ; Tue, 1 Aug 2023 13:40:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80CD9C433C8; Tue, 1 Aug 2023 13:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690897236; bh=1F/npABRXysSuJPmy5xHodfUuUjJEuXIHmC2YuarPHY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GNLgLd+DD4ffPBVltZF4rkHUPw/buHwy4IJSef5CuVwFThxOyoVHk1/KJdVGqyEZe s2oL+PSa2r5OZdF1EjGysdOupFDmvEPkPbbRi8hLKBGdRu1QQDhxiSgeF7W/Ew8itZ Td3fQQz/Ge+fm6Iad2/gA/inxGHoiMOJbP/lVgTHcHTH3CSNg05knLSlFyJPYWGx1q 3xntjHecjlrJxkWbUPhiNC+J6loH1CbKlolVg/BtpXLd2BWIrPUkAs3By+rbwJqTbQ cAsMXiRsE+xmBc5ANcY09gczsQl0S1Fnw8EtzQX6dABfA0prU0iOGSSlw67KTV2AmQ GvSWduXMYsdrg== Date: Tue, 1 Aug 2023 06:40:34 -0700 From: Nathan Chancellor To: Tiezhu Yang Cc: Huacai Chen , Nick Desaulniers , loongarch@lists.linux.dev, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: Re: [PATCH] LoongArch: Error out if clang version is less than 17.0.0 Message-ID: <20230801134034.GA3831650@dev-arch.thelio-3990X> References: <1690871446-23713-1-git-send-email-yangtiezhu@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1690871446-23713-1-git-send-email-yangtiezhu@loongson.cn> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi Tiezhu, On Tue, Aug 01, 2023 at 02:30:46PM +0800, Tiezhu Yang wrote: > On my test machine, the clang version is 16.0.4, when build kernel > with clang: > > make CC=clang loongson3_defconfig > make CC=clang > > there exist many errors such as: > > clang-16: error: argument unused during compilation: '-mabi=lp64s' > error: unknown register name 'a0' in asm > error: unknown register name 't0' in asm > > the above issues have been fixed in the upstream llvm project recently, > it works well when update clang version to 17.0.0: > > make CC=clang loongson3_defconfig > make CC=clang menuconfig (set CONFIG_MODULES=n and CONFIG_RELOCATABLE=n) > make CC=clang > > thus 17.0.0 is the minimal clang version to build kernel on LoongArch, > it is better to error out if clang version is less than 17.0.0, then > we can do the right thing to update clang version and avoid wasting > time to analysis kernel errors. > > By the way, the clang 17.0.0 still have some issues to build kernel on > LoongArch, you need to unset CONFIG_MODULES and CONFIG_RELOCATABLE to > avoid build errors. Additionally, if you want a workable kernel, some > modules should be set as y instead of m if CONFIG_MODULES=n. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1787 > Signed-off-by: Tiezhu Yang > --- > arch/loongarch/Makefile | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > index b1e5db5..f07f62a 100644 > --- a/arch/loongarch/Makefile > +++ b/arch/loongarch/Makefile > @@ -10,6 +10,12 @@ KBUILD_DEFCONFIG := loongson3_defconfig > image-name-y := vmlinux > image-name-$(CONFIG_EFI_ZBOOT) := vmlinuz > > +ifdef CONFIG_CC_IS_CLANG > + ifneq ($(call clang-min-version, 170000),y) > + $(error Sorry, you need a newer clang version >= 17.0.0) > + endif > +endif > + Thanks for the patch! I agree that we should restrict LoongArch to LLVM 17 and newer. However, there is already existing infrastructure for this type of check in Kconfig, so we don't need to add anything to arch/loongarch. Just modify scripts/min-tool-version.sh like so then there will be a message during configuration time that the compiler is too old. diff --git a/scripts/min-tool-version.sh b/scripts/min-tool-version.sh index 2ade63149466..572c0526ad61 100755 --- a/scripts/min-tool-version.sh +++ b/scripts/min-tool-version.sh @@ -26,6 +26,8 @@ gcc) llvm) if [ "$SRCARCH" = s390 ]; then echo 15.0.0 + elif [ "$SRCARCH" = loongarch ]; then + echo 17.0.0 else echo 11.0.0 fi *** *** C compiler is too old. *** Your Clang version: 16.0.6 *** Minimum Clang version: 17.0.0 *** scripts/Kconfig.include:44: Sorry, this C compiler is not supported. > ifndef CONFIG_EFI_STUB > KBUILD_IMAGE := $(boot)/vmlinux.elf > else > -- > 2.1.0 > > Cheers, Nathan