Skip to content

Commit

Permalink
perf tools: Fix in-source libperf build
Browse files Browse the repository at this point in the history
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 <linux@leemhuis.info>
Closes: https://lore.kernel.org/linux-perf-users/7703f88e-ccb7-4c98-9da4-8aad224e780f@leemhuis.info/
Fixes: bfb713e ("perf tools: Fix arm64 build by generating unistd_64.h")
Signed-off-by: James Clark <james.clark@linaro.org>
Tested-by: Thorsten Leemhuis <linux@leemhuis.info>
Link: https://lore.kernel.org/r/20250429-james-perf-fix-libperf-in-source-build-v1-1-a1a827ac15e5@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
  • Loading branch information
James Clark authored and Namhyung Kim committed Apr 29, 2025
1 parent bfb713e commit 8988c4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tools/lib/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
TEST_ARGS := $(if $(V),-v)

INCLUDES = \
-I$(OUTPUT)/../arch/$(SRCARCH)/include/generated/uapi \
-I$(OUTPUT)arch/$(SRCARCH)/include/generated/uapi \
-I$(srctree)/tools/lib/perf/include \
-I$(srctree)/tools/lib/ \
-I$(srctree)/tools/include \
Expand Down Expand Up @@ -100,7 +100,7 @@ $(LIBAPI)-clean:
$(call QUIET_CLEAN, libapi)
$(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null

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

TESTS_IN = tests-in.o

Expand Down
2 changes: 1 addition & 1 deletion tools/perf/Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include $(srctree)/tools/scripts/Makefile.arch
$(call detected_var,SRCARCH)

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

# Additional ARCH settings for ppc
ifeq ($(SRCARCH),powerpc)
Expand Down

0 comments on commit 8988c4b

Please sign in to comment.