All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Zhangjin Wu <falcon@tinylab.org>
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
Date: Sun, 6 Aug 2023 12:04:10 +0200	[thread overview]
Message-ID: <20230806100410.GC10627@1wt.eu> (raw)
In-Reply-To: <20230806093921.9648-1-falcon@tinylab.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

  reply	other threads:[~2023-08-06 10:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-05 18:38 [PATCH v6 0/8] tools/nolibc: add 32/64-bit powerpc support Zhangjin Wu
2023-08-05 18:39 ` [PATCH v6 1/8] tools/nolibc: add support for powerpc Zhangjin Wu
2023-08-05 18:40 ` [PATCH v6 2/8] tools/nolibc: add support for powerpc64 Zhangjin Wu
2023-08-05 18:41 ` [PATCH v6 3/8] selftests/nolibc: add XARCH and ARCH mapping support Zhangjin Wu
2023-08-05 18:42 ` [PATCH v6 4/8] selftests/nolibc: add test support for ppc Zhangjin Wu
2023-08-05 18:43 ` [PATCH v6 5/8] selftests/nolibc: add test support for ppc64le Zhangjin Wu
2023-08-05 18:44 ` [PATCH v6 6/8] selftests/nolibc: add test support for ppc64 Zhangjin Wu
2023-08-05 18:46 ` [PATCH v6 7/8] selftests/nolibc: allow customize CROSS_COMPILE by architecture Zhangjin Wu
2023-08-06  8:17   ` Willy Tarreau
2023-08-06  9:39     ` Zhangjin Wu
2023-08-06 10:04       ` Willy Tarreau [this message]
2023-08-06 10:16         ` Zhangjin Wu
2023-08-05 18:47 ` [PATCH v6 8/8] selftests/nolibc: customize CROSS_COMPILE for 32/64-bit powerpc Zhangjin Wu
2023-08-05 20:48   ` Willy Tarreau
2023-08-06  3:11     ` Zhangjin Wu
2023-08-06  3:18       ` Willy Tarreau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230806100410.GC10627@1wt.eu \
    --to=w@1wt.eu \
    --cc=arnd@arndb.de \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=tanyuan@tinylab.org \
    --cc=thomas@t-8ch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.