linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: Override makefile ARCH variable if defined, but empty
@ 2024-11-06 19:32 Björn Töpel
  2024-11-07  9:13 ` Jean-Philippe Brucker
  2024-11-20 13:25 ` Björn Töpel
  0 siblings, 2 replies; 7+ messages in thread
From: Björn Töpel @ 2024-11-06 19:32 UTC (permalink / raw)
  To: bpf, linux-perf-users, Alexandre Ghiti, Arnaldo Carvalho de Melo,
	Jean-Philippe Brucker, Quentin Monnet
  Cc: Björn Töpel, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	linux-riscv, linux-kernel, David Abdurachmanov

From: Björn Töpel <bjorn@rivosinc.com>

There are a number of tools (bpftool, selftests), that require a
"bootstrap" build. Here, a bootstrap build is a build host variant of
a target. E.g., assume that you're performing a bpftool cross-build on
x86 to riscv, a bootstrap build would then be an x86 variant of
bpftool. The typical way to perform the host build variant, is to pass
"ARCH=" in a sub-make. However, if a variable has been set with a
command argument, then ordinary assignments in the makefile are
ignored.

This side-effect results in that ARCH, and variables depending on ARCH
are not set.

Workaround by overriding ARCH to the host arch, if ARCH is empty.

Fixes: 8859b0da5aac ("tools/bpftool: Fix cross-build")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
---
 tools/scripts/Makefile.arch | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch
index f6a50f06dfc4..eabfe9f411d9 100644
--- a/tools/scripts/Makefile.arch
+++ b/tools/scripts/Makefile.arch
@@ -7,8 +7,8 @@ HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
                                   -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
                                   -e s/riscv.*/riscv/ -e s/loongarch.*/loongarch/)
 
-ifndef ARCH
-ARCH := $(HOSTARCH)
+ifeq ($(strip $(ARCH)),)
+override ARCH := $(HOSTARCH)
 endif
 
 SRCARCH := $(ARCH)

base-commit: 7758b206117dab9894f0bcb8333f8e4731c5065a
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] tools: Override makefile ARCH variable if defined, but empty
  2024-11-06 19:32 [PATCH] tools: Override makefile ARCH variable if defined, but empty Björn Töpel
@ 2024-11-07  9:13 ` Jean-Philippe Brucker
  2024-11-07 10:09   ` Alexandre Ghiti
  2024-11-20 13:25 ` Björn Töpel
  1 sibling, 1 reply; 7+ messages in thread
From: Jean-Philippe Brucker @ 2024-11-07  9:13 UTC (permalink / raw)
  To: Björn Töpel
  Cc: bpf, linux-perf-users, Alexandre Ghiti, Arnaldo Carvalho de Melo,
	Quentin Monnet, Björn Töpel, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, linux-riscv, linux-kernel,
	David Abdurachmanov

On Wed, Nov 06, 2024 at 08:32:06PM +0100, Björn Töpel wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
> 
> There are a number of tools (bpftool, selftests), that require a
> "bootstrap" build. Here, a bootstrap build is a build host variant of
> a target. E.g., assume that you're performing a bpftool cross-build on
> x86 to riscv, a bootstrap build would then be an x86 variant of
> bpftool. The typical way to perform the host build variant, is to pass
> "ARCH=" in a sub-make. However, if a variable has been set with a
> command argument, then ordinary assignments in the makefile are
> ignored.
> 
> This side-effect results in that ARCH, and variables depending on ARCH
> are not set.
> 
> Workaround by overriding ARCH to the host arch, if ARCH is empty.
> 
> Fixes: 8859b0da5aac ("tools/bpftool: Fix cross-build")
> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>

Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

> ---
>  tools/scripts/Makefile.arch | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch
> index f6a50f06dfc4..eabfe9f411d9 100644
> --- a/tools/scripts/Makefile.arch
> +++ b/tools/scripts/Makefile.arch
> @@ -7,8 +7,8 @@ HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
>                                    -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
>                                    -e s/riscv.*/riscv/ -e s/loongarch.*/loongarch/)
>  
> -ifndef ARCH
> -ARCH := $(HOSTARCH)
> +ifeq ($(strip $(ARCH)),)
> +override ARCH := $(HOSTARCH)
>  endif
>  
>  SRCARCH := $(ARCH)
> 
> base-commit: 7758b206117dab9894f0bcb8333f8e4731c5065a
> -- 
> 2.45.2
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tools: Override makefile ARCH variable if defined, but empty
  2024-11-07  9:13 ` Jean-Philippe Brucker
@ 2024-11-07 10:09   ` Alexandre Ghiti
  0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Ghiti @ 2024-11-07 10:09 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: Björn Töpel, bpf, linux-perf-users,
	Arnaldo Carvalho de Melo, Quentin Monnet, Björn Töpel,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv,
	linux-kernel, David Abdurachmanov

Hi Björn,

On Thu, Nov 7, 2024 at 10:12 AM Jean-Philippe Brucker
<jean-philippe@linaro.org> wrote:
>
> On Wed, Nov 06, 2024 at 08:32:06PM +0100, Björn Töpel wrote:
> > From: Björn Töpel <bjorn@rivosinc.com>
> >
> > There are a number of tools (bpftool, selftests), that require a
> > "bootstrap" build. Here, a bootstrap build is a build host variant of
> > a target. E.g., assume that you're performing a bpftool cross-build on
> > x86 to riscv, a bootstrap build would then be an x86 variant of
> > bpftool. The typical way to perform the host build variant, is to pass
> > "ARCH=" in a sub-make. However, if a variable has been set with a
> > command argument, then ordinary assignments in the makefile are
> > ignored.
> >
> > This side-effect results in that ARCH, and variables depending on ARCH
> > are not set.
> >
> > Workaround by overriding ARCH to the host arch, if ARCH is empty.
> >
> > Fixes: 8859b0da5aac ("tools/bpftool: Fix cross-build")
> > Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
>
> Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
>
> > ---
> >  tools/scripts/Makefile.arch | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/scripts/Makefile.arch b/tools/scripts/Makefile.arch
> > index f6a50f06dfc4..eabfe9f411d9 100644
> > --- a/tools/scripts/Makefile.arch
> > +++ b/tools/scripts/Makefile.arch
> > @@ -7,8 +7,8 @@ HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
> >                                    -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
> >                                    -e s/riscv.*/riscv/ -e s/loongarch.*/loongarch/)
> >
> > -ifndef ARCH
> > -ARCH := $(HOSTARCH)
> > +ifeq ($(strip $(ARCH)),)
> > +override ARCH := $(HOSTARCH)
> >  endif
> >
> >  SRCARCH := $(ARCH)
> >
> > base-commit: 7758b206117dab9894f0bcb8333f8e4731c5065a
> > --
> > 2.45.2
> >

You can add:

Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks,

Alex

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tools: Override makefile ARCH variable if defined, but empty
  2024-11-06 19:32 [PATCH] tools: Override makefile ARCH variable if defined, but empty Björn Töpel
  2024-11-07  9:13 ` Jean-Philippe Brucker
@ 2024-11-20 13:25 ` Björn Töpel
  2024-11-21  6:04   ` Namhyung Kim
  1 sibling, 1 reply; 7+ messages in thread
From: Björn Töpel @ 2024-11-20 13:25 UTC (permalink / raw)
  To: bpf, linux-perf-users, Alexandre Ghiti, Arnaldo Carvalho de Melo,
	Jean-Philippe Brucker, Quentin Monnet, Palmer Dabbelt
  Cc: Björn Töpel, Paul Walmsley, Albert Ou, linux-riscv,
	linux-kernel, David Abdurachmanov

Björn Töpel <bjorn@kernel.org> writes:

> From: Björn Töpel <bjorn@rivosinc.com>
>
> There are a number of tools (bpftool, selftests), that require a
> "bootstrap" build. Here, a bootstrap build is a build host variant of
> a target. E.g., assume that you're performing a bpftool cross-build on
> x86 to riscv, a bootstrap build would then be an x86 variant of
> bpftool. The typical way to perform the host build variant, is to pass
> "ARCH=" in a sub-make. However, if a variable has been set with a
> command argument, then ordinary assignments in the makefile are
> ignored.
>
> This side-effect results in that ARCH, and variables depending on ARCH
> are not set.
>
> Workaround by overriding ARCH to the host arch, if ARCH is empty.
>
> Fixes: 8859b0da5aac ("tools/bpftool: Fix cross-build")
> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>

Arnaldo/Palmer/Quentin:

A bit unsure what tree this patch should go. It's very important for the
RISC-V builds, so maybe via Palmer's RISC-V tree?

Opinions? Just want to make sure it doesn't fall between any chairs!
:-)


Björn

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tools: Override makefile ARCH variable if defined, but empty
  2024-11-20 13:25 ` Björn Töpel
@ 2024-11-21  6:04   ` Namhyung Kim
  2024-11-21 11:29     ` Quentin Monnet
  0 siblings, 1 reply; 7+ messages in thread
From: Namhyung Kim @ 2024-11-21  6:04 UTC (permalink / raw)
  To: Björn Töpel
  Cc: bpf, linux-perf-users, Alexandre Ghiti, Arnaldo Carvalho de Melo,
	Jean-Philippe Brucker, Quentin Monnet, Palmer Dabbelt,
	Björn Töpel, Paul Walmsley, Albert Ou, linux-riscv,
	linux-kernel, David Abdurachmanov

On Wed, Nov 20, 2024 at 02:25:22PM +0100, Björn Töpel wrote:
> Björn Töpel <bjorn@kernel.org> writes:
> 
> > From: Björn Töpel <bjorn@rivosinc.com>
> >
> > There are a number of tools (bpftool, selftests), that require a
> > "bootstrap" build. Here, a bootstrap build is a build host variant of
> > a target. E.g., assume that you're performing a bpftool cross-build on
> > x86 to riscv, a bootstrap build would then be an x86 variant of
> > bpftool. The typical way to perform the host build variant, is to pass
> > "ARCH=" in a sub-make. However, if a variable has been set with a
> > command argument, then ordinary assignments in the makefile are
> > ignored.
> >
> > This side-effect results in that ARCH, and variables depending on ARCH
> > are not set.
> >
> > Workaround by overriding ARCH to the host arch, if ARCH is empty.
> >
> > Fixes: 8859b0da5aac ("tools/bpftool: Fix cross-build")
> > Signed-off-by: Björn Töpel <bjorn@rivosinc.com>

Reviewed-by: Namhyung Kim <namhyung@kernel.org>

> 
> Arnaldo/Palmer/Quentin:
> 
> A bit unsure what tree this patch should go. It's very important for the
> RISC-V builds, so maybe via Palmer's RISC-V tree?

I think it'd be best to route this through the bpf tree as it seems the
main target is bpftool.  But given the size and the scope of the change,
it should be fine with perf-tools or RISC-V tree.

Thanks,
Namhyung

> 
> Opinions? Just want to make sure it doesn't fall between any chairs!
> :-)
> 
> 
> Björn

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tools: Override makefile ARCH variable if defined, but empty
  2024-11-21  6:04   ` Namhyung Kim
@ 2024-11-21 11:29     ` Quentin Monnet
  2024-11-26 19:08       ` Andrii Nakryiko
  0 siblings, 1 reply; 7+ messages in thread
From: Quentin Monnet @ 2024-11-21 11:29 UTC (permalink / raw)
  To: Namhyung Kim, Björn Töpel
  Cc: bpf, linux-perf-users, Alexandre Ghiti, Arnaldo Carvalho de Melo,
	Jean-Philippe Brucker, Palmer Dabbelt, Björn Töpel,
	Paul Walmsley, Albert Ou, linux-riscv, linux-kernel,
	David Abdurachmanov, Daniel Borkmann, Alexei Starovoitov,
	Andrii Nakryiko, Martin KaFai Lau

2024-11-20 22:04 UTC-0800 ~ Namhyung Kim <namhyung@kernel.org>
> On Wed, Nov 20, 2024 at 02:25:22PM +0100, Björn Töpel wrote:
>> Björn Töpel <bjorn@kernel.org> writes:
>>
>>> From: Björn Töpel <bjorn@rivosinc.com>
>>>
>>> There are a number of tools (bpftool, selftests), that require a
>>> "bootstrap" build. Here, a bootstrap build is a build host variant of
>>> a target. E.g., assume that you're performing a bpftool cross-build on
>>> x86 to riscv, a bootstrap build would then be an x86 variant of
>>> bpftool. The typical way to perform the host build variant, is to pass
>>> "ARCH=" in a sub-make. However, if a variable has been set with a
>>> command argument, then ordinary assignments in the makefile are
>>> ignored.
>>>
>>> This side-effect results in that ARCH, and variables depending on ARCH
>>> are not set.
>>>
>>> Workaround by overriding ARCH to the host arch, if ARCH is empty.
>>>
>>> Fixes: 8859b0da5aac ("tools/bpftool: Fix cross-build")
>>> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
> 
> Reviewed-by: Namhyung Kim <namhyung@kernel.org>


Acked-by: Quentin Monnet <qmo@kernel.org>


>> Arnaldo/Palmer/Quentin:
>>
>> A bit unsure what tree this patch should go. It's very important for the
>> RISC-V builds, so maybe via Palmer's RISC-V tree?
> 
> I think it'd be best to route this through the bpf tree as it seems the
> main target is bpftool.  But given the size and the scope of the change,
> it should be fine with perf-tools or RISC-V tree.


The bpf tree would make sense to me as well (but I don't merge patches
myself; let me Cc BPF maintainers).

Quentin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tools: Override makefile ARCH variable if defined, but empty
  2024-11-21 11:29     ` Quentin Monnet
@ 2024-11-26 19:08       ` Andrii Nakryiko
  0 siblings, 0 replies; 7+ messages in thread
From: Andrii Nakryiko @ 2024-11-26 19:08 UTC (permalink / raw)
  To: Quentin Monnet
  Cc: Namhyung Kim, Björn Töpel, bpf, linux-perf-users,
	Alexandre Ghiti, Arnaldo Carvalho de Melo, Jean-Philippe Brucker,
	Palmer Dabbelt, Björn Töpel, Paul Walmsley, Albert Ou,
	linux-riscv, linux-kernel, David Abdurachmanov, Daniel Borkmann,
	Alexei Starovoitov, Andrii Nakryiko, Martin KaFai Lau

On Thu, Nov 21, 2024 at 3:30 AM Quentin Monnet <qmo@kernel.org> wrote:
>
> 2024-11-20 22:04 UTC-0800 ~ Namhyung Kim <namhyung@kernel.org>
> > On Wed, Nov 20, 2024 at 02:25:22PM +0100, Björn Töpel wrote:
> >> Björn Töpel <bjorn@kernel.org> writes:
> >>
> >>> From: Björn Töpel <bjorn@rivosinc.com>
> >>>
> >>> There are a number of tools (bpftool, selftests), that require a
> >>> "bootstrap" build. Here, a bootstrap build is a build host variant of
> >>> a target. E.g., assume that you're performing a bpftool cross-build on
> >>> x86 to riscv, a bootstrap build would then be an x86 variant of
> >>> bpftool. The typical way to perform the host build variant, is to pass
> >>> "ARCH=" in a sub-make. However, if a variable has been set with a
> >>> command argument, then ordinary assignments in the makefile are
> >>> ignored.
> >>>
> >>> This side-effect results in that ARCH, and variables depending on ARCH
> >>> are not set.
> >>>
> >>> Workaround by overriding ARCH to the host arch, if ARCH is empty.
> >>>
> >>> Fixes: 8859b0da5aac ("tools/bpftool: Fix cross-build")
> >>> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
> >
> > Reviewed-by: Namhyung Kim <namhyung@kernel.org>
>
>
> Acked-by: Quentin Monnet <qmo@kernel.org>
>
>
> >> Arnaldo/Palmer/Quentin:
> >>
> >> A bit unsure what tree this patch should go. It's very important for the
> >> RISC-V builds, so maybe via Palmer's RISC-V tree?
> >
> > I think it'd be best to route this through the bpf tree as it seems the
> > main target is bpftool.  But given the size and the scope of the change,
> > it should be fine with perf-tools or RISC-V tree.
>
>
> The bpf tree would make sense to me as well (but I don't merge patches
> myself; let me Cc BPF maintainers).

Doesn't seem like this file is owned by anyone specific, I guess it's
fine to route it through BPF due to bpftool? Should this be bpf or
bpf-next? Also, please resend targeting the right tree, so BPF CI can
test this.

>
> Quentin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-26 19:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06 19:32 [PATCH] tools: Override makefile ARCH variable if defined, but empty Björn Töpel
2024-11-07  9:13 ` Jean-Philippe Brucker
2024-11-07 10:09   ` Alexandre Ghiti
2024-11-20 13:25 ` Björn Töpel
2024-11-21  6:04   ` Namhyung Kim
2024-11-21 11:29     ` Quentin Monnet
2024-11-26 19:08       ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).