Skip to content

Commit 8988c4b

Browse files
james-c-linaronamhyung
authored andcommitted
perf tools: Fix in-source libperf build
When libperf is built alone in-source, $(OUTPUT) isn't set. This causes the generated uapi path to resolve to '/../arch' which results in a permissions error: mkdir: cannot create directory '/../arch': Permission denied Fix it by removing the preceding '/..' which means that it gets generated either in the tools/lib/perf part of the tree or the OUTPUT folder. Some other rules that rely on OUTPUT further refine this conditionally depending on whether it's an in-source or out-of-source build, but I don't think we need the extra complexity here. And this rule is slightly different to others because the header is needed by both libperf and Perf. This is further complicated by the fact that Perf always passes O=... to libperf even for in source builds, meaning that OUTPUT isn't set consistently between projects. Because we're no longer going one level up to try to generate the file in the tools/ folder, Perf's include rule needs to descend into libperf. Also fix the clean rule while we're here. Reported-by: Thorsten Leemhuis <[email protected]> Closes: https://lore.kernel.org/linux-perf-users/[email protected]/ Fixes: bfb713e ("perf tools: Fix arm64 build by generating unistd_64.h") Signed-off-by: James Clark <[email protected]> Tested-by: Thorsten Leemhuis <[email protected]> Link: https://lore.kernel.org/r/20250429-james-perf-fix-libperf-in-source-build-v1-1-a1a827ac15e5@linaro.org Signed-off-by: Namhyung Kim <[email protected]>
1 parent bfb713e commit 8988c4b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tools/lib/perf/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
4242
TEST_ARGS := $(if $(V),-v)
4343

4444
INCLUDES = \
45-
-I$(OUTPUT)/../arch/$(SRCARCH)/include/generated/uapi \
45+
-I$(OUTPUT)arch/$(SRCARCH)/include/generated/uapi \
4646
-I$(srctree)/tools/lib/perf/include \
4747
-I$(srctree)/tools/lib/ \
4848
-I$(srctree)/tools/include \
@@ -100,7 +100,7 @@ $(LIBAPI)-clean:
100100
$(call QUIET_CLEAN, libapi)
101101
$(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
102102

103-
uapi-asm := $(OUTPUT)/../arch/$(SRCARCH)/include/generated/uapi/asm
103+
uapi-asm := $(OUTPUT)arch/$(SRCARCH)/include/generated/uapi/asm
104104
ifeq ($(SRCARCH),arm64)
105105
syscall-y := $(uapi-asm)/unistd_64.h
106106
endif
@@ -130,7 +130,7 @@ all: fixdep
130130
clean: $(LIBAPI)-clean
131131
$(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \
132132
*.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd tests/*.o LIBPERF-CFLAGS $(LIBPERF_PC) \
133-
$(TESTS_STATIC) $(TESTS_SHARED)
133+
$(TESTS_STATIC) $(TESTS_SHARED) $(syscall-y)
134134

135135
TESTS_IN = tests-in.o
136136

tools/perf/Makefile.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ include $(srctree)/tools/scripts/Makefile.arch
2929
$(call detected_var,SRCARCH)
3030

3131
CFLAGS += -I$(OUTPUT)arch/$(SRCARCH)/include/generated
32-
CFLAGS += -I$(OUTPUT)arch/$(SRCARCH)/include/generated/uapi
32+
CFLAGS += -I$(OUTPUT)libperf/arch/$(SRCARCH)/include/generated/uapi
3333

3434
# Additional ARCH settings for ppc
3535
ifeq ($(SRCARCH),powerpc)

0 commit comments

Comments
 (0)