perf build: build BPF skeletons with fPIC
Subsystems (3)
PATCH 1/1 perf build: build BPF skeletons with fPIC
Fix Makefile.perf to ensure that bpf skeletons are built with fPIC.
When building with BUILD_BPF_SKEL=1, bpf_skel's was not getting built with fPIC, seeing compilation failures like:
/usr/bin/ld: /builddir/.../tools/perf/util/bpf_skel/.tmp/bootstrap/main.o:
relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
Bisected down to 6.18 commit a39516805992 ("tools build: Don't assume libtracefs-devel is always available").
--- tools/perf/Makefile.perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
@@ -1211,7 +1211,7 @@ endif $(BPFTOOL): | $(SKEL_TMP_OUT) $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ - OUTPUT=$(SKEL_TMP_OUT)/ bootstrap + EXTRA_CFLAGS="-fPIC" OUTPUT=$(SKEL_TMP_OUT)/ bootstrap # Paths to search for a kernel to generate vmlinux.h from. VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \
Signature · 1 line
2.43.0
Arnaldo Carvalho de Melo
maintainerQuoted 5 lines · Jon Kohler
Fix Makefile.perf to ensure that bpf skeletons are built with fPIC.
When building with BUILD_BPF_SKEL=1, bpf_skel's was not getting built with fPIC, seeing compilation failures like:
Quoted 8 lines
/usr/bin/ld: /builddir/.../tools/perf/util/bpf_skel/.tmp/bootstrap/main.o:
relocationR_X86_64_32against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIEBisected down to 6.18 commit
a39516805992("tools build: Don't assume libtracefs-devel is always available").Fixes a39516805992 ("tools build: Don't assume libtracefs-devel is always available")
How come, this patch is just:
tools/build/Makefile.feature +0 -1
@@ -83,7 +83,6 @@ FEATURE_TESTS_BASIC := \ libpython \ libslang \ libtraceevent \ - libtracefs \ libcpupower \ pthread-attr-setaffinity-np \ pthread-barrier \
tools/build/feature/test-all.c +0 -5
@@ -150,10 +150,6 @@# include "test-libtraceevent.c" #undef main -#define main main_test_libtracefs -# include "test-libtracefs.c" -#undef main -int main (int argc,char *argv[]) {main_test_libpython ();
@@ -187,7 +183,6 @@ int main(int argc, char *argv[])main_test_reallocarray ();main_test_libzstd ();main_test_libtraceevent (); -main_test_libtracefs ();return 0 ;
}
----
And your patch is touching building bpftool? Seems very unrelated :-\
- Arnaldo
Quoted 21 lines
Signed-off-by Jon Kohler <[email protected]>--- tools/perf/Makefile.perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/Makefile.perf +1
-1@@ -1211,7 +1211,7 @@ endif $(BPFTOOL): | $(SKEL_TMP_OUT) $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ - OUTPUT=$(SKEL_TMP_OUT)/ bootstrap + EXTRA_CFLAGS="-fPIC" OUTPUT=$(SKEL_TMP_OUT)/ bootstrap # Paths to search for a kernel to generate vmlinux.h from. VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \Signature · 1 line
2.43.0
Quoted 14 lines · Arnaldo Carvalho de Melo
Quoted 9 lines · Jon Kohler
Fix Makefile.perf to ensure that bpf skeletons are built with fPIC.
When building with BUILD_BPF_SKEL=1, bpf_skel's was not getting built with fPIC, seeing compilation failures like:
/usr/bin/ld: /builddir/.../tools/perf/util/bpf_skel/.tmp/bootstrap/main.o:
relocationR_X86_64_32against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
Quoted 6 lines
Quoted 4 lines
Bisected down to 6.18 commit
a39516805992("tools build: Don't assume libtracefs-devel is always available").Fixes a39516805992 ("tools build: Don't assume libtracefs-devel is always available")How come, this patch is just:
It doesn’t make sense to me, but I checked the results of the bisection by hand and, hand-to-god, reverting commit a39516805992 unbreaks our build every single time. Putting a39516805992 back breaks our build 100% of the time.
Quoted 65 lines
tools/build/Makefile.feature +0
-1@@ -83,7 +83,6 @@ FEATURE_TESTS_BASIC := \ libpython \ libslang \ libtraceevent \ - libtracefs \ libcpupower \ pthread-attr-setaffinity-np \ pthread-barrier \tools/build/feature/test-all.c +0
-6@@ -150,10 +150,6 @@# include "test-libtraceevent.c" #undef main -#define main main_test_libtracefs -# include "test-libtracefs.c" -#undef main -int main (int argc,char *argv[]) {main_test_libpython ();@@ -187,7 +183,6 @@ int main(int argc, char *argv[])main_test_reallocarray ();main_test_libzstd ();main_test_libtraceevent (); -main_test_libtracefs ();return 0 ; } ----And your patch is touching building bpftool? Seems very unrelated :-\
- Arnaldo
Quoted 21 lines
Signed-off-by Jon Kohler <[email protected]>---
tools/perf/Makefile.perf| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/Makefile.perf +1
-1@@ -1211,7 +1211,7 @@ endif $(BPFTOOL): | $(SKEL_TMP_OUT) $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ - OUTPUT=$(SKEL_TMP_OUT)/ bootstrap + EXTRA_CFLAGS="-fPIC" OUTPUT=$(SKEL_TMP_OUT)/ bootstrap # Paths to search for a kernel to generate vmlinux.h from. VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \Signature · 1 line
2.43.0