Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp1788189rwb; Sun, 6 Aug 2023 03:00:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvUS1OugBH+xG5cTakshppe9+vXYDtPepPVmxoh9mHQZQZM9iyQZoZiKDLm//b6KPU4vJD X-Received: by 2002:a17:906:3196:b0:99c:c138:a694 with SMTP id 22-20020a170906319600b0099cc138a694mr3246591ejy.43.1691316037512; Sun, 06 Aug 2023 03:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691316037; cv=none; d=google.com; s=arc-20160816; b=KE/YUXngOD35e97IQgoR0nEHvPkIPz6dMjdKtxeTcurOl6iFFTR4gw5tRDbeNXLkvd Cgz8qRf+cBazfTwM4bTHfXgx47BJeYfmPnfosxI//vX14HwTGsk4d9Wa5I3Q5YemgAbo RQlIb2mmDylEpScbvdOW3xJcoTn5yPNsoqI2MKrkFGpM7dF0ozguJZ17FZTDjmLmJ+OG hF2khSXN8YNBB2n9hFRdkasEHTTWZbmIXqGRyrgtDz4rJ2iob/EGtVpKWoKj2n20byNE aXSqeqWlRERrQW4YhoqOeBikm4MPq1oJWFDlcoS0i6jMpLas5+4EsK8hoZ2iWCvNazyI kJbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=J+19cFblDN2AzTyx7vArIJJ/t7omPHRSq6P1jQaRuRo=; fh=/vS2sZUuhma2kdLIF5OIZVjw0sPbMnKegco7d7tPfD4=; b=hl4sdNnBOBWW5BqbiUo9BUUnBnV5BDx6cNIEcgxLHw63bkPRw0spcKV/WHlxrqktU9 3uRl+7P+WqqVnrBhKFJPItdrcwBGYJIzQ5+/WTHW3ckVj4PlNHinNmn3rikpZc+HSjph o0JMdwVAErV3Fo2n25WBLrLWSskjo6xJ63tfBC4aqDvdG/Zh6vZ0vgyQBMZejbvG+nqQ A2GZy/W+5gcRgrd9bPqscfWFJJvFsZPi2VKIfR6PD5H6RjhZI5Xhm40iAyoie373PiCd olElBbzoECSaT/RZrenYRJJwGRpDk23bIvImXUCnlp2bNNFaYcP02Koa0tM+Dvri5sgB Xh+g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z26-20020aa7cf9a000000b0052329110943si2073797edx.95.2023.08.06.03.00.13; Sun, 06 Aug 2023 03:00:37 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230189AbjHFJjn (ORCPT + 99 others); Sun, 6 Aug 2023 05:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjHFJjl (ORCPT ); Sun, 6 Aug 2023 05:39:41 -0400 Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 737CA1B3; Sun, 6 Aug 2023 02:39:38 -0700 (PDT) X-QQ-mid: bizesmtp80t1691314767tiuq1r0y Received: from linux-lab-host.localdomain ( [116.30.130.12]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 06 Aug 2023 17:39:26 +0800 (CST) X-QQ-SSF: 01200000000000E0X000000A0000000 X-QQ-FEAT: Nq+POyG2GSpEb8/3lK4WNmAIbWr1gD0CLEgZCmzgiVkuRvdF+f3t3VBpNVG6n 6h30wyuDStDJ/NDsQtmFNbqQ4a5K/eLOoJ07a22WiNnQyrGra92le02ZxmwGuI294f/icQl NdtATgxXtbBwfsgAHArwzH9IRmBvMxOO5KuNvshHIs/ntl6V+mkjJY0c63DnJLTjOPCrcRX MCzvezajTlrR3dBaHTzpQUNoetK/TqZfFuHCe9kWvATjA2qCHvg96KX0RfOIV8r3s8IRjk5 HGSlDngzrgcXoUQQmKWyH4SY6mL3uzTNr4k06pJS8v9JEdJCu72Dg48B22zZLJwgWFKrzXs n2MPpbl2FxjrUNIaH3U9wLCAFfuOm6BdC4xr6KGayWWpgeKt8vYV8oAAsim8MndfsF6T9i8 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 9856170352400102152 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tanyuan@tinylab.org, thomas@t-8ch.de Subject: Re: [PATCH v6 7/8] selftests/nolibc: allow customize CROSS_COMPILE by architecture Date: Sun, 6 Aug 2023 17:39:21 +0800 Message-Id: <20230806093921.9648-1-falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230806081731.GA10627@1wt.eu> References: <20230806081731.GA10627@1wt.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,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 Hi, Willy > On Sun, Aug 06, 2023 at 02:46:03AM +0800, Zhangjin Wu wrote: > > Some cross compilers may not just be prefixed with ARCH, customize them > > by architecture may simplify the test a lot, especially, when iterate > > with ARCH. > > > > After customizing this for every architecture, the minimal test argument > > will be architecture itself, no CROSS_COMPILE required to be passed. > > > > If the prefix of installed cross compiler is not the same as the one > > customized, we can also pass CROSS_COMPILE as before or even pass > > CROSS_COMPILE_. > > > > Signed-off-by: Zhangjin Wu > > --- > > tools/testing/selftests/nolibc/Makefile | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile > > index 452d8e424d28..45d231b9c5c2 100644 > > --- a/tools/testing/selftests/nolibc/Makefile > > +++ b/tools/testing/selftests/nolibc/Makefile > > @@ -55,6 +55,12 @@ IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi > > IMAGE = $(IMAGE_$(XARCH)) > > IMAGE_NAME = $(notdir $(IMAGE)) > > > > +# CROSS_COMPILE: cross toolchain prefix by architecture > > +CROSS_COMPILE ?= $(CROSS_COMPILE_$(XARCH)) > > + > > +# make sure CC is prefixed with CROSS_COMPILE > > +$(call allow-override,CC,$(CROSS_COMPILE)gcc) > > + > > Note that I feared that it would break my "CC=gcc-5.5.0" and so on but > fortunately it did not. However I don't understand what it tries to do > nor the problem it tries to solve (even the commit message is quite > unclear to me). I'm leaving it aside anyway but I wanted to let you > know. > Thanks you for this note, will add it as a test case in our v2. These places require the '$(CC)' prefixed with $(CROSS_COMPILE): $ grep ")\$(CC)" tools/testing/selftests/nolibc/Makefile $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ $(QUIET_CC)$(CC) -o $@ $< When CROSS_COMPILE come from command line, the first lines we included have the CROSS_COMPILE knowledge and will add right prefix for CC: # Makefile for nolibc tests include ../../../scripts/Makefile.include But the customized $(CROSS_COMPILE) must be added from the XARCH lines, then, differs from the ones passed from command line, the above lines (before XARCH) will have no CROSS_COMPILE knowledge, the CC therefore will have no prefix. CROSS_COMPILE=xxx <= before, from command line include ../../../scripts/Makefile.include <= CC get the right CROSS_COMPILE prefix XARCH = $(or $(XARCH_$(ARCH)),$(ARCH)) <= XARCH here CROSS_COMPILE ?= $(CROSS_COMPILE_$(XARCH)) <= after, customize ourselves (call allow-override,CC,$(CROSS_COMPILE)gcc) <= CC have no right prefix here $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \ So, we must add the prefix to CC ourselves after the CROSS_COMPILE lines we customized, the 'allow-override' helper is also from ../../../scripts/Makefile.include. But you did find a bug above, we should include it again here to avoid not break the possibility of using llvm (still require to check if there are some other regressions): include ../../../scripts/Makefile.include And I have further found there is another cc-cross-prefix helper from: $ grep cc-cross-prefix -ur scripts/ scripts/Makefile.compiler:# cc-cross-prefix scripts/Makefile.compiler:# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) scripts/Makefile.compiler:cc-cross-prefix = $(firstword $(foreach c, $(1), \ So, we are able to search the toolchains from Arnd's, local toolchains and ..., may not need to force users to use which one, I will do more tests on it. Please don't merge this patch too, to avoid break anything, let's tune it carefully in our v2 and delay the whole stuff to v6.7. Thanks, Zhangjin > Willy