Skip to contentSkip to conversation

libperf build: Always place libperf includes first

PATCH Applied Ian Rogers 2 participants 2 messages Feb 3 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 libperf build: Always place libperf includes first

When building tools/perf the CFLAGS can contain a directory for the installed headers. As the headers may be being installed while building libperf.a this can cause headers to be partially installed and found in the include path while building an object file for libperf.a. The installed header may reference other installed headers that are missing given the partial nature of the install and then the build fails with a missing header file. Avoid this by ensuring the libperf source headers are always first in the CFLAGS.

Fixes 314350491810 ("libperf: Make libperf.a part of the perf build")

---
I started seeing these build failures in build-test post commit c3030995f23b ("perf sched stats: Add record and rawdump support") which increased the number of libperf header files and their dependencies. It isn't correct that this patch fixes that patch, the problem has existed as long as libperf which is why a much earlier commit is in the Fixes tag.

---
 tools/lib/perf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/perf/Makefile +1 -1
index 9692d0742ed0..32301a1d8f0c 100644
@@ -50,9 +50,9 @@ INCLUDES = \
 -I$(srctree)/tools/include/uapi
 
 # Append required CFLAGS
+override CFLAGS := $(INCLUDES) $(CFLAGS)
 override CFLAGS += -g -Werror -Wall
 override CFLAGS += -fPIC
-override CFLAGS += $(INCLUDES)
 override CFLAGS += -fvisibility=hidden
 override CFLAGS += $(EXTRA_WARNINGS)
 override CFLAGS += $(EXTRA_CFLAGS)
Signature · 1 line
2.53.0.rc1.225.gd81095ad13-goog
maintainer Applied
#1 lore raw
Quoted 11 lines · Ian Rogers

When building tools/perf the CFLAGS can contain a directory for the installed headers. As the headers may be being installed while building libperf.a this can cause headers to be partially installed and found in the include path while building an object file for libperf.a. The installed header may reference other installed headers that are missing given the partial nature of the install and then the build fails with a missing header file. Avoid this by ensuring the libperf source headers are always first in the CFLAGS.

Fixes 314350491810 ("libperf: Make libperf.a part of the perf build")

Thanks, applied to perf-tools-next,

- Arnaldo

Quoted 29 lines

---
I started seeing these build failures in build-test post commit c3030995f23b ("perf sched stats: Add record and rawdump support") which increased the number of libperf header files and their dependencies. It isn't correct that this patch fixes that patch, the problem has existed as long as libperf which is why a much earlier commit is in the Fixes tag.

---
 tools/lib/perf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/perf/Makefile +1 -1
index 9692d0742ed0..32301a1d8f0c 100644
@@ -50,9 +50,9 @@ INCLUDES = \
 -I$(srctree)/tools/include/uapi
 
 # Append required CFLAGS
+override CFLAGS := $(INCLUDES) $(CFLAGS)
 override CFLAGS += -g -Werror -Wall
 override CFLAGS += -fPIC
-override CFLAGS += $(INCLUDES)
 override CFLAGS += -fvisibility=hidden
 override CFLAGS += $(EXTRA_WARNINGS)
 override CFLAGS += $(EXTRA_CFLAGS)
Signature · 1 line
2.53.0.rc1.225.gd81095ad13-goog