Skip to contentSkip to conversation

tools: Override makefile ARCH variable if defined, but empty

PATCH Superseded Björn Töpel 6 participants 7 messages Nov 6, 2024 – Nov 26, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: Override makefile ARCH variable if defined, but empty

From: Björn Töpel <[email protected]>

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")
---
 tools/scripts/Makefile.arch | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/scripts/Makefile.arch +2 -2
index f6a50f06dfc4..eabfe9f411d9 100644
@@ -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

Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Björn Töpel

From: Björn Töpel <[email protected]>

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.

Quoted 7 lines

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")
Quoted 24 lines
---
 tools/scripts/Makefile.arch | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/scripts/Makefile.arch +2 -2
index f6a50f06dfc4..eabfe9f411d9 100644
@@ -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

Signature · 1 line
2.45.2
Tested-by
#2 lore raw

Hi Björn,

Quoted 41 lines · Jean-Philippe Brucker
Quoted 11 lines · Björn Töpel

From: Björn Töpel <[email protected]>

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.

Quoted 7 lines

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")
Quoted 18 lines
---
 tools/scripts/Makefile.arch | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/scripts/Makefile.arch +2 -2
index f6a50f06dfc4..eabfe9f411d9 100644
@@ -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
 
Quoted 6 lines
Quoted 6 lines
tools/scripts/Makefile.arch +0 -0
 SRCARCH := $(ARCH)

base-commit: 7758b206117dab9894f0bcb8333f8e4731c5065a --
2.45.2

You can add:

Thanks,

Alex

#3 lore raw
In reply to Björn Töpel
Quoted 11 lines · Björn Töpel

From: Björn Töpel <[email protected]>

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.

Quoted 7 lines

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")

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

Reviewed-by
#4 lore raw
Quoted 13 lines · Björn Töpel
Quoted 11 lines · Björn Töpel

From: Björn Töpel <[email protected]>

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.

Quoted 7 lines
Quoted 7 lines

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")
Quoted 5 lines

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

Quoted 6 lines

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

Björn

#5 lore raw

2024-11-20 22:04 UTC-0800 ~ Namhyung Kim <[email protected]>

Quoted 17 lines · Björn Töpel
Quoted 16 lines
Quoted 14 lines · Björn Töpel

From: Björn Töpel <[email protected]>

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.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

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

Fixes 8859b0da5aac ("tools/bpftool: Fix cross-build")
Quoted 8 lines
Quoted 4 lines

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

#6 lore raw
Quoted 35 lines · Quentin Monnet

2024-11-20 22:04 UTC-0800 ~ Namhyung Kim <[email protected]>

Quoted 17 lines · Björn Töpel
Quoted 16 lines
Quoted 14 lines · Björn Töpel

From: Björn Töpel <[email protected]>

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.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

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

Fixes 8859b0da5aac ("tools/bpftool: Fix cross-build")
Quoted 5 lines
Quoted 4 lines

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?

Quoted 7 lines
Quoted 3 lines

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.

Quoted 2 lines

Quentin