perf build: compile BPF skeletons with -mcpu=v3
Subsystems (2)
PATCH v2 2/2 perf build: compile BPF skeletons with -mcpu=v3
The lock_contention BPF program uses __sync_val_compare_and_swap() to atomically update the max_time and min_time fields in contention_data. This builtin lowers to the BPF_CMPXCHG instruction, which is only available in BPF ISA v3. Without an explicit -mcpu flag, Clang targets BPF v1/v2 by default on older toolchains (Clang < 18), causing build errors when v3 instructions are emitted.
Add -mcpu=v3 to CLANG_OPTIONS, which is used exclusively in the BPF skeleton compilation rule.
Changes since v1:
- Moved the -mcpu=v3 addition from tools/perf/Makefile.perf to tools/perf/bpf_skel.mak, following the refactoring of BPF skeleton build logic into that file.
--- tools/perf/bpf_skel.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/bpf_skel.mak +1 -1
@@ -29,7 +29,7 @@ ifneq ($(CROSS_COMPILE),) CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) endif -CLANG_OPTIONS = -Wall +CLANG_OPTIONS = -Wall -mcpu=v3 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) LIBBPF_INCLUDE := $(abspath $(or $(OUTPUT),.))/libbpf/include BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(SKEL_TOOL_OUT) -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES)
Signature · 1 line
2.54.0
Quoted 8 lines · Suchit Karunakaran
The
lock_contentionBPF program uses__sync_val_compare_and_swap()to atomically update themax_timeandmin_timefields incontention_data. This builtin lowers to theBPF_CMPXCHGinstruction, which is only available in BPF ISA v3. Without an explicit -mcpu flag, Clang targets BPF v1/v2 by default on older toolchains (Clang < 18), causing build errors when v3 instructions are emitted.
Quoted 4 lines
Add -mcpu=v3 to
CLANG_OPTIONS, which is used exclusively in the BPF skeleton compilation rule.Signed-off-by Suchit Karunakaran <[email protected]>
Thanks,
Ian
Quoted 24 lines
Changes since v1:
- Moved the -mcpu=v3 addition fromtools/perf/Makefile.perftotools/perf/bpf_skel.mak, following the refactoring of BPF skeleton build logic into that file.--- tools/perf/bpf_skel.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/bpf_skel.mak +1
-2@@ -29,7 +29,7 @@ ifneq ($(CROSS_COMPILE),) CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) endif -CLANG_OPTIONS = -Wall +CLANG_OPTIONS = -Wall -mcpu=v3 CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) LIBBPF_INCLUDE := $(abspath $(or $(OUTPUT),.))/libbpf/include BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(SKEL_TOOL_OUT) -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) --2.54.0
Quoted 10 lines · Ian Rogers
Quoted 8 lines · Suchit Karunakaran
The
lock_contentionBPF program uses__sync_val_compare_and_swap()to atomically update themax_timeandmin_timefields incontention_data. This builtin lowers to theBPF_CMPXCHGinstruction, which is only available in BPF ISA v3. Without an explicit -mcpu flag, Clang targets BPF v1/v2 by default on older toolchains (Clang < 18), causing build errors when v3 instructions are emitted.
Quoted 6 lines
Quoted 4 lines
Add -mcpu=v3 to
CLANG_OPTIONS, which is used exclusively in the BPF skeleton compilation rule.Signed-off-by Suchit Karunakaran <[email protected]>Acked-by Ian Rogers <[email protected]>
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo