Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp1830787rwb; Sun, 6 Aug 2023 04:08:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdCjmzLWu+0jVGUXrBo9Q2RQr1HB7Kx25Sd20zMSpYX1huQMRbRxVWeseMGgW7uGck2lML X-Received: by 2002:a05:6a00:1798:b0:666:b254:1c9c with SMTP id s24-20020a056a00179800b00666b2541c9cmr6608761pfg.27.1691320105695; Sun, 06 Aug 2023 04:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691320105; cv=none; d=google.com; s=arc-20160816; b=mNAExIpD2BxFqoo7Q8q9SIJNZWtOATlUi26Gi+cyqsIuS3rYZFKLZK34hSSeCc/lAP lQX1xAglgso+nfbq4mw5xrktasKAtvSgvaG5++hkSJCI/Ev3yvazQQmtO+phDl53BgaS Upj9Gt5pDwb1vmnZ/xGWwvZn5DTgyvmEZP+NYdQgnMSprc2ROwDjMQ61qDWOJsT56PdZ vtMvURKnP4fUGc9iD89FSuJ+QiiiarvjhvJwZkogQxOOIgSX0J1UTNaJfbsiV3LNaHL9 xUY+2ODaRM1J0rscPDBIY/byzJmEah8azG6wd2oMbc3nj/e9BzPobM3gwSizbM5esLP4 +V1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=6MPcdY7MopCzMoI/ja8Or2E32Zy7UNa8AaffNIcKhPs=; fh=+JBeOadqUsa9XSBIXq4VuB3OufFNBxHjauCOPr6+Aw8=; b=XEMnMRYfME1rQrMHdD4/kucgZOVpsnI7Lr7SxMbFiNGEly179R1roI0uwlOoYCVaDE TEgYqWOcVw+1jyog6qkPhUm3r2lTXLepML/frTNHIgonCMakiDyzYecAvn5mzyC8RlZx pYy8CUboNb1HlH/7aYv2OHTsXRGgAH7dLP2W7o5dmOwNQp1DJJ4Ef+yKhwBD89+G8Hld W8CAJdZYdmwWCA1csVq8XUnF8ufcwhpsbfKFoLxuozy/JzMGK6JuyAH/3CEzSQT7SKx4 X+wEUouxozrjnIqzAGziThIk6eMqNDl8oOpPMUu/gZ+FBB0hHqwQHjEeN0gL4un9/fpt kcxA== 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 l6-20020a632506000000b0055b4307963fsi4263451pgl.197.2023.08.06.04.08.14; Sun, 06 Aug 2023 04:08:25 -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 S230237AbjHFKEZ (ORCPT + 99 others); Sun, 6 Aug 2023 06:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbjHFKEW (ORCPT ); Sun, 6 Aug 2023 06:04:22 -0400 Received: from 1wt.eu (ded1.1wt.eu [163.172.96.212]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2B7441BEF; Sun, 6 Aug 2023 03:04:18 -0700 (PDT) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 376A4AcX012345; Sun, 6 Aug 2023 12:04:10 +0200 Date: Sun, 6 Aug 2023 12:04:10 +0200 From: Willy Tarreau To: Zhangjin Wu Cc: arnd@arndb.de, 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 Message-ID: <20230806100410.GC10627@1wt.eu> References: <20230806081731.GA10627@1wt.eu> <20230806093921.9648-1-falcon@tinylab.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230806093921.9648-1-falcon@tinylab.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 On Sun, Aug 06, 2023 at 05:39:21PM +0800, Zhangjin Wu wrote: > > > +# 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. OK, I feared it would overwrite the command-line one. > 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. OK. Note that in the end it might be less difficult to try to set CROSS_COMPILE *before* including the general include instead of after: we could preset CROSS_COMPILE based on the ARCH/XARCH we know at this step, as this is not expected to rely on auto-detection. Willy