linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 00/13] Perf tool build improvements
@ 2023-03-11  6:57 Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 01/13] perf build: Support python/perf.so testing Ian Rogers
                   ` (13 more replies)
  0 siblings, 14 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

Make the default build options a more preferred set, such as making
BPF skeletons default and failing the build if jevents or libtracevent
dependencies fail. The binutil dependencies are opt-in given license
restrictions. abi::__cxa_demangle demangling support is added so that
libiberty, from binutils, isn't necessary for C++ demangling.

Some build/test dependencies are fixed and the code cleaned up.

Ian Rogers (13):
  perf build: Support python/perf.so testing
  perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
  perf build: Remove unused HAVE_GLIBC_SUPPORT
  perf build: Error if no libelf and NO_LIBELF isn't set
  perf util: Remove weak sched_getcpu
  perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set
  perf build: Make binutil libraries opt in
  tools build: Add feature test for abi::__cxa_demangle
  perf symbol: Add abi::__cxa_demangle C++ demangling support
  perf build: Switch libpfm4 to opt-out rather than opt-in
  perf build: If libtraceevent isn't present error the build
  tools headers: Make the difference output easier to read
  perf build: Remove redundant NO_NEWT build option

 tools/build/Makefile.feature              |   1 +
 tools/build/feature/Makefile              |   4 +
 tools/build/feature/test-cxa-demangle.cpp |  17 ++
 tools/perf/Makefile.config                |  84 +++-----
 tools/perf/Makefile.perf                  |  21 +-
 tools/perf/builtin-lock.c                 |   2 +-
 tools/perf/builtin-record.c               |   2 +-
 tools/perf/builtin-version.c              |   2 +-
 tools/perf/check-headers.sh               | 229 ++++++++++++----------
 tools/perf/tests/make                     |  17 +-
 tools/perf/tests/shell/record_offcpu.sh   |   2 +-
 tools/perf/util/Build                     |   1 +
 tools/perf/util/cloexec.c                 |  13 --
 tools/perf/util/demangle-cxx.cpp          |  50 +++++
 tools/perf/util/demangle-cxx.h            |  16 ++
 tools/perf/util/symbol-elf.c              |  37 +---
 tools/perf/util/util.c                    |  16 ++
 17 files changed, 294 insertions(+), 220 deletions(-)
 create mode 100644 tools/build/feature/test-cxa-demangle.cpp
 create mode 100644 tools/perf/util/demangle-cxx.cpp
 create mode 100644 tools/perf/util/demangle-cxx.h

-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v1 01/13] perf build: Support python/perf.so testing
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL Ian Rogers
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

Add a build target to echo the python/perf.so's name from
Makefile.perf. Use it in tests/make so the correct target is built and
tested for.

Fixes: caec54705adb ("perf build: Fix python/perf.so library's name")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.perf | 7 +++++--
 tools/perf/tests/make    | 5 +++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index bac9272682b7..2fcee585b225 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -647,13 +647,16 @@ all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
 # Create python binding output directory if not already present
 _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
 
-$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBPERF)
+$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBPERF) $(LIBSUBCMD)
 	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
         CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' \
 	  $(PYTHON_WORD) util/setup.py \
 	  --quiet build_ext; \
 	cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/
 
+python_perf_target:
+	@echo "Target is: $(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX)"
+
 please_set_SHELL_PATH_to_a_more_modern_shell:
 	$(Q)$$(:)
 
@@ -1152,7 +1155,7 @@ FORCE:
 .PHONY: all install clean config-clean strip install-gtk
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
 .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare
-.PHONY: archheaders
+.PHONY: archheaders python_perf_target
 
 endif # force_fixdep
 
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 009d6efb673c..deb37fb982e9 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -62,10 +62,11 @@ lib = lib
 endif
 
 has = $(shell which $1 2>/dev/null)
+python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{print $$3}')
 
 # standard single make variable specified
 make_clean_all      := clean all
-make_python_perf_so := python/perf.so
+make_python_perf_so := $(python_perf_so)
 make_debug          := DEBUG=1
 make_no_libperl     := NO_LIBPERL=1
 make_no_libpython   := NO_LIBPYTHON=1
@@ -204,7 +205,7 @@ test_make_doc    := $(test_ok)
 test_make_help_O := $(test_ok)
 test_make_doc_O  := $(test_ok)
 
-test_make_python_perf_so := test -f $(PERF_O)/python/perf.so
+test_make_python_perf_so := test -f $(PERF_O)/$(python_perf_so)
 
 test_make_perf_o           := test -f $(PERF_O)/perf.o
 test_make_util_map_o       := test -f $(PERF_O)/util/map.o
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 01/13] perf build: Support python/perf.so testing Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-13 20:19   ` Arnaldo Carvalho de Melo
  2023-03-11  6:57 ` [PATCH v1 03/13] perf build: Remove unused HAVE_GLIBC_SUPPORT Ian Rogers
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

BPF skeleton support is now key to a number of perf features. Rather
than making it so that BPF support must be enabled for the build, make
this the default and error if the build lacks a clang and libbpf that
are sufficient. To avoid the error and build without BPF skeletons the
NO_BPF_SKEL=1 flag can be used. Add a build-options flag to 'perf
version' to enable detection of the BPF skeleton support and use this
in the offcpu shell test.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config              | 19 ++++++++++++-------
 tools/perf/Makefile.perf                |  8 ++++----
 tools/perf/builtin-lock.c               |  2 +-
 tools/perf/builtin-record.c             |  2 +-
 tools/perf/builtin-version.c            |  1 +
 tools/perf/tests/shell/record_offcpu.sh |  2 +-
 6 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 5f11834f189e..33d62d542fd5 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -415,6 +415,7 @@ ifdef NO_LIBELF
   NO_LIBUNWIND := 1
   NO_LIBDW_DWARF_UNWIND := 1
   NO_LIBBPF := 1
+  NO_BPF_SKEL := 1
   NO_JVMTI := 1
 else
   ifeq ($(feature-libelf), 0)
@@ -662,18 +663,22 @@ ifndef NO_LIBBPF
     msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
     NO_LIBBPF := 1
   endif
+else
+  NO_BPF_SKEL := 1
 endif
 
-ifdef BUILD_BPF_SKEL
+ifndef NO_BPF_SKEL
   $(call feature_check,clang-bpf-co-re)
   ifeq ($(feature-clang-bpf-co-re), 0)
-    dummy := $(error Error: clang too old/not installed. Please install recent clang to build with BUILD_BPF_SKEL)
-  endif
-  ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)
-    dummy := $(error Error: BPF skeleton support requires libbpf)
+    dummy := $(error: ERROR: BPF skeletons unsupported. clang too old/not installed or build with NO_BPF_SKEL=1.)
+  else
+    ifeq ($(filter -DHAVE_LIBBPF_SUPPORT, $(CFLAGS)),)
+      dummy := $(error: ERROR: BPF skeletons unsupported. BPF skeleton support requires libbpf or build with NO_BPF_SKEL=1.)
+    else
+      $(call detected,CONFIG_PERF_BPF_SKEL)
+      CFLAGS += -DHAVE_BPF_SKEL
+    endif
   endif
-  $(call detected,CONFIG_PERF_BPF_SKEL)
-  CFLAGS += -DHAVE_BPF_SKEL
 endif
 
 dwarf-post-unwind := 1
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 2fcee585b225..283ee4f56234 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -126,7 +126,7 @@ include ../scripts/utilities.mak
 #
 # Define NO_LIBDEBUGINFOD if you do not want support debuginfod
 #
-# Define BUILD_BPF_SKEL to enable BPF skeletons
+# Define NO_BPF_SKEL to disable BPF skeletons
 #
 
 # As per kernel Makefile, avoid funny character set dependencies
@@ -1055,7 +1055,7 @@ SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h
 $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT):
 	$(Q)$(MKDIR) -p $@
 
-ifdef BUILD_BPF_SKEL
+ifndef NO_BPF_SKEL
 BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool
 BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE)
 
@@ -1088,11 +1088,11 @@ bpf-skel: $(SKELETONS)
 
 .PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o
 
-else # BUILD_BPF_SKEL
+else # NO_BPF_SKEL
 
 bpf-skel:
 
-endif # BUILD_BPF_SKEL
+endif # NO_BPF_SKEL
 
 bpf-skel-clean:
 	$(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 054997edd98b..240d49a85524 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -2371,7 +2371,7 @@ int cmd_lock(int argc, const char **argv)
 
 #ifndef HAVE_BPF_SKEL
 		set_option_nobuild(contention_options, 'b', "use-bpf",
-				   "no BUILD_BPF_SKEL=1", false);
+				   "NO_BPF_SKEL=1", false);
 #endif
 		if (argc) {
 			argc = parse_options(argc, argv, contention_options,
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 8374117e66f6..495627437f97 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -3971,7 +3971,7 @@ int cmd_record(int argc, const char **argv)
 
 #ifndef HAVE_BPF_SKEL
 # define set_nobuild(s, l, m, c) set_option_nobuild(record_options, s, l, m, c)
-	set_nobuild('\0', "off-cpu", "no BUILD_BPF_SKEL=1", true);
+	set_nobuild('\0', "off-cpu", "NO_BPF_SKEL=1", true);
 # undef set_nobuild
 #endif
 
diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index a886929ec6e5..0d9cda238c07 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -83,6 +83,7 @@ static void library_status(void)
 	STATUS(HAVE_ZSTD_SUPPORT, zstd);
 	STATUS(HAVE_LIBPFM, libpfm4);
 	STATUS(HAVE_LIBTRACEEVENT, libtraceevent);
+	STATUS(HAVE_BPF_SKEL, BPF skeletons);
 }
 
 int cmd_version(int argc, const char **argv)
diff --git a/tools/perf/tests/shell/record_offcpu.sh b/tools/perf/tests/shell/record_offcpu.sh
index e01973d4e0fb..24f81ff85793 100755
--- a/tools/perf/tests/shell/record_offcpu.sh
+++ b/tools/perf/tests/shell/record_offcpu.sh
@@ -28,7 +28,7 @@ test_offcpu_priv() {
     err=2
     return
   fi
-  if perf record --off-cpu -o /dev/null --quiet true 2>&1 | grep BUILD_BPF_SKEL
+  if perf version --build-options 2>&1 | grep HAVE_BPF_SKEL | grep -q OFF
   then
     echo "off-cpu test [Skipped missing BPF support]"
     err=2
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 03/13] perf build: Remove unused HAVE_GLIBC_SUPPORT
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 01/13] perf build: Support python/perf.so testing Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set Ian Rogers
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

HAVE_GLIBC_SUPPORT is only used in `perf version --build-options` but
doesn't control any behavior. Remove from the build to simplify it.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config   | 4 ----
 tools/perf/builtin-version.c | 1 -
 2 files changed, 5 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 33d62d542fd5..a68a3e9b47ae 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -476,10 +476,6 @@ else
   endif # libelf support
 endif # NO_LIBELF
 
-ifeq ($(feature-glibc), 1)
-  CFLAGS += -DHAVE_GLIBC_SUPPORT
-endif
-
 ifeq ($(feature-libaio), 1)
   ifndef NO_AIO
     CFLAGS += -DHAVE_AIO_SUPPORT
diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 0d9cda238c07..c5d03a11e565 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -59,7 +59,6 @@ static void library_status(void)
 {
 	STATUS(HAVE_DWARF_SUPPORT, dwarf);
 	STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
-	STATUS(HAVE_GLIBC_SUPPORT, glibc);
 #ifndef HAVE_SYSCALL_TABLE_SUPPORT
 	STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
 #endif
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (2 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 03/13] perf build: Remove unused HAVE_GLIBC_SUPPORT Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-13 19:45   ` Arnaldo Carvalho de Melo
  2023-03-11  6:57 ` [PATCH v1 05/13] perf util: Remove weak sched_getcpu Ian Rogers
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

Building without libelf support is going disable a lot of
functionality. Require that the NO_LIBELF=1 build option is passed if
this is intentional.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index a68a3e9b47ae..5691e2ffb1b9 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -426,15 +426,7 @@ else
       LIBC_SUPPORT := 1
     endif
     ifeq ($(LIBC_SUPPORT),1)
-      msg := $(warning No libelf found. Disables 'probe' tool, jvmti and BPF support in 'perf record'. Please install libelf-dev, libelf-devel or elfutils-libelf-devel);
-
-      NO_LIBELF := 1
-      NO_DWARF := 1
-      NO_DEMANGLE := 1
-      NO_LIBUNWIND := 1
-      NO_LIBDW_DWARF_UNWIND := 1
-      NO_LIBBPF := 1
-      NO_JVMTI := 1
+      msg := $(error ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1.)
     else
       ifneq ($(filter s% -fsanitize=address%,$(EXTRA_CFLAGS),),)
         ifneq ($(shell ldconfig -p | grep libasan >/dev/null 2>&1; echo $$?), 0)
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 05/13] perf util: Remove weak sched_getcpu
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (3 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 06/13] perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set Ian Rogers
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

sched_getcpu may not be present and so a feature test and definition
exist to workaround this in the build. The feature test is used to
define HAVE_SCHED_GETCPU_SUPPORT and so this is sufficient to know
whether the local sched_getcpu is needed and a weak symbol can be
avoided.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/cloexec.c | 13 -------------
 tools/perf/util/util.c    | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
index fa8248aadb59..8830604c3a8d 100644
--- a/tools/perf/util/cloexec.c
+++ b/tools/perf/util/cloexec.c
@@ -13,19 +13,6 @@
 
 static unsigned long flag = PERF_FLAG_FD_CLOEXEC;
 
-int __weak sched_getcpu(void)
-{
-#ifdef __NR_getcpu
-	unsigned cpu;
-	int err = syscall(__NR_getcpu, &cpu, NULL, NULL);
-	if (!err)
-		return cpu;
-#else
-	errno = ENOSYS;
-#endif
-	return -1;
-}
-
 static int perf_flag_probe(void)
 {
 	/* use 'safest' configuration as used in evsel__fallback() */
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 391c1e928bd7..b356c9f7f0c3 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -533,3 +533,19 @@ int do_realloc_array_as_needed(void **arr, size_t *arr_sz, size_t x, size_t msz,
 	*arr_sz = new_sz;
 	return 0;
 }
+
+#ifndef HAVE_SCHED_GETCPU_SUPPORT
+int sched_getcpu(void)
+{
+#ifdef __NR_getcpu
+	unsigned int cpu;
+	int err = syscall(__NR_getcpu, &cpu, NULL, NULL);
+
+	if (!err)
+		return cpu;
+#else
+	errno = ENOSYS;
+#endif
+	return -1;
+}
+#endif
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 06/13] perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (4 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 05/13] perf util: Remove weak sched_getcpu Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 07/13] perf build: Make binutil libraries opt in Ian Rogers
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

Rather than disabling jevents if a sufficient python isn't present
error in the build. This avoids the build progressing but the binary
being degraded. The build can still succeed by specifying NO_JEVENTS=1
to the build and this is conveyed in the error message.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 5691e2ffb1b9..2557654d8e29 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -872,14 +872,12 @@ endif
 ifneq ($(NO_JEVENTS),1)
   NO_JEVENTS := 0
   ifndef PYTHON
-    $(warning No python interpreter disabling jevent generation)
-    NO_JEVENTS := 1
+    $(error ERROR: No python interpreter needed for jevents generation. Install python or build with NO_JEVENTS=1.)
   else
     # jevents.py uses f-strings present in Python 3.6 released in Dec. 2016.
     JEVENTS_PYTHON_GOOD := $(shell $(PYTHON) -c 'import sys;print("1" if(sys.version_info.major >= 3 and sys.version_info.minor >= 6) else "0")' 2> /dev/null)
     ifneq ($(JEVENTS_PYTHON_GOOD), 1)
-      $(warning Python interpreter too old (older than 3.6) disabling jevent generation)
-      NO_JEVENTS := 1
+      $(error ERROR: Python interpreter needed for jevents generation too old (older than 3.6). Install a newer python or build with NO_JEVENTS=1.)
     endif
   endif
 endif
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 07/13] perf build: Make binutil libraries opt in
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (5 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 06/13] perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-13 19:37   ` Arnaldo Carvalho de Melo
  2023-03-11  6:57 ` [PATCH v1 08/13] tools build: Add feature test for abi::__cxa_demangle Ian Rogers
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

binutils is GPLv3 so distributions cannot ship perf linked against
libbfd and libiberty as the licenses are incompatible. Rather than
defaulting the build to opting in to libbfd and libiberty support and
opting out via NO_LIBBFD=1 and NO_DEMANGLE=1, make building against
the libraries optional and enabled with BUILD_NONDISTRO=1.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config | 25 ++++++++++---------------
 tools/perf/Makefile.perf   |  2 ++
 tools/perf/tests/make      |  2 ++
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 2557654d8e29..5756498248e0 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -882,7 +882,7 @@ ifneq ($(NO_JEVENTS),1)
   endif
 endif
 
-ifndef NO_LIBBFD
+ifdef BUILD_NONDISTRO
   ifeq ($(feature-libbfd), 1)
     EXTLIBS += -lbfd -lopcodes
   else
@@ -905,6 +905,7 @@ ifndef NO_LIBBFD
     $(call feature_check,disassembler-init-styled)
   endif
 
+  CFLAGS += -DHAVE_LIBBFD_SUPPORT
   ifeq ($(feature-libbfd-buildid), 1)
     CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
   else
@@ -915,32 +916,26 @@ endif
 ifdef NO_DEMANGLE
   CFLAGS += -DNO_DEMANGLE
 else
-  ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
-    EXTLIBS += -liberty
-  else
+  ifdef BUILD_NONDISTRO
     ifeq ($(filter -liberty,$(EXTLIBS)),)
-      $(call feature_check,cplus-demangle)
-
-      # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
-      # or any of 'bfd iberty z' trinity
-      ifeq ($(feature-cplus-demangle), 1)
+      ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
         EXTLIBS += -liberty
       else
-        msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
-        CFLAGS += -DNO_DEMANGLE
+        $(call feature_check,cplus-demangle)
+        ifeq ($(feature-cplus-demangle), 1)
+          EXTLIBS += -liberty
+        endif
       endif
     endif
   endif
 
   ifneq ($(filter -liberty,$(EXTLIBS)),)
     CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
+  else
+    CFLAGS += -DNO_DEMANGLE
   endif
 endif
 
-ifneq ($(filter -lbfd,$(EXTLIBS)),)
-  CFLAGS += -DHAVE_LIBBFD_SUPPORT
-endif
-
 ifndef NO_ZLIB
   ifeq ($(feature-zlib), 1)
     CFLAGS += -DHAVE_ZLIB_SUPPORT
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 283ee4f56234..a35bc995d5d8 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -128,6 +128,8 @@ include ../scripts/utilities.mak
 #
 # Define NO_BPF_SKEL to disable BPF skeletons
 #
+# Define BUILD_NONDISTRO to enable building an linking against libbfd and
+# libiberty distribution license incompatible libraries.
 
 # As per kernel Makefile, avoid funny character set dependencies
 unexport LC_ALL
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index deb37fb982e9..c2f74ed43418 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -68,6 +68,7 @@ python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{pri
 make_clean_all      := clean all
 make_python_perf_so := $(python_perf_so)
 make_debug          := DEBUG=1
+make_nondistro      := BUILD_NONDISTRO=1
 make_no_libperl     := NO_LIBPERL=1
 make_no_libpython   := NO_LIBPYTHON=1
 make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
@@ -134,6 +135,7 @@ MAKE_F := $(MAKE) -f $(MK)
 endif
 run += make_python_perf_so
 run += make_debug
+run += make_nondistro
 run += make_no_libperl
 run += make_no_libpython
 run += make_no_scripts
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 08/13] tools build: Add feature test for abi::__cxa_demangle
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (6 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 07/13] perf build: Make binutil libraries opt in Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support Ian Rogers
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

cxxabi.h is part of libsdtc++ and LLVM's libcxx, providing
abi::__cxa_demangle a portable C++ demangler. Add a feature test to
detect that the function is available.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/build/Makefile.feature              |  1 +
 tools/build/feature/Makefile              |  4 ++++
 tools/build/feature/test-cxa-demangle.cpp | 17 +++++++++++++++++
 3 files changed, 22 insertions(+)
 create mode 100644 tools/build/feature/test-cxa-demangle.cpp

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 38f8851bd7cb..214622d7537c 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -80,6 +80,7 @@ FEATURE_TESTS_EXTRA :=                  \
          compile-32                     \
          compile-x32                    \
          cplus-demangle                 \
+         cxa-demangle                   \
          gtk2                           \
          gtk2-infobar                   \
          hello                          \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index dc9323e01e42..0a3b9281f8b0 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -23,6 +23,7 @@ FILES=                                          \
          test-libbfd-liberty.bin                \
          test-libbfd-liberty-z.bin              \
          test-cplus-demangle.bin                \
+         test-cxa-demangle.bin                  \
          test-libcap.bin			\
          test-libelf.bin                        \
          test-libelf-getphdrnum.bin             \
@@ -262,6 +263,9 @@ $(OUTPUT)test-libbfd-liberty-z.bin:
 $(OUTPUT)test-cplus-demangle.bin:
 	$(BUILD) -liberty
 
+$(OUTPUT)test-cxa-demangle.bin:
+	$(BUILDXX)
+
 $(OUTPUT)test-backtrace.bin:
 	$(BUILD)
 
diff --git a/tools/build/feature/test-cxa-demangle.cpp b/tools/build/feature/test-cxa-demangle.cpp
new file mode 100644
index 000000000000..a3e712f65c37
--- /dev/null
+++ b/tools/build/feature/test-cxa-demangle.cpp
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <stdio.h>
+#include <stdlib.h>
+#include <cxxabi.h>
+
+int main(void)
+{
+  size_t len = 256;
+  char *output = (char*)malloc(len);
+        int status;
+
+        output = abi::__cxa_demangle("FieldName__9ClassNameFd", output, &len, &status);
+
+        printf("demangled symbol: {%s}\n", output);
+
+        return 0;
+}
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (7 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 08/13] tools build: Add feature test for abi::__cxa_demangle Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-30 14:08   ` James Clark
  2023-03-11  6:57 ` [PATCH v1 10/13] perf build: Switch libpfm4 to opt-out rather than opt-in Ian Rogers
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

Refactor C++ demangling out of symbol-elf into its own files similar
to other languages. Add abi::__cxa_demangle support. As the other
demanglers are not shippable with distributions, this brings back C++
demangling in a common case. It isn't perfect as the support for
optionally demangling arguments and modifiers isn't present.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config       | 29 +++++++++---------
 tools/perf/util/Build            |  1 +
 tools/perf/util/demangle-cxx.cpp | 50 ++++++++++++++++++++++++++++++++
 tools/perf/util/demangle-cxx.h   | 16 ++++++++++
 tools/perf/util/symbol-elf.c     | 37 +++++------------------
 5 files changed, 88 insertions(+), 45 deletions(-)
 create mode 100644 tools/perf/util/demangle-cxx.cpp
 create mode 100644 tools/perf/util/demangle-cxx.h

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 5756498248e0..fdeca45cf15f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -906,6 +906,7 @@ ifdef BUILD_NONDISTRO
   endif
 
   CFLAGS += -DHAVE_LIBBFD_SUPPORT
+  CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
   ifeq ($(feature-libbfd-buildid), 1)
     CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
   else
@@ -913,26 +914,24 @@ ifdef BUILD_NONDISTRO
   endif
 endif
 
-ifdef NO_DEMANGLE
-  CFLAGS += -DNO_DEMANGLE
-else
+ifndef NO_DEMANGLE
+  $(call feature_check,cxa-demangle)
+  ifeq ($(feature-cxa-demangle), 1)
+    EXTLIBS += -lstdc++
+    CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
+    CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
+  endif
   ifdef BUILD_NONDISTRO
     ifeq ($(filter -liberty,$(EXTLIBS)),)
-      ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
+      $(call feature_check,cplus-demangle)
+      ifeq ($(feature-cplus-demangle), 1)
         EXTLIBS += -liberty
-      else
-        $(call feature_check,cplus-demangle)
-        ifeq ($(feature-cplus-demangle), 1)
-          EXTLIBS += -liberty
-        endif
       endif
     endif
-  endif
-
-  ifneq ($(filter -liberty,$(EXTLIBS)),)
-    CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
-  else
-    CFLAGS += -DNO_DEMANGLE
+    ifneq ($(filter -liberty,$(EXTLIBS)),)
+      CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
+      CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
+    endif
   endif
 endif
 
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 918b501f9bd8..8607575183a9 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -211,6 +211,7 @@ perf-$(CONFIG_ZSTD) += zstd.o
 
 perf-$(CONFIG_LIBCAP) += cap.o
 
+perf-y += demangle-cxx.o
 perf-y += demangle-ocaml.o
 perf-y += demangle-java.o
 perf-y += demangle-rust.o
diff --git a/tools/perf/util/demangle-cxx.cpp b/tools/perf/util/demangle-cxx.cpp
new file mode 100644
index 000000000000..8708bcafd370
--- /dev/null
+++ b/tools/perf/util/demangle-cxx.cpp
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "demangle-cxx.h"
+#include <stdlib.h>
+#include <string.h>
+#include <linux/compiler.h>
+
+#ifdef HAVE_LIBBFD_SUPPORT
+#define PACKAGE 'perf'
+#include <bfd.h>
+#endif
+
+#ifdef HAVE_CXA_DEMANGLE_SUPPORT
+#include <cxxabi.h>
+#endif
+
+#if defined(HAVE_LIBBFD_SUPPORT) || defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
+#ifndef DMGL_PARAMS
+#define DMGL_PARAMS     (1 << 0)  /* Include function args */
+#define DMGL_ANSI       (1 << 1)  /* Include const, volatile, etc */
+#endif
+#endif
+
+/*
+ * Demangle C++ function signature
+ *
+ * Note: caller is responsible for freeing demangled string
+ */
+extern "C"
+char *cxx_demangle_sym(const char *str, bool params __maybe_unused,
+                       bool modifiers __maybe_unused)
+{
+#ifdef HAVE_LIBBFD_SUPPORT
+        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
+
+        return bfd_demangle(NULL, str, flags);
+#elif defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
+        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
+
+        return cplus_demangle(str, flags);
+#elif defined(HAVE_CXA_DEMANGLE_SUPPORT)
+        size_t len = strlen(str);
+        char *output = (char*)malloc(len);
+        int status;
+
+        output = abi::__cxa_demangle(str, output, &len, &status);
+        return output;
+#else
+        return NULL;
+#endif
+}
diff --git a/tools/perf/util/demangle-cxx.h b/tools/perf/util/demangle-cxx.h
new file mode 100644
index 000000000000..26b5b66c0b4e
--- /dev/null
+++ b/tools/perf/util/demangle-cxx.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PERF_DEMANGLE_CXX
+#define __PERF_DEMANGLE_CXX 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *cxx_demangle_sym(const char *str, bool params, bool modifiers);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __PERF_DEMANGLE_CXX */
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 41882ae8452e..c0a2de42c51b 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -12,6 +12,7 @@
 #include "maps.h"
 #include "symbol.h"
 #include "symsrc.h"
+#include "demangle-cxx.h"
 #include "demangle-ocaml.h"
 #include "demangle-java.h"
 #include "demangle-rust.h"
@@ -25,6 +26,11 @@
 #include <symbol/kallsyms.h>
 #include <internal/lib.h>
 
+#ifdef HAVE_LIBBFD_SUPPORT
+#define PACKAGE 'perf'
+#include <bfd.h>
+#endif
+
 #ifndef EM_AARCH64
 #define EM_AARCH64	183  /* ARM 64 bit */
 #endif
@@ -45,34 +51,6 @@
 
 typedef Elf64_Nhdr GElf_Nhdr;
 
-#ifndef DMGL_PARAMS
-#define DMGL_NO_OPTS     0              /* For readability... */
-#define DMGL_PARAMS      (1 << 0)       /* Include function args */
-#define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
-#endif
-
-#ifdef HAVE_LIBBFD_SUPPORT
-#define PACKAGE 'perf'
-#include <bfd.h>
-#else
-#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
-extern char *cplus_demangle(const char *, int);
-
-static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
-{
-	return cplus_demangle(c, i);
-}
-#else
-#ifdef NO_DEMANGLE
-static inline char *bfd_demangle(void __maybe_unused *v,
-				 const char __maybe_unused *c,
-				 int __maybe_unused i)
-{
-	return NULL;
-}
-#endif
-#endif
-#endif
 
 #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
 static int elf_getphdrnum(Elf *elf, size_t *dst)
@@ -295,7 +273,6 @@ static bool want_demangle(bool is_kernel_sym)
 
 static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
 {
-	int demangle_flags = verbose > 0 ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
 	char *demangled = NULL;
 
 	/*
@@ -306,7 +283,7 @@ static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
 	if (!want_demangle(dso->kernel || kmodule))
 	    return demangled;
 
-	demangled = bfd_demangle(NULL, elf_name, demangle_flags);
+	demangled = cxx_demangle_sym(elf_name, verbose > 0, verbose > 0);
 	if (demangled == NULL) {
 		demangled = ocaml_demangle_sym(elf_name);
 		if (demangled == NULL) {
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 10/13] perf build: Switch libpfm4 to opt-out rather than opt-in
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (8 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 11/13] perf build: If libtraceevent isn't present error the build Ian Rogers
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

If libpfm4 passes the feature test, it would be nice to have it
enabled rather than also requiring the LIBPFM4=1 build flag.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config | 3 +--
 tools/perf/Makefile.perf   | 2 +-
 tools/perf/tests/make      | 4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index fdeca45cf15f..9754218bd418 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -1130,7 +1130,7 @@ ifdef LIBCLANGLLVM
   endif
 endif
 
-ifdef LIBPFM4
+ifndef NO_LIBPFM4
   $(call feature_check,libpfm4)
   ifeq ($(feature-libpfm4), 1)
     CFLAGS += -DHAVE_LIBPFM
@@ -1139,7 +1139,6 @@ ifdef LIBPFM4
     $(call detected,CONFIG_LIBPFM4)
   else
     msg := $(warning libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev);
-    NO_LIBPFM4 := 1
   endif
 endif
 
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index a35bc995d5d8..3e06915f6bd0 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -122,7 +122,7 @@ include ../scripts/utilities.mak
 # generated from the kernel .tbl or unistd.h files and use, if available, libaudit
 # for doing the conversions to/from strings/id.
 #
-# Define LIBPFM4 to enable libpfm4 events extension.
+# Define NO_LIBPFM4 to disable libpfm4 events extension.
 #
 # Define NO_LIBDEBUGINFOD if you do not want support debuginfod
 #
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index c2f74ed43418..47c665659022 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -94,7 +94,7 @@ make_with_coresight := CORESIGHT=1
 make_no_sdt	    := NO_SDT=1
 make_no_syscall_tbl := NO_SYSCALL_TABLE=1
 make_with_clangllvm := LIBCLANGLLVM=1
-make_with_libpfm4   := LIBPFM4=1
+make_no_libpfm4     := NO_LIBPFM4=1
 make_with_gtk2      := GTK2=1
 make_tags           := tags
 make_cscope         := cscope
@@ -161,7 +161,7 @@ run += make_no_syscall_tbl
 run += make_with_babeltrace
 run += make_with_coresight
 run += make_with_clangllvm
-run += make_with_libpfm4
+run += make_no_libpfm4
 run += make_help
 run += make_doc
 run += make_perf_o
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 11/13] perf build: If libtraceevent isn't present error the build
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (9 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 10/13] perf build: Switch libpfm4 to opt-out rather than opt-in Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-11  6:57 ` [PATCH v1 12/13] tools headers: Make the difference output easier to read Ian Rogers
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

If libtraceevent isn't present, the build will warn and continue. This
disables a number of features and so isn't desirable. This change
makes the build error for this case. The build can still be made to
happen by adding NO_LIBTRACEEVENT=1.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 9754218bd418..1b598c5e68eb 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -1156,7 +1156,7 @@ ifneq ($(NO_LIBTRACEEVENT),1)
     CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP)
     $(call detected,CONFIG_LIBTRACEEVENT)
   else
-    dummy := $(warning Warning: libtraceevent is missing limiting functionality, please install libtraceevent-dev/libtraceevent-devel)
+    dummy := $(error ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel or build with NO_LIBTRACEEVENT=1)
   endif
 
   $(call feature_check,libtracefs)
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 12/13] tools headers: Make the difference output easier to read
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (10 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 11/13] perf build: If libtraceevent isn't present error the build Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-13 19:35   ` Arnaldo Carvalho de Melo
  2023-03-11  6:57 ` [PATCH v1 13/13] perf build: Remove redundant NO_NEWT build option Ian Rogers
  2023-03-14 12:11 ` [PATCH v1 00/13] Perf tool build improvements Arnaldo Carvalho de Melo
  13 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

Add failures to an array and display it before exiting. Before:

```
Warning: Kernel ABI header at 'tools/include/uapi/linux/fcntl.h' differs from latest version at 'include/uapi/linux/fcntl.h'
diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
...
```

After:
```
Warning: Kernel ABI header differences:
  tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
  tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
...
```

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/check-headers.sh | 229 ++++++++++++++++++++----------------
 1 file changed, 125 insertions(+), 104 deletions(-)

diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index eacca9a874e2..f848b425d936 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -1,113 +1,121 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
-FILES='
-include/uapi/linux/const.h
-include/uapi/drm/drm.h
-include/uapi/drm/i915_drm.h
-include/uapi/linux/fadvise.h
-include/uapi/linux/fcntl.h
-include/uapi/linux/fs.h
-include/uapi/linux/fscrypt.h
-include/uapi/linux/kcmp.h
-include/uapi/linux/kvm.h
-include/uapi/linux/in.h
-include/uapi/linux/mount.h
-include/uapi/linux/openat2.h
-include/uapi/linux/perf_event.h
-include/uapi/linux/prctl.h
-include/uapi/linux/sched.h
-include/uapi/linux/stat.h
-include/uapi/linux/usbdevice_fs.h
-include/uapi/linux/vhost.h
-include/uapi/sound/asound.h
-include/linux/bits.h
-include/vdso/bits.h
-include/linux/const.h
-include/vdso/const.h
-include/linux/hash.h
-include/linux/list-sort.h
-include/uapi/linux/hw_breakpoint.h
-arch/x86/include/asm/disabled-features.h
-arch/x86/include/asm/required-features.h
-arch/x86/include/asm/cpufeatures.h
-arch/x86/include/asm/inat_types.h
-arch/x86/include/asm/emulate_prefix.h
-arch/x86/include/asm/irq_vectors.h
-arch/x86/include/asm/msr-index.h
-arch/x86/include/uapi/asm/prctl.h
-arch/x86/lib/x86-opcode-map.txt
-arch/x86/tools/gen-insn-attr-x86.awk
-arch/arm/include/uapi/asm/perf_regs.h
-arch/arm64/include/uapi/asm/perf_regs.h
-arch/mips/include/uapi/asm/perf_regs.h
-arch/powerpc/include/uapi/asm/perf_regs.h
-arch/s390/include/uapi/asm/perf_regs.h
-arch/x86/include/uapi/asm/perf_regs.h
-arch/x86/include/uapi/asm/kvm.h
-arch/x86/include/uapi/asm/kvm_perf.h
-arch/x86/include/uapi/asm/svm.h
-arch/x86/include/uapi/asm/unistd.h
-arch/x86/include/uapi/asm/vmx.h
-arch/powerpc/include/uapi/asm/kvm.h
-arch/s390/include/uapi/asm/kvm.h
-arch/s390/include/uapi/asm/kvm_perf.h
-arch/s390/include/uapi/asm/ptrace.h
-arch/s390/include/uapi/asm/sie.h
-arch/arm/include/uapi/asm/kvm.h
-arch/arm64/include/uapi/asm/kvm.h
-arch/arm64/include/uapi/asm/unistd.h
-arch/alpha/include/uapi/asm/errno.h
-arch/mips/include/asm/errno.h
-arch/mips/include/uapi/asm/errno.h
-arch/parisc/include/uapi/asm/errno.h
-arch/powerpc/include/uapi/asm/errno.h
-arch/sparc/include/uapi/asm/errno.h
-arch/x86/include/uapi/asm/errno.h
-include/asm-generic/bitops/arch_hweight.h
-include/asm-generic/bitops/const_hweight.h
-include/asm-generic/bitops/__fls.h
-include/asm-generic/bitops/fls.h
-include/asm-generic/bitops/fls64.h
-include/linux/coresight-pmu.h
-include/uapi/asm-generic/errno.h
-include/uapi/asm-generic/errno-base.h
-include/uapi/asm-generic/ioctls.h
-include/uapi/asm-generic/mman-common.h
-include/uapi/asm-generic/unistd.h
-'
-
-SYNC_CHECK_FILES='
-arch/x86/include/asm/inat.h
-arch/x86/include/asm/insn.h
-arch/x86/lib/inat.c
-arch/x86/lib/insn.c
-'
+YELLOW='\033[0;33m'
+NC='\033[0m' # No Color
+
+declare -a FILES
+FILES=(
+  "include/uapi/linux/const.h"
+  "include/uapi/drm/drm.h"
+  "include/uapi/drm/i915_drm.h"
+  "include/uapi/linux/fadvise.h"
+  "include/uapi/linux/fcntl.h"
+  "include/uapi/linux/fs.h"
+  "include/uapi/linux/fscrypt.h"
+  "include/uapi/linux/kcmp.h"
+  "include/uapi/linux/kvm.h"
+  "include/uapi/linux/in.h"
+  "include/uapi/linux/mount.h"
+  "include/uapi/linux/openat2.h"
+  "include/uapi/linux/perf_event.h"
+  "include/uapi/linux/prctl.h"
+  "include/uapi/linux/sched.h"
+  "include/uapi/linux/stat.h"
+  "include/uapi/linux/usbdevice_fs.h"
+  "include/uapi/linux/vhost.h"
+  "include/uapi/sound/asound.h"
+  "include/linux/bits.h"
+  "include/vdso/bits.h"
+  "include/linux/const.h"
+  "include/vdso/const.h"
+  "include/linux/hash.h"
+  "include/linux/list-sort.h"
+  "include/uapi/linux/hw_breakpoint.h"
+  "arch/x86/include/asm/disabled-features.h"
+  "arch/x86/include/asm/required-features.h"
+  "arch/x86/include/asm/cpufeatures.h"
+  "arch/x86/include/asm/inat_types.h"
+  "arch/x86/include/asm/emulate_prefix.h"
+  "arch/x86/include/asm/irq_vectors.h"
+  "arch/x86/include/asm/msr-index.h"
+  "arch/x86/include/uapi/asm/prctl.h"
+  "arch/x86/lib/x86-opcode-map.txt"
+  "arch/x86/tools/gen-insn-attr-x86.awk"
+  "arch/arm/include/uapi/asm/perf_regs.h"
+  "arch/arm64/include/uapi/asm/perf_regs.h"
+  "arch/mips/include/uapi/asm/perf_regs.h"
+  "arch/powerpc/include/uapi/asm/perf_regs.h"
+  "arch/s390/include/uapi/asm/perf_regs.h"
+  "arch/x86/include/uapi/asm/perf_regs.h"
+  "arch/x86/include/uapi/asm/kvm.h"
+  "arch/x86/include/uapi/asm/kvm_perf.h"
+  "arch/x86/include/uapi/asm/svm.h"
+  "arch/x86/include/uapi/asm/unistd.h"
+  "arch/x86/include/uapi/asm/vmx.h"
+  "arch/powerpc/include/uapi/asm/kvm.h"
+  "arch/s390/include/uapi/asm/kvm.h"
+  "arch/s390/include/uapi/asm/kvm_perf.h"
+  "arch/s390/include/uapi/asm/ptrace.h"
+  "arch/s390/include/uapi/asm/sie.h"
+  "arch/arm/include/uapi/asm/kvm.h"
+  "arch/arm64/include/uapi/asm/kvm.h"
+  "arch/arm64/include/uapi/asm/unistd.h"
+  "arch/alpha/include/uapi/asm/errno.h"
+  "arch/mips/include/asm/errno.h"
+  "arch/mips/include/uapi/asm/errno.h"
+  "arch/parisc/include/uapi/asm/errno.h"
+  "arch/powerpc/include/uapi/asm/errno.h"
+  "arch/sparc/include/uapi/asm/errno.h"
+  "arch/x86/include/uapi/asm/errno.h"
+  "include/asm-generic/bitops/arch_hweight.h"
+  "include/asm-generic/bitops/const_hweight.h"
+  "include/asm-generic/bitops/__fls.h"
+  "include/asm-generic/bitops/fls.h"
+  "include/asm-generic/bitops/fls64.h"
+  "include/linux/coresight-pmu.h"
+  "include/uapi/asm-generic/errno.h"
+  "include/uapi/asm-generic/errno-base.h"
+  "include/uapi/asm-generic/ioctls.h"
+  "include/uapi/asm-generic/mman-common.h"
+  "include/uapi/asm-generic/unistd.h"
+)
+
+declare -a SYNC_CHECK_FILES
+SYNC_CHECK_FILES=(
+  "arch/x86/include/asm/inat.h"
+  "arch/x86/include/asm/insn.h"
+  "arch/x86/lib/inat.c"
+  "arch/x86/lib/insn.c"
+)
 
 # These copies are under tools/perf/trace/beauty/ as they are not used to in
 # building object files only by scripts in tools/perf/trace/beauty/ to generate
 # tables that then gets included in .c files for things like id->string syscall
 # tables (and the reverse lookup as well: string -> id)
 
-BEAUTY_FILES='
-include/linux/socket.h
-'
+declare -a BEAUTY_FILES
+BEAUTY_FILES=(
+  "include/linux/socket.h"
+)
+
+declare -a FAILURES
 
 check_2 () {
-  file1=$1
-  file2=$2
+  tools_file=$1
+  orig_file=$2
 
   shift
   shift
 
-  cmd="diff $* $file1 $file2 > /dev/null"
+  cmd="diff $* $tools_file $orig_file > /dev/null"
 
-  test -f $file2 && {
-    eval $cmd || {
-      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
-      echo diff -u $file1 $file2
-    }
-  }
+  if [ -f "$orig_file" ] && ! eval "$cmd"
+  then
+    FAILURES+=(
+      "$tools_file $orig_file"
+    )
+  fi
 }
 
 check () {
@@ -115,7 +123,7 @@ check () {
 
   shift
 
-  check_2 tools/$file $file $*
+  check_2 "tools/$file" "$file" $*
 }
 
 beauty_check () {
@@ -123,23 +131,29 @@ beauty_check () {
 
   shift
 
-  check_2 tools/perf/trace/beauty/$file $file $*
+  check_2 "tools/perf/trace/beauty/$file" "$file" $*
 }
 
 # Check if we have the kernel headers (tools/perf/../../include), else
 # we're probably on a detached tarball, so no point in trying to check
 # differences.
-test -d ../../include || exit 0
+if ! [ -d ../../include ]
+then
+  echo -e "${YELLOW}Warning${NC}: Skipped check-headers due to missing ../../include"
+  exit 0
+fi
 
 cd ../..
 
 # simple diff check
-for i in $FILES; do
-  check $i -B
+for i in "${FILES[@]}"
+do
+  check "$i" -B
 done
 
-for i in $SYNC_CHECK_FILES; do
-  check $i '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
+for i in "${SYNC_CHECK_FILES[@]}"
+do
+  check "$i" '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
 done
 
 # diff with extra ignore lines
@@ -160,8 +174,9 @@ check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/s
 check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
 check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
 
-for i in $BEAUTY_FILES; do
-  beauty_check $i -B
+for i in "${BEAUTY_FILES[@]}"
+do
+  beauty_check "$i" -B
 done
 
 # check duplicated library files
@@ -169,3 +184,9 @@ check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
 check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
 
 cd tools/perf
+
+echo -e "${YELLOW}Warning${NC}: Kernel ABI header differences:"
+for i in "${FAILURES[@]}"
+do
+  echo "  $i"
+done
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v1 13/13] perf build: Remove redundant NO_NEWT build option
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (11 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 12/13] tools headers: Make the difference output easier to read Ian Rogers
@ 2023-03-11  6:57 ` Ian Rogers
  2023-03-14 12:11 ` [PATCH v1 00/13] Perf tool build improvements Arnaldo Carvalho de Melo
  13 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-11  6:57 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Roberto Sassu,
	Quentin Monnet, Andres Freund, Tiezhu Yang, Pavithra Gurushankar,
	Yang Jihong, Adrian Hunter, Leo Yan, Martin Liška,
	linux-kernel, linux-perf-users, llvm
  Cc: Stephane Eranian, Ian Rogers

The option controlled nothing and no code depends, conditional or
otherwise, on libnewt.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/Makefile.config | 4 ----
 tools/perf/Makefile.perf   | 2 --
 tools/perf/tests/make      | 6 ++----
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 1b598c5e68eb..b7a9cb4a3526 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -752,10 +752,6 @@ ifndef NO_LIBCRYPTO
   endif
 endif
 
-ifdef NO_NEWT
-  NO_SLANG=1
-endif
-
 ifndef NO_SLANG
   ifneq ($(feature-libslang), 1)
     ifneq ($(feature-libslang-include-subdir), 1)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 3e06915f6bd0..dc9dda09b076 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -44,8 +44,6 @@ include ../scripts/utilities.mak
 #
 # Define WERROR=0 to disable treating any warnings as errors.
 #
-# Define NO_NEWT if you do not want TUI support. (deprecated)
-#
 # Define NO_SLANG if you do not want TUI support.
 #
 # Define GTK2 if you want GTK+ GUI support.
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 47c665659022..a74b4be446c6 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -72,10 +72,9 @@ make_nondistro      := BUILD_NONDISTRO=1
 make_no_libperl     := NO_LIBPERL=1
 make_no_libpython   := NO_LIBPYTHON=1
 make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
-make_no_newt        := NO_NEWT=1
 make_no_slang       := NO_SLANG=1
 make_no_gtk2        := NO_GTK2=1
-make_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
+make_no_ui          := NO_SLANG=1 NO_GTK2=1
 make_no_demangle    := NO_DEMANGLE=1
 make_no_libelf      := NO_LIBELF=1
 make_no_libunwind   := NO_LIBUNWIND=1
@@ -115,7 +114,7 @@ make_install_prefix_slash := install prefix=/tmp/krava/
 make_static         := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
 
 # all the NO_* variable combined
-make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
+make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_GTK2=1
 make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
 make_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
 make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
@@ -139,7 +138,6 @@ run += make_nondistro
 run += make_no_libperl
 run += make_no_libpython
 run += make_no_scripts
-run += make_no_newt
 run += make_no_slang
 run += make_no_gtk2
 run += make_no_ui
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 12/13] tools headers: Make the difference output easier to read
  2023-03-11  6:57 ` [PATCH v1 12/13] tools headers: Make the difference output easier to read Ian Rogers
@ 2023-03-13 19:35   ` Arnaldo Carvalho de Melo
  2023-03-13 20:14     ` Ian Rogers
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 19:35 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Fri, Mar 10, 2023 at 10:57:52PM -0800, Ian Rogers escreveu:
> Add failures to an array and display it before exiting. Before:
> 
> ```
> Warning: Kernel ABI header at 'tools/include/uapi/linux/fcntl.h' differs from latest version at 'include/uapi/linux/fcntl.h'
> diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
> Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
> diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
> ...
> ```
> 
> After:
> ```
> Warning: Kernel ABI header differences:
>   tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
>   tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h

I use that diff line to cut and paste, check the errors, etc.

- Arnaldo

> ...
> ```
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/check-headers.sh | 229 ++++++++++++++++++++----------------
>  1 file changed, 125 insertions(+), 104 deletions(-)
> 
> diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
> index eacca9a874e2..f848b425d936 100755
> --- a/tools/perf/check-headers.sh
> +++ b/tools/perf/check-headers.sh
> @@ -1,113 +1,121 @@
> -#!/bin/sh
> +#!/bin/bash
>  # SPDX-License-Identifier: GPL-2.0
>  
> -FILES='
> -include/uapi/linux/const.h
> -include/uapi/drm/drm.h
> -include/uapi/drm/i915_drm.h
> -include/uapi/linux/fadvise.h
> -include/uapi/linux/fcntl.h
> -include/uapi/linux/fs.h
> -include/uapi/linux/fscrypt.h
> -include/uapi/linux/kcmp.h
> -include/uapi/linux/kvm.h
> -include/uapi/linux/in.h
> -include/uapi/linux/mount.h
> -include/uapi/linux/openat2.h
> -include/uapi/linux/perf_event.h
> -include/uapi/linux/prctl.h
> -include/uapi/linux/sched.h
> -include/uapi/linux/stat.h
> -include/uapi/linux/usbdevice_fs.h
> -include/uapi/linux/vhost.h
> -include/uapi/sound/asound.h
> -include/linux/bits.h
> -include/vdso/bits.h
> -include/linux/const.h
> -include/vdso/const.h
> -include/linux/hash.h
> -include/linux/list-sort.h
> -include/uapi/linux/hw_breakpoint.h
> -arch/x86/include/asm/disabled-features.h
> -arch/x86/include/asm/required-features.h
> -arch/x86/include/asm/cpufeatures.h
> -arch/x86/include/asm/inat_types.h
> -arch/x86/include/asm/emulate_prefix.h
> -arch/x86/include/asm/irq_vectors.h
> -arch/x86/include/asm/msr-index.h
> -arch/x86/include/uapi/asm/prctl.h
> -arch/x86/lib/x86-opcode-map.txt
> -arch/x86/tools/gen-insn-attr-x86.awk
> -arch/arm/include/uapi/asm/perf_regs.h
> -arch/arm64/include/uapi/asm/perf_regs.h
> -arch/mips/include/uapi/asm/perf_regs.h
> -arch/powerpc/include/uapi/asm/perf_regs.h
> -arch/s390/include/uapi/asm/perf_regs.h
> -arch/x86/include/uapi/asm/perf_regs.h
> -arch/x86/include/uapi/asm/kvm.h
> -arch/x86/include/uapi/asm/kvm_perf.h
> -arch/x86/include/uapi/asm/svm.h
> -arch/x86/include/uapi/asm/unistd.h
> -arch/x86/include/uapi/asm/vmx.h
> -arch/powerpc/include/uapi/asm/kvm.h
> -arch/s390/include/uapi/asm/kvm.h
> -arch/s390/include/uapi/asm/kvm_perf.h
> -arch/s390/include/uapi/asm/ptrace.h
> -arch/s390/include/uapi/asm/sie.h
> -arch/arm/include/uapi/asm/kvm.h
> -arch/arm64/include/uapi/asm/kvm.h
> -arch/arm64/include/uapi/asm/unistd.h
> -arch/alpha/include/uapi/asm/errno.h
> -arch/mips/include/asm/errno.h
> -arch/mips/include/uapi/asm/errno.h
> -arch/parisc/include/uapi/asm/errno.h
> -arch/powerpc/include/uapi/asm/errno.h
> -arch/sparc/include/uapi/asm/errno.h
> -arch/x86/include/uapi/asm/errno.h
> -include/asm-generic/bitops/arch_hweight.h
> -include/asm-generic/bitops/const_hweight.h
> -include/asm-generic/bitops/__fls.h
> -include/asm-generic/bitops/fls.h
> -include/asm-generic/bitops/fls64.h
> -include/linux/coresight-pmu.h
> -include/uapi/asm-generic/errno.h
> -include/uapi/asm-generic/errno-base.h
> -include/uapi/asm-generic/ioctls.h
> -include/uapi/asm-generic/mman-common.h
> -include/uapi/asm-generic/unistd.h
> -'
> -
> -SYNC_CHECK_FILES='
> -arch/x86/include/asm/inat.h
> -arch/x86/include/asm/insn.h
> -arch/x86/lib/inat.c
> -arch/x86/lib/insn.c
> -'
> +YELLOW='\033[0;33m'
> +NC='\033[0m' # No Color
> +
> +declare -a FILES
> +FILES=(
> +  "include/uapi/linux/const.h"
> +  "include/uapi/drm/drm.h"
> +  "include/uapi/drm/i915_drm.h"
> +  "include/uapi/linux/fadvise.h"
> +  "include/uapi/linux/fcntl.h"
> +  "include/uapi/linux/fs.h"
> +  "include/uapi/linux/fscrypt.h"
> +  "include/uapi/linux/kcmp.h"
> +  "include/uapi/linux/kvm.h"
> +  "include/uapi/linux/in.h"
> +  "include/uapi/linux/mount.h"
> +  "include/uapi/linux/openat2.h"
> +  "include/uapi/linux/perf_event.h"
> +  "include/uapi/linux/prctl.h"
> +  "include/uapi/linux/sched.h"
> +  "include/uapi/linux/stat.h"
> +  "include/uapi/linux/usbdevice_fs.h"
> +  "include/uapi/linux/vhost.h"
> +  "include/uapi/sound/asound.h"
> +  "include/linux/bits.h"
> +  "include/vdso/bits.h"
> +  "include/linux/const.h"
> +  "include/vdso/const.h"
> +  "include/linux/hash.h"
> +  "include/linux/list-sort.h"
> +  "include/uapi/linux/hw_breakpoint.h"
> +  "arch/x86/include/asm/disabled-features.h"
> +  "arch/x86/include/asm/required-features.h"
> +  "arch/x86/include/asm/cpufeatures.h"
> +  "arch/x86/include/asm/inat_types.h"
> +  "arch/x86/include/asm/emulate_prefix.h"
> +  "arch/x86/include/asm/irq_vectors.h"
> +  "arch/x86/include/asm/msr-index.h"
> +  "arch/x86/include/uapi/asm/prctl.h"
> +  "arch/x86/lib/x86-opcode-map.txt"
> +  "arch/x86/tools/gen-insn-attr-x86.awk"
> +  "arch/arm/include/uapi/asm/perf_regs.h"
> +  "arch/arm64/include/uapi/asm/perf_regs.h"
> +  "arch/mips/include/uapi/asm/perf_regs.h"
> +  "arch/powerpc/include/uapi/asm/perf_regs.h"
> +  "arch/s390/include/uapi/asm/perf_regs.h"
> +  "arch/x86/include/uapi/asm/perf_regs.h"
> +  "arch/x86/include/uapi/asm/kvm.h"
> +  "arch/x86/include/uapi/asm/kvm_perf.h"
> +  "arch/x86/include/uapi/asm/svm.h"
> +  "arch/x86/include/uapi/asm/unistd.h"
> +  "arch/x86/include/uapi/asm/vmx.h"
> +  "arch/powerpc/include/uapi/asm/kvm.h"
> +  "arch/s390/include/uapi/asm/kvm.h"
> +  "arch/s390/include/uapi/asm/kvm_perf.h"
> +  "arch/s390/include/uapi/asm/ptrace.h"
> +  "arch/s390/include/uapi/asm/sie.h"
> +  "arch/arm/include/uapi/asm/kvm.h"
> +  "arch/arm64/include/uapi/asm/kvm.h"
> +  "arch/arm64/include/uapi/asm/unistd.h"
> +  "arch/alpha/include/uapi/asm/errno.h"
> +  "arch/mips/include/asm/errno.h"
> +  "arch/mips/include/uapi/asm/errno.h"
> +  "arch/parisc/include/uapi/asm/errno.h"
> +  "arch/powerpc/include/uapi/asm/errno.h"
> +  "arch/sparc/include/uapi/asm/errno.h"
> +  "arch/x86/include/uapi/asm/errno.h"
> +  "include/asm-generic/bitops/arch_hweight.h"
> +  "include/asm-generic/bitops/const_hweight.h"
> +  "include/asm-generic/bitops/__fls.h"
> +  "include/asm-generic/bitops/fls.h"
> +  "include/asm-generic/bitops/fls64.h"
> +  "include/linux/coresight-pmu.h"
> +  "include/uapi/asm-generic/errno.h"
> +  "include/uapi/asm-generic/errno-base.h"
> +  "include/uapi/asm-generic/ioctls.h"
> +  "include/uapi/asm-generic/mman-common.h"
> +  "include/uapi/asm-generic/unistd.h"
> +)
> +
> +declare -a SYNC_CHECK_FILES
> +SYNC_CHECK_FILES=(
> +  "arch/x86/include/asm/inat.h"
> +  "arch/x86/include/asm/insn.h"
> +  "arch/x86/lib/inat.c"
> +  "arch/x86/lib/insn.c"
> +)
>  
>  # These copies are under tools/perf/trace/beauty/ as they are not used to in
>  # building object files only by scripts in tools/perf/trace/beauty/ to generate
>  # tables that then gets included in .c files for things like id->string syscall
>  # tables (and the reverse lookup as well: string -> id)
>  
> -BEAUTY_FILES='
> -include/linux/socket.h
> -'
> +declare -a BEAUTY_FILES
> +BEAUTY_FILES=(
> +  "include/linux/socket.h"
> +)
> +
> +declare -a FAILURES
>  
>  check_2 () {
> -  file1=$1
> -  file2=$2
> +  tools_file=$1
> +  orig_file=$2
>  
>    shift
>    shift
>  
> -  cmd="diff $* $file1 $file2 > /dev/null"
> +  cmd="diff $* $tools_file $orig_file > /dev/null"
>  
> -  test -f $file2 && {
> -    eval $cmd || {
> -      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
> -      echo diff -u $file1 $file2
> -    }
> -  }
> +  if [ -f "$orig_file" ] && ! eval "$cmd"
> +  then
> +    FAILURES+=(
> +      "$tools_file $orig_file"
> +    )
> +  fi
>  }
>  
>  check () {
> @@ -115,7 +123,7 @@ check () {
>  
>    shift
>  
> -  check_2 tools/$file $file $*
> +  check_2 "tools/$file" "$file" $*
>  }
>  
>  beauty_check () {
> @@ -123,23 +131,29 @@ beauty_check () {
>  
>    shift
>  
> -  check_2 tools/perf/trace/beauty/$file $file $*
> +  check_2 "tools/perf/trace/beauty/$file" "$file" $*
>  }
>  
>  # Check if we have the kernel headers (tools/perf/../../include), else
>  # we're probably on a detached tarball, so no point in trying to check
>  # differences.
> -test -d ../../include || exit 0
> +if ! [ -d ../../include ]
> +then
> +  echo -e "${YELLOW}Warning${NC}: Skipped check-headers due to missing ../../include"
> +  exit 0
> +fi
>  
>  cd ../..
>  
>  # simple diff check
> -for i in $FILES; do
> -  check $i -B
> +for i in "${FILES[@]}"
> +do
> +  check "$i" -B
>  done
>  
> -for i in $SYNC_CHECK_FILES; do
> -  check $i '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
> +for i in "${SYNC_CHECK_FILES[@]}"
> +do
> +  check "$i" '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
>  done
>  
>  # diff with extra ignore lines
> @@ -160,8 +174,9 @@ check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/s
>  check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
>  check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
>  
> -for i in $BEAUTY_FILES; do
> -  beauty_check $i -B
> +for i in "${BEAUTY_FILES[@]}"
> +do
> +  beauty_check "$i" -B
>  done
>  
>  # check duplicated library files
> @@ -169,3 +184,9 @@ check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
>  check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
>  
>  cd tools/perf
> +
> +echo -e "${YELLOW}Warning${NC}: Kernel ABI header differences:"
> +for i in "${FAILURES[@]}"
> +do
> +  echo "  $i"
> +done
> -- 
> 2.40.0.rc1.284.g88254d51c5-goog
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 07/13] perf build: Make binutil libraries opt in
  2023-03-11  6:57 ` [PATCH v1 07/13] perf build: Make binutil libraries opt in Ian Rogers
@ 2023-03-13 19:37   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 19:37 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Fri, Mar 10, 2023 at 10:57:47PM -0800, Ian Rogers escreveu:
> binutils is GPLv3 so distributions cannot ship perf linked against
> libbfd and libiberty as the licenses are incompatible. Rather than
> defaulting the build to opting in to libbfd and libiberty support and
> opting out via NO_LIBBFD=1 and NO_DEMANGLE=1, make building against
> the libraries optional and enabled with BUILD_NONDISTRO=1.

So now I get this:

⬢[acme@toolbox perf-tools-next]$ perf -vv
perf version 6.3.rc1.gace4d44d094c
                 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
    dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
         syscall_table: [ on  ]  # HAVE_SYSCALL_TABLE_SUPPORT
                libbfd: [ OFF ]  # HAVE_LIBBFD_SUPPORT
            debuginfod: [ on  ]  # HAVE_DEBUGINFOD_SUPPORT
                libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
               libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
               libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
             libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
              libslang: [ on  ]  # HAVE_SLANG_SUPPORT
             libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
             libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
    libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
             get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
                   aio: [ on  ]  # HAVE_AIO_SUPPORT
                  zstd: [ on  ]  # HAVE_ZSTD_SUPPORT
               libpfm4: [ on  ]  # HAVE_LIBPFM
         libtraceevent: [ on  ]  # HAVE_LIBTRACEEVENT
         BPF skeletons: [ on  ]  # HAVE_BPF_SKEL
⬢[acme@toolbox perf-tools-next]$

Shouldn't we have, right next to libbpf that libstdc++ feature status?

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/Makefile.config | 25 ++++++++++---------------
>  tools/perf/Makefile.perf   |  2 ++
>  tools/perf/tests/make      |  2 ++
>  3 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 2557654d8e29..5756498248e0 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -882,7 +882,7 @@ ifneq ($(NO_JEVENTS),1)
>    endif
>  endif
>  
> -ifndef NO_LIBBFD
> +ifdef BUILD_NONDISTRO
>    ifeq ($(feature-libbfd), 1)
>      EXTLIBS += -lbfd -lopcodes
>    else
> @@ -905,6 +905,7 @@ ifndef NO_LIBBFD
>      $(call feature_check,disassembler-init-styled)
>    endif
>  
> +  CFLAGS += -DHAVE_LIBBFD_SUPPORT
>    ifeq ($(feature-libbfd-buildid), 1)
>      CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
>    else
> @@ -915,32 +916,26 @@ endif
>  ifdef NO_DEMANGLE
>    CFLAGS += -DNO_DEMANGLE
>  else
> -  ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
> -    EXTLIBS += -liberty
> -  else
> +  ifdef BUILD_NONDISTRO
>      ifeq ($(filter -liberty,$(EXTLIBS)),)
> -      $(call feature_check,cplus-demangle)
> -
> -      # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
> -      # or any of 'bfd iberty z' trinity
> -      ifeq ($(feature-cplus-demangle), 1)
> +      ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
>          EXTLIBS += -liberty
>        else
> -        msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
> -        CFLAGS += -DNO_DEMANGLE
> +        $(call feature_check,cplus-demangle)
> +        ifeq ($(feature-cplus-demangle), 1)
> +          EXTLIBS += -liberty
> +        endif
>        endif
>      endif
>    endif
>  
>    ifneq ($(filter -liberty,$(EXTLIBS)),)
>      CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> +  else
> +    CFLAGS += -DNO_DEMANGLE
>    endif
>  endif
>  
> -ifneq ($(filter -lbfd,$(EXTLIBS)),)
> -  CFLAGS += -DHAVE_LIBBFD_SUPPORT
> -endif
> -
>  ifndef NO_ZLIB
>    ifeq ($(feature-zlib), 1)
>      CFLAGS += -DHAVE_ZLIB_SUPPORT
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 283ee4f56234..a35bc995d5d8 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -128,6 +128,8 @@ include ../scripts/utilities.mak
>  #
>  # Define NO_BPF_SKEL to disable BPF skeletons
>  #
> +# Define BUILD_NONDISTRO to enable building an linking against libbfd and
> +# libiberty distribution license incompatible libraries.
>  
>  # As per kernel Makefile, avoid funny character set dependencies
>  unexport LC_ALL
> diff --git a/tools/perf/tests/make b/tools/perf/tests/make
> index deb37fb982e9..c2f74ed43418 100644
> --- a/tools/perf/tests/make
> +++ b/tools/perf/tests/make
> @@ -68,6 +68,7 @@ python_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{pri
>  make_clean_all      := clean all
>  make_python_perf_so := $(python_perf_so)
>  make_debug          := DEBUG=1
> +make_nondistro      := BUILD_NONDISTRO=1
>  make_no_libperl     := NO_LIBPERL=1
>  make_no_libpython   := NO_LIBPYTHON=1
>  make_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
> @@ -134,6 +135,7 @@ MAKE_F := $(MAKE) -f $(MK)
>  endif
>  run += make_python_perf_so
>  run += make_debug
> +run += make_nondistro
>  run += make_no_libperl
>  run += make_no_libpython
>  run += make_no_scripts
> -- 
> 2.40.0.rc1.284.g88254d51c5-goog
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set
  2023-03-11  6:57 ` [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set Ian Rogers
@ 2023-03-13 19:45   ` Arnaldo Carvalho de Melo
  2023-03-13 20:18     ` Ian Rogers
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 19:45 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Fri, Mar 10, 2023 at 10:57:44PM -0800, Ian Rogers escreveu:
> Building without libelf support is going disable a lot of
> functionality. Require that the NO_LIBELF=1 build option is passed if
> this is intentional.


'make -C tools/perf build-test' is failing:

⬢[acme@toolbox perf-tools-next]$ git log --oneline -1 ; time make -C tools/perf build-test
ace4d44d094ce850 (HEAD -> perf-tools-next) perf build: Remove redundant NO_NEWT build option
make: Entering directory '/var/home/acme/git/perf-tools-next/tools/perf'
Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
- tarpkg: ./tests/perf-targz-src-pkg .
                 make_static: cd . && make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 -j32  DESTDIR=/tmp/tmp.jqGYXdF9cQ
cd . && make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 -j32 DESTDIR=/tmp/tmp.jqGYXdF9cQ
  BUILD:   Doing 'make -j32' parallel build
  HOSTCC  fixdep.o
  HOSTLD  fixdep-in.o
  LINK    fixdep
Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
Makefile.config:429: *** ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1..  Stop.
make[3]: *** [Makefile.perf:236: sub-make] Error 2
make[2]: *** [Makefile:70: all] Error 2
  test: test -x ./perf
make[1]: *** [tests/make:316: make_static] Error 1
make: *** [Makefile:103: build-test] Error 2

Same thing for the libtraceevent, I'll add NO_LIBTRACEEVENT=1 and NO_LIBELF=1 to the static build test in tools/perf/tests/make

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 12/13] tools headers: Make the difference output easier to read
  2023-03-13 19:35   ` Arnaldo Carvalho de Melo
@ 2023-03-13 20:14     ` Ian Rogers
  0 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-13 20:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

On Mon, Mar 13, 2023 at 12:35 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Fri, Mar 10, 2023 at 10:57:52PM -0800, Ian Rogers escreveu:
> > Add failures to an array and display it before exiting. Before:
> >
> > ```
> > Warning: Kernel ABI header at 'tools/include/uapi/linux/fcntl.h' differs from latest version at 'include/uapi/linux/fcntl.h'
> > diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
> > Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
> > diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
> > ...
> > ```
> >
> > After:
> > ```
> > Warning: Kernel ABI header differences:
> >   tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
> >   tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
>
> I use that diff line to cut and paste, check the errors, etc.
>
> - Arnaldo

Sure, you can do something similar here but you need to add "diff -u"
at the beginning of the line. We could add a flag to the tool to do
the diff for you. The current 1st warning line is ~120characters long
and wraps onto 2 lines for me, the diff makes this 3 lines. Overall I
struggle to see the Makefile.config warnings because of all the
check-headers.sh warnings and the indent makes the grouping,
check-headers.sh vs other warnings/error, easier to see.

Compare the new output:
```
Warning: Kernel ABI header differences:
 tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
 tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
 tools/include/uapi/linux/in.h include/uapi/linux/in.h
 tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
 tools/include/uapi/linux/prctl.h include/uapi/linux/prctl.h
 tools/include/uapi/linux/vhost.h include/uapi/linux/vhost.h
 tools/include/linux/bits.h include/linux/bits.h
 tools/include/vdso/bits.h include/vdso/bits.h
 tools/arch/x86/include/asm/disabled-features.h
arch/x86/include/asm/disabled-features.h
 tools/arch/x86/include/asm/required-features.h
arch/x86/include/asm/required-features.h
 tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
 tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
 tools/arch/arm64/include/uapi/asm/perf_regs.h
arch/arm64/include/uapi/asm/perf_regs.h
 tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
 tools/arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/svm.h
 tools/arch/arm64/include/uapi/asm/kvm.h arch/arm64/include/uapi/asm/kvm.h
 tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
 tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
 tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S
Makefile.config:587: No sys/sdt.h found, no SDT events are defined,
please install systemtap-sdt-dev
el or systemtap-sdt-dev
Makefile.config:635: No libunwind found. Please install
libunwind-dev[el] >= 1.1 and/or set LIBUNWIN
D_DIR
Makefile.config:805: Missing perl devel files. Disabling perl
scripting support, please install perl
-ExtUtils-Embed/libperl-dev
Makefile.config:963: No libzstd found, disables trace compression,
please install libzstd-dev[el] an
d/or set LIBZSTD_DIR
Makefile.config:974: No libcap found, disables capability support,
please install libcap-devel/libca
p-dev
Makefile.config:987: No numa.h found, disables 'perf bench numa mem'
benchmark, please install numac
tl-devel/libnuma-devel/libnuma-dev
Makefile.config:1046: No libbabeltrace found, disables 'perf data' CTF
format support, please instal
l libbabeltrace-dev[el]/libbabeltrace-ctf-dev

Auto-detecting system features:
...                                   dwarf: [ on  ]
...                      dwarf_getlocations: [ on  ]
...
```

with

```
Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs
from latest version at 'includ
e/uapi/linux/in.h'
diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
Warning: Kernel ABI header at
'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version
at 'arch/x86/include/asm/cpufeatures.h'
diff -u tools/arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/cpufeatures.h
Warning: Kernel ABI header at
'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest ve
rsion at 'arch/arm64/include/uapi/asm/perf_regs.h'
diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h
arch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h'
differs from latest version at '
include/linux/coresight-pmu.h'
diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
Makefile.config:587: No sys/sdt.h found, no SDT events are defined,
please install systemtap-sdt-dev
el or systemtap-sdt-dev
Makefile.config:635: No libunwind found. Please install
libunwind-dev[el] >= 1.1 and/or set LIBUNWIN
D_DIR
Makefile.config:809: Missing perl devel files. Disabling perl
scripting support, please install perl
-ExtUtils-Embed/libperl-dev
Makefile.config:967: No libzstd found, disables trace compression,
please install libzstd-dev[el] an
d/or set LIBZSTD_DIR
Makefile.config:978: No libcap found, disables capability support,
please install libcap-devel/libca
p-dev
Makefile.config:991: No numa.h found, disables 'perf bench numa mem'
benchmark, please install numac
tl-devel/libnuma-devel/libnuma-dev
Makefile.config:1050: No libbabeltrace found, disables 'perf data' CTF
format support, please instal
l libbabeltrace-dev[el]/libbabeltrace-ctf-dev

Auto-detecting system features:
...                                   dwarf: [ on  ]
...                      dwarf_getlocations: [ on  ]
...
```

That said there are more warnings with the new code, which looks like
some of the filters have kept working as they should :-)

Thanks,
Ian

> > ...
> > ```
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/check-headers.sh | 229 ++++++++++++++++++++----------------
> >  1 file changed, 125 insertions(+), 104 deletions(-)
> >
> > diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
> > index eacca9a874e2..f848b425d936 100755
> > --- a/tools/perf/check-headers.sh
> > +++ b/tools/perf/check-headers.sh
> > @@ -1,113 +1,121 @@
> > -#!/bin/sh
> > +#!/bin/bash
> >  # SPDX-License-Identifier: GPL-2.0
> >
> > -FILES='
> > -include/uapi/linux/const.h
> > -include/uapi/drm/drm.h
> > -include/uapi/drm/i915_drm.h
> > -include/uapi/linux/fadvise.h
> > -include/uapi/linux/fcntl.h
> > -include/uapi/linux/fs.h
> > -include/uapi/linux/fscrypt.h
> > -include/uapi/linux/kcmp.h
> > -include/uapi/linux/kvm.h
> > -include/uapi/linux/in.h
> > -include/uapi/linux/mount.h
> > -include/uapi/linux/openat2.h
> > -include/uapi/linux/perf_event.h
> > -include/uapi/linux/prctl.h
> > -include/uapi/linux/sched.h
> > -include/uapi/linux/stat.h
> > -include/uapi/linux/usbdevice_fs.h
> > -include/uapi/linux/vhost.h
> > -include/uapi/sound/asound.h
> > -include/linux/bits.h
> > -include/vdso/bits.h
> > -include/linux/const.h
> > -include/vdso/const.h
> > -include/linux/hash.h
> > -include/linux/list-sort.h
> > -include/uapi/linux/hw_breakpoint.h
> > -arch/x86/include/asm/disabled-features.h
> > -arch/x86/include/asm/required-features.h
> > -arch/x86/include/asm/cpufeatures.h
> > -arch/x86/include/asm/inat_types.h
> > -arch/x86/include/asm/emulate_prefix.h
> > -arch/x86/include/asm/irq_vectors.h
> > -arch/x86/include/asm/msr-index.h
> > -arch/x86/include/uapi/asm/prctl.h
> > -arch/x86/lib/x86-opcode-map.txt
> > -arch/x86/tools/gen-insn-attr-x86.awk
> > -arch/arm/include/uapi/asm/perf_regs.h
> > -arch/arm64/include/uapi/asm/perf_regs.h
> > -arch/mips/include/uapi/asm/perf_regs.h
> > -arch/powerpc/include/uapi/asm/perf_regs.h
> > -arch/s390/include/uapi/asm/perf_regs.h
> > -arch/x86/include/uapi/asm/perf_regs.h
> > -arch/x86/include/uapi/asm/kvm.h
> > -arch/x86/include/uapi/asm/kvm_perf.h
> > -arch/x86/include/uapi/asm/svm.h
> > -arch/x86/include/uapi/asm/unistd.h
> > -arch/x86/include/uapi/asm/vmx.h
> > -arch/powerpc/include/uapi/asm/kvm.h
> > -arch/s390/include/uapi/asm/kvm.h
> > -arch/s390/include/uapi/asm/kvm_perf.h
> > -arch/s390/include/uapi/asm/ptrace.h
> > -arch/s390/include/uapi/asm/sie.h
> > -arch/arm/include/uapi/asm/kvm.h
> > -arch/arm64/include/uapi/asm/kvm.h
> > -arch/arm64/include/uapi/asm/unistd.h
> > -arch/alpha/include/uapi/asm/errno.h
> > -arch/mips/include/asm/errno.h
> > -arch/mips/include/uapi/asm/errno.h
> > -arch/parisc/include/uapi/asm/errno.h
> > -arch/powerpc/include/uapi/asm/errno.h
> > -arch/sparc/include/uapi/asm/errno.h
> > -arch/x86/include/uapi/asm/errno.h
> > -include/asm-generic/bitops/arch_hweight.h
> > -include/asm-generic/bitops/const_hweight.h
> > -include/asm-generic/bitops/__fls.h
> > -include/asm-generic/bitops/fls.h
> > -include/asm-generic/bitops/fls64.h
> > -include/linux/coresight-pmu.h
> > -include/uapi/asm-generic/errno.h
> > -include/uapi/asm-generic/errno-base.h
> > -include/uapi/asm-generic/ioctls.h
> > -include/uapi/asm-generic/mman-common.h
> > -include/uapi/asm-generic/unistd.h
> > -'
> > -
> > -SYNC_CHECK_FILES='
> > -arch/x86/include/asm/inat.h
> > -arch/x86/include/asm/insn.h
> > -arch/x86/lib/inat.c
> > -arch/x86/lib/insn.c
> > -'
> > +YELLOW='\033[0;33m'
> > +NC='\033[0m' # No Color
> > +
> > +declare -a FILES
> > +FILES=(
> > +  "include/uapi/linux/const.h"
> > +  "include/uapi/drm/drm.h"
> > +  "include/uapi/drm/i915_drm.h"
> > +  "include/uapi/linux/fadvise.h"
> > +  "include/uapi/linux/fcntl.h"
> > +  "include/uapi/linux/fs.h"
> > +  "include/uapi/linux/fscrypt.h"
> > +  "include/uapi/linux/kcmp.h"
> > +  "include/uapi/linux/kvm.h"
> > +  "include/uapi/linux/in.h"
> > +  "include/uapi/linux/mount.h"
> > +  "include/uapi/linux/openat2.h"
> > +  "include/uapi/linux/perf_event.h"
> > +  "include/uapi/linux/prctl.h"
> > +  "include/uapi/linux/sched.h"
> > +  "include/uapi/linux/stat.h"
> > +  "include/uapi/linux/usbdevice_fs.h"
> > +  "include/uapi/linux/vhost.h"
> > +  "include/uapi/sound/asound.h"
> > +  "include/linux/bits.h"
> > +  "include/vdso/bits.h"
> > +  "include/linux/const.h"
> > +  "include/vdso/const.h"
> > +  "include/linux/hash.h"
> > +  "include/linux/list-sort.h"
> > +  "include/uapi/linux/hw_breakpoint.h"
> > +  "arch/x86/include/asm/disabled-features.h"
> > +  "arch/x86/include/asm/required-features.h"
> > +  "arch/x86/include/asm/cpufeatures.h"
> > +  "arch/x86/include/asm/inat_types.h"
> > +  "arch/x86/include/asm/emulate_prefix.h"
> > +  "arch/x86/include/asm/irq_vectors.h"
> > +  "arch/x86/include/asm/msr-index.h"
> > +  "arch/x86/include/uapi/asm/prctl.h"
> > +  "arch/x86/lib/x86-opcode-map.txt"
> > +  "arch/x86/tools/gen-insn-attr-x86.awk"
> > +  "arch/arm/include/uapi/asm/perf_regs.h"
> > +  "arch/arm64/include/uapi/asm/perf_regs.h"
> > +  "arch/mips/include/uapi/asm/perf_regs.h"
> > +  "arch/powerpc/include/uapi/asm/perf_regs.h"
> > +  "arch/s390/include/uapi/asm/perf_regs.h"
> > +  "arch/x86/include/uapi/asm/perf_regs.h"
> > +  "arch/x86/include/uapi/asm/kvm.h"
> > +  "arch/x86/include/uapi/asm/kvm_perf.h"
> > +  "arch/x86/include/uapi/asm/svm.h"
> > +  "arch/x86/include/uapi/asm/unistd.h"
> > +  "arch/x86/include/uapi/asm/vmx.h"
> > +  "arch/powerpc/include/uapi/asm/kvm.h"
> > +  "arch/s390/include/uapi/asm/kvm.h"
> > +  "arch/s390/include/uapi/asm/kvm_perf.h"
> > +  "arch/s390/include/uapi/asm/ptrace.h"
> > +  "arch/s390/include/uapi/asm/sie.h"
> > +  "arch/arm/include/uapi/asm/kvm.h"
> > +  "arch/arm64/include/uapi/asm/kvm.h"
> > +  "arch/arm64/include/uapi/asm/unistd.h"
> > +  "arch/alpha/include/uapi/asm/errno.h"
> > +  "arch/mips/include/asm/errno.h"
> > +  "arch/mips/include/uapi/asm/errno.h"
> > +  "arch/parisc/include/uapi/asm/errno.h"
> > +  "arch/powerpc/include/uapi/asm/errno.h"
> > +  "arch/sparc/include/uapi/asm/errno.h"
> > +  "arch/x86/include/uapi/asm/errno.h"
> > +  "include/asm-generic/bitops/arch_hweight.h"
> > +  "include/asm-generic/bitops/const_hweight.h"
> > +  "include/asm-generic/bitops/__fls.h"
> > +  "include/asm-generic/bitops/fls.h"
> > +  "include/asm-generic/bitops/fls64.h"
> > +  "include/linux/coresight-pmu.h"
> > +  "include/uapi/asm-generic/errno.h"
> > +  "include/uapi/asm-generic/errno-base.h"
> > +  "include/uapi/asm-generic/ioctls.h"
> > +  "include/uapi/asm-generic/mman-common.h"
> > +  "include/uapi/asm-generic/unistd.h"
> > +)
> > +
> > +declare -a SYNC_CHECK_FILES
> > +SYNC_CHECK_FILES=(
> > +  "arch/x86/include/asm/inat.h"
> > +  "arch/x86/include/asm/insn.h"
> > +  "arch/x86/lib/inat.c"
> > +  "arch/x86/lib/insn.c"
> > +)
> >
> >  # These copies are under tools/perf/trace/beauty/ as they are not used to in
> >  # building object files only by scripts in tools/perf/trace/beauty/ to generate
> >  # tables that then gets included in .c files for things like id->string syscall
> >  # tables (and the reverse lookup as well: string -> id)
> >
> > -BEAUTY_FILES='
> > -include/linux/socket.h
> > -'
> > +declare -a BEAUTY_FILES
> > +BEAUTY_FILES=(
> > +  "include/linux/socket.h"
> > +)
> > +
> > +declare -a FAILURES
> >
> >  check_2 () {
> > -  file1=$1
> > -  file2=$2
> > +  tools_file=$1
> > +  orig_file=$2
> >
> >    shift
> >    shift
> >
> > -  cmd="diff $* $file1 $file2 > /dev/null"
> > +  cmd="diff $* $tools_file $orig_file > /dev/null"
> >
> > -  test -f $file2 && {
> > -    eval $cmd || {
> > -      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
> > -      echo diff -u $file1 $file2
> > -    }
> > -  }
> > +  if [ -f "$orig_file" ] && ! eval "$cmd"
> > +  then
> > +    FAILURES+=(
> > +      "$tools_file $orig_file"
> > +    )
> > +  fi
> >  }
> >
> >  check () {
> > @@ -115,7 +123,7 @@ check () {
> >
> >    shift
> >
> > -  check_2 tools/$file $file $*
> > +  check_2 "tools/$file" "$file" $*
> >  }
> >
> >  beauty_check () {
> > @@ -123,23 +131,29 @@ beauty_check () {
> >
> >    shift
> >
> > -  check_2 tools/perf/trace/beauty/$file $file $*
> > +  check_2 "tools/perf/trace/beauty/$file" "$file" $*
> >  }
> >
> >  # Check if we have the kernel headers (tools/perf/../../include), else
> >  # we're probably on a detached tarball, so no point in trying to check
> >  # differences.
> > -test -d ../../include || exit 0
> > +if ! [ -d ../../include ]
> > +then
> > +  echo -e "${YELLOW}Warning${NC}: Skipped check-headers due to missing ../../include"
> > +  exit 0
> > +fi
> >
> >  cd ../..
> >
> >  # simple diff check
> > -for i in $FILES; do
> > -  check $i -B
> > +for i in "${FILES[@]}"
> > +do
> > +  check "$i" -B
> >  done
> >
> > -for i in $SYNC_CHECK_FILES; do
> > -  check $i '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
> > +for i in "${SYNC_CHECK_FILES[@]}"
> > +do
> > +  check "$i" '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
> >  done
> >
> >  # diff with extra ignore lines
> > @@ -160,8 +174,9 @@ check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/s
> >  check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
> >  check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
> >
> > -for i in $BEAUTY_FILES; do
> > -  beauty_check $i -B
> > +for i in "${BEAUTY_FILES[@]}"
> > +do
> > +  beauty_check "$i" -B
> >  done
> >
> >  # check duplicated library files
> > @@ -169,3 +184,9 @@ check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
> >  check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
> >
> >  cd tools/perf
> > +
> > +echo -e "${YELLOW}Warning${NC}: Kernel ABI header differences:"
> > +for i in "${FAILURES[@]}"
> > +do
> > +  echo "  $i"
> > +done
> > --
> > 2.40.0.rc1.284.g88254d51c5-goog
> >
>
> --
>
> - Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set
  2023-03-13 19:45   ` Arnaldo Carvalho de Melo
@ 2023-03-13 20:18     ` Ian Rogers
  0 siblings, 0 replies; 34+ messages in thread
From: Ian Rogers @ 2023-03-13 20:18 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

On Mon, Mar 13, 2023 at 12:45 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Fri, Mar 10, 2023 at 10:57:44PM -0800, Ian Rogers escreveu:
> > Building without libelf support is going disable a lot of
> > functionality. Require that the NO_LIBELF=1 build option is passed if
> > this is intentional.
>
>
> 'make -C tools/perf build-test' is failing:
>
> ⬢[acme@toolbox perf-tools-next]$ git log --oneline -1 ; time make -C tools/perf build-test
> ace4d44d094ce850 (HEAD -> perf-tools-next) perf build: Remove redundant NO_NEWT build option
> make: Entering directory '/var/home/acme/git/perf-tools-next/tools/perf'
> Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
> Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
> Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
> Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
> - tarpkg: ./tests/perf-targz-src-pkg .
>                  make_static: cd . && make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 -j32  DESTDIR=/tmp/tmp.jqGYXdF9cQ
> cd . && make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 -j32 DESTDIR=/tmp/tmp.jqGYXdF9cQ
>   BUILD:   Doing 'make -j32' parallel build
>   HOSTCC  fixdep.o
>   HOSTLD  fixdep-in.o
>   LINK    fixdep
> Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
> diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
> Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
> diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
> Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
> diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
> Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
> diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
> Makefile.config:429: *** ERROR: No libelf found. Disables 'probe' tool, jvmti and BPF support. Please install libelf-dev, libelf-devel, elfutils-libelf-devel or build with NO_LIBELF=1..  Stop.
> make[3]: *** [Makefile.perf:236: sub-make] Error 2
> make[2]: *** [Makefile:70: all] Error 2
>   test: test -x ./perf
> make[1]: *** [tests/make:316: make_static] Error 1
> make: *** [Makefile:103: build-test] Error 2
>
> Same thing for the libtraceevent, I'll add NO_LIBTRACEEVENT=1 and NO_LIBELF=1 to the static build test in tools/perf/tests/make

Right, this is kind of the point of the patch set. Make it harder for
people to make a reduced perf binary without explicitly flagging that
this is what they want. For the build tests it may be better to make
the flag conditional on what is installed in the image.

Thanks,
Ian

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
  2023-03-11  6:57 ` [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL Ian Rogers
@ 2023-03-13 20:19   ` Arnaldo Carvalho de Melo
  2023-03-13 20:27     ` Ian Rogers
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 20:19 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Fri, Mar 10, 2023 at 10:57:42PM -0800, Ian Rogers escreveu:
> BPF skeleton support is now key to a number of perf features. Rather
> than making it so that BPF support must be enabled for the build, make
> this the default and error if the build lacks a clang and libbpf that
> are sufficient. To avoid the error and build without BPF skeletons the
> NO_BPF_SKEL=1 flag can be used. Add a build-options flag to 'perf
> version' to enable detection of the BPF skeleton support and use this
> in the offcpu shell test.

Checking this:

cd . && make LIBBPF_DYNAMIC=1 FEATURES_DUMP=/var/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.Rr5xDuXo13 DESTDIR=/tmp/tmp.cYdDvy09eY
  BUILD:   Doing 'make -j32' parallel build
  HOSTCC  /tmp/tmp.Rr5xDuXo13/fixdep.o
  HOSTLD  /tmp/tmp.Rr5xDuXo13/fixdep-in.o
  LINK    /tmp/tmp.Rr5xDuXo13/fixdep
Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
Makefile.config:1130: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel

  GEN     /tmp/tmp.Rr5xDuXo13/common-cmds.h
  CC      /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-test-api-v0.o
  CC      /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-show-cycles.o
  LINK    /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-test-api-v0.so
  LINK    /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-show-cycles.so
  INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/exec-cmd.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/help.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/pager.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/parse-options.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/run-command.h
  CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/exec-cmd.o
  CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/help.o
  CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/pager.o
  CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/parse-options.o
  CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/run-command.o
  CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/sigchain.o
  CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/subcmd-config.o
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/
  INSTALL libsubcmd_headers
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/hashmap.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/relo_core.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_internal.h
  PERF_VERSION = 6.3.rc1.g0b82b38b7b56
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/bpf_perf.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/core.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/cpumap.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/threadmap.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libsymbol/include/symbol/kallsyms.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/cpu.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/evlist.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/debug.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/evsel.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/io.h
  GEN     perf-archive
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/event.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fd/array.h
  GEN     perf-iostat
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/mmap.h
  CC      /tmp/tmp.Rr5xDuXo13/libperf/core.o
  CC      /tmp/tmp.Rr5xDuXo13/libsymbol/kallsyms.o
  CC      /tmp/tmp.Rr5xDuXo13/libapi/cpu.o
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/cpumap.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fs/fs.h
  INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fs/tracing_path.h
  MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fd/
  CC      /tmp/tmp.Rr5xDuXo13/libapi/debug.o
  CC      /tmp/tmp.Rr5xDuXo13/libapi/str_error_r.o
  CC      /tmp/tmp.Rr5xDuXo13/libperf/cpumap.o
  INSTALL libsymbol_headers
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/evlist.h
  CC      /tmp/tmp.Rr5xDuXo13/libperf/threadmap.o
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/evsel.h
  CC      /tmp/tmp.Rr5xDuXo13/libperf/evsel.o
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/lib.h
  CC      /tmp/tmp.Rr5xDuXo13/libperf/evlist.o
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/mmap.h
  MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fs/
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/threadmap.h
  CC      /tmp/tmp.Rr5xDuXo13/libapi/fd/array.o
  MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fs/
  CC      /tmp/tmp.Rr5xDuXo13/libperf/mmap.o
  INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/xyarray.h
  CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/fs.o
  CC      /tmp/tmp.Rr5xDuXo13/libperf/zalloc.o
  CC      /tmp/tmp.Rr5xDuXo13/libperf/xyarray.o
  CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/cgroup.o
  CC      /tmp/tmp.Rr5xDuXo13/libperf/lib.o
  INSTALL libapi_headers
  CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/tracing_path.o
  INSTALL libperf_headers
  GEN     /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/bpf_helper_defs.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/btf.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_common.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_legacy.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helpers.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_tracing.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_endian.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_core_read.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/skel_internal.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_version.h
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/usdt.bpf.h
  LD      /tmp/tmp.Rr5xDuXo13/libapi/fd/libapi-in.o
  LD      /tmp/tmp.Rr5xDuXo13/libsymbol/libsymbol-in.o
  AR      /tmp/tmp.Rr5xDuXo13/libsymbol/libsymbol.a
  LD      /tmp/tmp.Rr5xDuXo13/libapi/fs/libapi-in.o
  INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helper_defs.h
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  INSTALL libbpf_headers
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  LD      /tmp/tmp.Rr5xDuXo13/libapi/libapi-in.o
  MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_probes.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/hashmap.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/nlattr.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf_dump.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_errno.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/str_error.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/netlink.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/ringbuf.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf_prog_linfo.o
  LD      /tmp/tmp.Rr5xDuXo13/libperf/libperf-in.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/strset.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/linker.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/gen_loader.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/relo_core.o
  AR      /tmp/tmp.Rr5xDuXo13/libapi/libapi.a
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/usdt.o
  AR      /tmp/tmp.Rr5xDuXo13/libperf/libperf.a
  LD      /tmp/tmp.Rr5xDuXo13/libsubcmd/libsubcmd-in.o
  AR      /tmp/tmp.Rr5xDuXo13/libsubcmd/libsubcmd.a
  GEN     /tmp/tmp.Rr5xDuXo13/python/perf.cpython-311-x86_64-linux-gnu.so
  LD      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf-in.o
  LINK    /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/libbpf.a
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/main.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/common.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/json_writer.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/gen.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/btf.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/xlated_dumper.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/btf_dumper.o
  CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/disasm.o
  LINK    /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/bpftool
  GEN     /tmp/tmp.Rr5xDuXo13/util/bpf_skel/vmlinux.h
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_leader.bpf.o
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_follower.bpf.o
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/func_latency.bpf.o
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/off_cpu.bpf.o
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/lock_contention.bpf.o
  CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/kwork_trace.bpf.o
util/bpf_skel/lock_contention.bpf.c:192:7: error: call to undeclared function 'bpf_core_type_matches'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
                if (bpf_core_type_matches(struct rw_semaphore___old)) {
                    ^
util/bpf_skel/lock_contention.bpf.c:192:29: error: expected expression
                if (bpf_core_type_matches(struct rw_semaphore___old)) {
                                          ^
util/bpf_skel/lock_contention.bpf.c:195:36: error: expected expression
                } else if (bpf_core_type_matches(struct rw_semaphore___new)) {
                                                 ^
3 errors generated.
/usr/bin/ld: bpf architecture of input file `/tmp/bperf_follower-74fba5.o' is incompatible with i386:x86-64 output
/usr/bin/ld: bpf architecture of input file `/tmp/bperf_leader-b2ec61.o' is incompatible with i386:x86-64 output
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: final link failed: file in wrong format
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: final link failed: file in wrong format
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
/usr/bin/ld: bpf architecture of input file `/tmp/func_latency-70b7d4.o' is incompatible with i386:x86-64 output
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/lock_contention.bpf.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_follower.bpf.o] Error 1
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_leader.bpf.o] Error 1
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: final link failed: file in wrong format
collect2: error: ld returned 1 exit status
clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/func_latency.bpf.o] Error 1
/usr/bin/ld: bpf architecture of input file `/tmp/bpf_prog_profiler-6e9720.o' is incompatible with i386:x86-64 output
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: final link failed: file in wrong format
collect2: error: ld returned 1 exit status
clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o] Error 1
/usr/bin/ld: bpf architecture of input file `/tmp/kwork_trace-8d5b4e.o' is incompatible with i386:x86-64 output
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: final link failed: file in wrong format
collect2: error: ld returned 1 exit status
clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/kwork_trace.bpf.o] Error 1
/usr/bin/ld: bpf architecture of input file `/tmp/off_cpu-1cb75d.o' is incompatible with i386:x86-64 output
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: final link failed: file in wrong format
collect2: error: ld returned 1 exit status
clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/off_cpu.bpf.o] Error 1
/usr/bin/ld: bpf architecture of input file `/tmp/bperf_cgroup-45eb44.o' is incompatible with i386:x86-64 output
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: final link failed: file in wrong format
collect2: error: ld returned 1 exit status
clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o] Error 1
make[3]: *** [Makefile.perf:236: sub-make] Error 2
make[2]: *** [Makefile:70: all] Error 2
make[1]: *** [tests/make:326: make_libbpf_dynamic_O] Error 1
make: *** [Makefile:103: build-test] Error 2
make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'

real	5m55.192s
user	62m31.596s
sys	14m30.828s
⬢[acme@toolbox perf-tools-next]$



^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
  2023-03-13 20:19   ` Arnaldo Carvalho de Melo
@ 2023-03-13 20:27     ` Ian Rogers
  2023-03-13 20:34       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-13 20:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

On Mon, Mar 13, 2023 at 1:19 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Em Fri, Mar 10, 2023 at 10:57:42PM -0800, Ian Rogers escreveu:
> > BPF skeleton support is now key to a number of perf features. Rather
> > than making it so that BPF support must be enabled for the build, make
> > this the default and error if the build lacks a clang and libbpf that
> > are sufficient. To avoid the error and build without BPF skeletons the
> > NO_BPF_SKEL=1 flag can be used. Add a build-options flag to 'perf
> > version' to enable detection of the BPF skeleton support and use this
> > in the offcpu shell test.
>
> Checking this:
>
> cd . && make LIBBPF_DYNAMIC=1 FEATURES_DUMP=/var/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.Rr5xDuXo13 DESTDIR=/tmp/tmp.cYdDvy09eY
>   BUILD:   Doing 'make -j32' parallel build
>   HOSTCC  /tmp/tmp.Rr5xDuXo13/fixdep.o
>   HOSTLD  /tmp/tmp.Rr5xDuXo13/fixdep-in.o
>   LINK    /tmp/tmp.Rr5xDuXo13/fixdep
> Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
> diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
> Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
> diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
> Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
> diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
> Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
> diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
> Makefile.config:1130: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel
>
>   GEN     /tmp/tmp.Rr5xDuXo13/common-cmds.h
>   CC      /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-test-api-v0.o
>   CC      /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-show-cycles.o
>   LINK    /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-test-api-v0.so
>   LINK    /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-show-cycles.so
>   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/exec-cmd.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/help.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/pager.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/parse-options.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/run-command.h
>   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/exec-cmd.o
>   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/help.o
>   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/pager.o
>   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/parse-options.o
>   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/run-command.o
>   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/sigchain.o
>   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/subcmd-config.o
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/
>   INSTALL libsubcmd_headers
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/hashmap.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/relo_core.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_internal.h
>   PERF_VERSION = 6.3.rc1.g0b82b38b7b56
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/bpf_perf.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/core.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/cpumap.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/threadmap.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libsymbol/include/symbol/kallsyms.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/cpu.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/evlist.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/debug.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/evsel.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/io.h
>   GEN     perf-archive
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/event.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fd/array.h
>   GEN     perf-iostat
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/mmap.h
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/core.o
>   CC      /tmp/tmp.Rr5xDuXo13/libsymbol/kallsyms.o
>   CC      /tmp/tmp.Rr5xDuXo13/libapi/cpu.o
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/cpumap.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fs/fs.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fs/tracing_path.h
>   MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fd/
>   CC      /tmp/tmp.Rr5xDuXo13/libapi/debug.o
>   CC      /tmp/tmp.Rr5xDuXo13/libapi/str_error_r.o
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/cpumap.o
>   INSTALL libsymbol_headers
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/evlist.h
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/threadmap.o
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/evsel.h
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/evsel.o
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/lib.h
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/evlist.o
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/mmap.h
>   MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fs/
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/threadmap.h
>   CC      /tmp/tmp.Rr5xDuXo13/libapi/fd/array.o
>   MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fs/
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/mmap.o
>   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/xyarray.h
>   CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/fs.o
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/zalloc.o
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/xyarray.o
>   CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/cgroup.o
>   CC      /tmp/tmp.Rr5xDuXo13/libperf/lib.o
>   INSTALL libapi_headers
>   CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/tracing_path.o
>   INSTALL libperf_headers
>   GEN     /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/bpf_helper_defs.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/btf.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_common.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_legacy.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helpers.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_tracing.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_endian.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_core_read.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/skel_internal.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_version.h
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/usdt.bpf.h
>   LD      /tmp/tmp.Rr5xDuXo13/libapi/fd/libapi-in.o
>   LD      /tmp/tmp.Rr5xDuXo13/libsymbol/libsymbol-in.o
>   AR      /tmp/tmp.Rr5xDuXo13/libsymbol/libsymbol.a
>   LD      /tmp/tmp.Rr5xDuXo13/libapi/fs/libapi-in.o
>   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helper_defs.h
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   INSTALL libbpf_headers
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   LD      /tmp/tmp.Rr5xDuXo13/libapi/libapi-in.o
>   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_probes.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/hashmap.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/nlattr.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf_dump.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_errno.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/str_error.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/netlink.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/ringbuf.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf_prog_linfo.o
>   LD      /tmp/tmp.Rr5xDuXo13/libperf/libperf-in.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/strset.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/linker.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/gen_loader.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/relo_core.o
>   AR      /tmp/tmp.Rr5xDuXo13/libapi/libapi.a
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/usdt.o
>   AR      /tmp/tmp.Rr5xDuXo13/libperf/libperf.a
>   LD      /tmp/tmp.Rr5xDuXo13/libsubcmd/libsubcmd-in.o
>   AR      /tmp/tmp.Rr5xDuXo13/libsubcmd/libsubcmd.a
>   GEN     /tmp/tmp.Rr5xDuXo13/python/perf.cpython-311-x86_64-linux-gnu.so
>   LD      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf-in.o
>   LINK    /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/libbpf.a
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/main.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/common.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/json_writer.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/gen.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/btf.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/xlated_dumper.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/btf_dumper.o
>   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/disasm.o
>   LINK    /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/bpftool
>   GEN     /tmp/tmp.Rr5xDuXo13/util/bpf_skel/vmlinux.h
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_leader.bpf.o
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_follower.bpf.o
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/func_latency.bpf.o
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/off_cpu.bpf.o
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/lock_contention.bpf.o
>   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/kwork_trace.bpf.o
> util/bpf_skel/lock_contention.bpf.c:192:7: error: call to undeclared function 'bpf_core_type_matches'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
>                 if (bpf_core_type_matches(struct rw_semaphore___old)) {
>                     ^
> util/bpf_skel/lock_contention.bpf.c:192:29: error: expected expression
>                 if (bpf_core_type_matches(struct rw_semaphore___old)) {
>                                           ^
> util/bpf_skel/lock_contention.bpf.c:195:36: error: expected expression
>                 } else if (bpf_core_type_matches(struct rw_semaphore___new)) {
>                                                  ^
> 3 errors generated.
> /usr/bin/ld: bpf architecture of input file `/tmp/bperf_follower-74fba5.o' is incompatible with i386:x86-64 output
> /usr/bin/ld: bpf architecture of input file `/tmp/bperf_leader-b2ec61.o' is incompatible with i386:x86-64 output
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> (.text+0x1b): undefined reference to `main'
> /usr/bin/ld: final link failed: file in wrong format
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> (.text+0x1b): undefined reference to `main'
> /usr/bin/ld: final link failed: file in wrong format
> collect2: error: ld returned 1 exit status
> collect2: error: ld returned 1 exit status
> clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> /usr/bin/ld: bpf architecture of input file `/tmp/func_latency-70b7d4.o' is incompatible with i386:x86-64 output
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/lock_contention.bpf.o] Error 1
> make[4]: *** Waiting for unfinished jobs....
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_follower.bpf.o] Error 1
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_leader.bpf.o] Error 1
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> (.text+0x1b): undefined reference to `main'
> /usr/bin/ld: final link failed: file in wrong format
> collect2: error: ld returned 1 exit status
> clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/func_latency.bpf.o] Error 1
> /usr/bin/ld: bpf architecture of input file `/tmp/bpf_prog_profiler-6e9720.o' is incompatible with i386:x86-64 output
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> (.text+0x1b): undefined reference to `main'
> /usr/bin/ld: final link failed: file in wrong format
> collect2: error: ld returned 1 exit status
> clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o] Error 1
> /usr/bin/ld: bpf architecture of input file `/tmp/kwork_trace-8d5b4e.o' is incompatible with i386:x86-64 output
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> (.text+0x1b): undefined reference to `main'
> /usr/bin/ld: final link failed: file in wrong format
> collect2: error: ld returned 1 exit status
> clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/kwork_trace.bpf.o] Error 1
> /usr/bin/ld: bpf architecture of input file `/tmp/off_cpu-1cb75d.o' is incompatible with i386:x86-64 output
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> (.text+0x1b): undefined reference to `main'
> /usr/bin/ld: final link failed: file in wrong format
> collect2: error: ld returned 1 exit status
> clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/off_cpu.bpf.o] Error 1
> /usr/bin/ld: bpf architecture of input file `/tmp/bperf_cgroup-45eb44.o' is incompatible with i386:x86-64 output
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> (.text+0x1b): undefined reference to `main'
> /usr/bin/ld: final link failed: file in wrong format
> collect2: error: ld returned 1 exit status
> clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o] Error 1
> make[3]: *** [Makefile.perf:236: sub-make] Error 2
> make[2]: *** [Makefile:70: all] Error 2
> make[1]: *** [tests/make:326: make_libbpf_dynamic_O] Error 1
> make: *** [Makefile:103: build-test] Error 2
> make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'
>
> real    5m55.192s
> user    62m31.596s
> sys     14m30.828s
> ⬢[acme@toolbox perf-tools-next]$

Sorry, I was testing this on top of:
https://lore.kernel.org/lkml/20230116010115.490713-1-irogers@google.com/
The issue being that we're trying to use an old libbpf that the has
meant disabling things but:
  NO_BPF_SKEL := 1
hadn't been set as part of this. I can address in v2, but with the
"assume libbpf 1.0+" patch I hadn't been worrying about this as we'd
error out for this case  - rather than build error. The erroring out
can be worked around by just not having libbpf be dynamic (ie static
or not at all by adding NO_LIBBPF=1).

Thanks,
Ian

>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
  2023-03-13 20:27     ` Ian Rogers
@ 2023-03-13 20:34       ` Arnaldo Carvalho de Melo
  2023-03-13 20:59         ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 20:34 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Mon, Mar 13, 2023 at 01:27:21PM -0700, Ian Rogers escreveu:
> On Mon, Mar 13, 2023 at 1:19 PM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > Em Fri, Mar 10, 2023 at 10:57:42PM -0800, Ian Rogers escreveu:
> > > BPF skeleton support is now key to a number of perf features. Rather
> > > than making it so that BPF support must be enabled for the build, make
> > > this the default and error if the build lacks a clang and libbpf that
> > > are sufficient. To avoid the error and build without BPF skeletons the
> > > NO_BPF_SKEL=1 flag can be used. Add a build-options flag to 'perf
> > > version' to enable detection of the BPF skeleton support and use this
> > > in the offcpu shell test.
> >
> > Checking this:
> >
> > cd . && make LIBBPF_DYNAMIC=1 FEATURES_DUMP=/var/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.Rr5xDuXo13 DESTDIR=/tmp/tmp.cYdDvy09eY
> >   BUILD:   Doing 'make -j32' parallel build
> >   HOSTCC  /tmp/tmp.Rr5xDuXo13/fixdep.o
> >   HOSTLD  /tmp/tmp.Rr5xDuXo13/fixdep-in.o
> >   LINK    /tmp/tmp.Rr5xDuXo13/fixdep
> > Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
> > diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
> > Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
> > diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
> > Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
> > diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
> > Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
> > diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
> > Makefile.config:1130: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel
> >
> >   GEN     /tmp/tmp.Rr5xDuXo13/common-cmds.h
> >   CC      /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-test-api-v0.o
> >   CC      /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-show-cycles.o
> >   LINK    /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-test-api-v0.so
> >   LINK    /tmp/tmp.Rr5xDuXo13/dlfilters/dlfilter-show-cycles.so
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/exec-cmd.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/help.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/pager.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/parse-options.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libsubcmd/include/subcmd/run-command.h
> >   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/exec-cmd.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/help.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/pager.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/parse-options.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/run-command.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/sigchain.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libsubcmd/subcmd-config.o
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/
> >   INSTALL libsubcmd_headers
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/hashmap.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/relo_core.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_internal.h
> >   PERF_VERSION = 6.3.rc1.g0b82b38b7b56
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/bpf_perf.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/core.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/cpumap.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/threadmap.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libsymbol/include/symbol/kallsyms.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/cpu.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/evlist.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/debug.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/evsel.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/io.h
> >   GEN     perf-archive
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/event.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fd/array.h
> >   GEN     perf-iostat
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/perf/mmap.h
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/core.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libsymbol/kallsyms.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libapi/cpu.o
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/cpumap.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fs/fs.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libapi/include/api/fs/tracing_path.h
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fd/
> >   CC      /tmp/tmp.Rr5xDuXo13/libapi/debug.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libapi/str_error_r.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/cpumap.o
> >   INSTALL libsymbol_headers
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/evlist.h
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/threadmap.o
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/evsel.h
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/evsel.o
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/lib.h
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/evlist.o
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/mmap.h
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fs/
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/threadmap.h
> >   CC      /tmp/tmp.Rr5xDuXo13/libapi/fd/array.o
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/libapi/fs/
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/mmap.o
> >   INSTALL /tmp/tmp.Rr5xDuXo13/libperf/include/internal/xyarray.h
> >   CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/fs.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/zalloc.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/xyarray.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/cgroup.o
> >   CC      /tmp/tmp.Rr5xDuXo13/libperf/lib.o
> >   INSTALL libapi_headers
> >   CC      /tmp/tmp.Rr5xDuXo13/libapi/fs/tracing_path.o
> >   INSTALL libperf_headers
> >   GEN     /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/bpf_helper_defs.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/btf.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_common.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_legacy.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helpers.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_tracing.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_endian.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_core_read.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/skel_internal.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/libbpf_version.h
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/usdt.bpf.h
> >   LD      /tmp/tmp.Rr5xDuXo13/libapi/fd/libapi-in.o
> >   LD      /tmp/tmp.Rr5xDuXo13/libsymbol/libsymbol-in.o
> >   AR      /tmp/tmp.Rr5xDuXo13/libsymbol/libsymbol.a
> >   LD      /tmp/tmp.Rr5xDuXo13/libapi/fs/libapi-in.o
> >   INSTALL /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/include/bpf/bpf_helper_defs.h
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   INSTALL libbpf_headers
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   LD      /tmp/tmp.Rr5xDuXo13/libapi/libapi-in.o
> >   MKDIR   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_probes.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/hashmap.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/nlattr.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf_dump.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/btf.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf_errno.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/str_error.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/netlink.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/ringbuf.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/bpf_prog_linfo.o
> >   LD      /tmp/tmp.Rr5xDuXo13/libperf/libperf-in.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/strset.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/linker.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/gen_loader.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/relo_core.o
> >   AR      /tmp/tmp.Rr5xDuXo13/libapi/libapi.a
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/usdt.o
> >   AR      /tmp/tmp.Rr5xDuXo13/libperf/libperf.a
> >   LD      /tmp/tmp.Rr5xDuXo13/libsubcmd/libsubcmd-in.o
> >   AR      /tmp/tmp.Rr5xDuXo13/libsubcmd/libsubcmd.a
> >   GEN     /tmp/tmp.Rr5xDuXo13/python/perf.cpython-311-x86_64-linux-gnu.so
> >   LD      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/staticobjs/libbpf-in.o
> >   LINK    /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/libbpf/libbpf.a
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/main.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/common.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/json_writer.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/gen.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/btf.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/xlated_dumper.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/btf_dumper.o
> >   CC      /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/disasm.o
> >   LINK    /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bootstrap/bpftool
> >   GEN     /tmp/tmp.Rr5xDuXo13/util/bpf_skel/vmlinux.h
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_leader.bpf.o
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_follower.bpf.o
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/func_latency.bpf.o
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/off_cpu.bpf.o
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/lock_contention.bpf.o
> >   CLANG   /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/kwork_trace.bpf.o
> > util/bpf_skel/lock_contention.bpf.c:192:7: error: call to undeclared function 'bpf_core_type_matches'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
> >                 if (bpf_core_type_matches(struct rw_semaphore___old)) {
> >                     ^
> > util/bpf_skel/lock_contention.bpf.c:192:29: error: expected expression
> >                 if (bpf_core_type_matches(struct rw_semaphore___old)) {
> >                                           ^
> > util/bpf_skel/lock_contention.bpf.c:195:36: error: expected expression
> >                 } else if (bpf_core_type_matches(struct rw_semaphore___new)) {
> >                                                  ^
> > 3 errors generated.
> > /usr/bin/ld: bpf architecture of input file `/tmp/bperf_follower-74fba5.o' is incompatible with i386:x86-64 output
> > /usr/bin/ld: bpf architecture of input file `/tmp/bperf_leader-b2ec61.o' is incompatible with i386:x86-64 output
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> > (.text+0x1b): undefined reference to `main'
> > /usr/bin/ld: final link failed: file in wrong format
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> > (.text+0x1b): undefined reference to `main'
> > /usr/bin/ld: final link failed: file in wrong format
> > collect2: error: ld returned 1 exit status
> > collect2: error: ld returned 1 exit status
> > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > /usr/bin/ld: bpf architecture of input file `/tmp/func_latency-70b7d4.o' is incompatible with i386:x86-64 output
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/lock_contention.bpf.o] Error 1
> > make[4]: *** Waiting for unfinished jobs....
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_follower.bpf.o] Error 1
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_leader.bpf.o] Error 1
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> > (.text+0x1b): undefined reference to `main'
> > /usr/bin/ld: final link failed: file in wrong format
> > collect2: error: ld returned 1 exit status
> > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/func_latency.bpf.o] Error 1
> > /usr/bin/ld: bpf architecture of input file `/tmp/bpf_prog_profiler-6e9720.o' is incompatible with i386:x86-64 output
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> > (.text+0x1b): undefined reference to `main'
> > /usr/bin/ld: final link failed: file in wrong format
> > collect2: error: ld returned 1 exit status
> > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o] Error 1
> > /usr/bin/ld: bpf architecture of input file `/tmp/kwork_trace-8d5b4e.o' is incompatible with i386:x86-64 output
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> > (.text+0x1b): undefined reference to `main'
> > /usr/bin/ld: final link failed: file in wrong format
> > collect2: error: ld returned 1 exit status
> > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/kwork_trace.bpf.o] Error 1
> > /usr/bin/ld: bpf architecture of input file `/tmp/off_cpu-1cb75d.o' is incompatible with i386:x86-64 output
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> > (.text+0x1b): undefined reference to `main'
> > /usr/bin/ld: final link failed: file in wrong format
> > collect2: error: ld returned 1 exit status
> > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/off_cpu.bpf.o] Error 1
> > /usr/bin/ld: bpf architecture of input file `/tmp/bperf_cgroup-45eb44.o' is incompatible with i386:x86-64 output
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o: in function `_start':
> > (.text+0x1b): undefined reference to `main'
> > /usr/bin/ld: final link failed: file in wrong format
> > collect2: error: ld returned 1 exit status
> > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o] Error 1
> > make[3]: *** [Makefile.perf:236: sub-make] Error 2
> > make[2]: *** [Makefile:70: all] Error 2
> > make[1]: *** [tests/make:326: make_libbpf_dynamic_O] Error 1
> > make: *** [Makefile:103: build-test] Error 2
> > make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'
> >
> > real    5m55.192s
> > user    62m31.596s
> > sys     14m30.828s
> > ⬢[acme@toolbox perf-tools-next]$
> 
> Sorry, I was testing this on top of:
> https://lore.kernel.org/lkml/20230116010115.490713-1-irogers@google.com/
> The issue being that we're trying to use an old libbpf that the has
> meant disabling things but:
>   NO_BPF_SKEL := 1
> hadn't been set as part of this. I can address in v2, but with the
> "assume libbpf 1.0+" patch I hadn't been worrying about this as we'd
> error out for this case  - rather than build error. The erroring out
> can be worked around by just not having libbpf be dynamic (ie static
> or not at all by adding NO_LIBBPF=1).

I'll try adding that 3-patch series before this one.

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
  2023-03-13 20:34       ` Arnaldo Carvalho de Melo
@ 2023-03-13 20:59         ` Arnaldo Carvalho de Melo
  2023-03-13 21:05           ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 20:59 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Mon, Mar 13, 2023 at 05:34:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Mar 13, 2023 at 01:27:21PM -0700, Ian Rogers escreveu:
> > On Mon, Mar 13, 2023 at 1:19 PM Arnaldo Carvalho de Melo
> > > (.text+0x1b): undefined reference to `main'
> > > /usr/bin/ld: final link failed: file in wrong format
> > > collect2: error: ld returned 1 exit status
> > > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o] Error 1
> > > make[3]: *** [Makefile.perf:236: sub-make] Error 2
> > > make[2]: *** [Makefile:70: all] Error 2
> > > make[1]: *** [tests/make:326: make_libbpf_dynamic_O] Error 1
> > > make: *** [Makefile:103: build-test] Error 2
> > > make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'
> > >
> > > real    5m55.192s
> > > user    62m31.596s
> > > sys     14m30.828s
> > > ⬢[acme@toolbox perf-tools-next]$
> > 
> > Sorry, I was testing this on top of:
> > https://lore.kernel.org/lkml/20230116010115.490713-1-irogers@google.com/
> > The issue being that we're trying to use an old libbpf that the has
> > meant disabling things but:
> >   NO_BPF_SKEL := 1
> > hadn't been set as part of this. I can address in v2, but with the
> > "assume libbpf 1.0+" patch I hadn't been worrying about this as we'd
> > error out for this case  - rather than build error. The erroring out
> > can be worked around by just not having libbpf be dynamic (ie static
> > or not at all by adding NO_LIBBPF=1).
> 
> I'll try adding that 3-patch series before this one.

⬢[acme@toolbox perf-tools-next]$ git log --oneline -16
76c8a07f51703787 (HEAD -> perf-tools-next) perf build: Error if no libelf and NO_LIBELF isn't set
030a6c72b38e334d perf build: Remove redundant NO_NEWT build option
5d1360fc84cd2e3b perf build: If libtraceevent isn't present error the build
e25e0db4700aa39a perf build: Switch libpfm4 to opt-out rather than opt-in
39f53202a8961d3d perf symbol: Add abi::__cxa_demangle C++ demangling support
d857f258f3d1214a tools build: Add feature test for abi::__cxa_demangle
7aae0d8341c9c373 perf build: Make binutil libraries opt in
dc4890e772aba1e9 perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set
334e64172816623d perf util: Remove weak sched_getcpu
e44d7e7c60fc4ded perf build: Remove unused HAVE_GLIBC_SUPPORT
14ea53be45758450 perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
eb03903c5c119254 perf build: Support python/perf.so testing
f8b579c1996ba4a9 perf bpf: Remove pre libbpf 1.0 conditional logic
2cce43c63d4d0abc perf build: Remove libbpf pre-1.0 feature tests
a24ebff6cce14a34 tools build: Pass libbpf feature only if libbpf 1.0+
17535a33a9c1e4fb perf lock contention: Fix compiler builtin detection
⬢[acme@toolbox perf-tools-next]$

       make_libbpf_dynamic_O: cd . && make LIBBPF_DYNAMIC=1 FEATURES_DUMP=/var/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.cO9WpgtAvo DESTDIR=/tmp/tmp.jjguTPlLWt
ldd: /tmp/tmp.cO9WpgtAvo/perf: No such file or directory
cd . && make LIBBPF_DYNAMIC=1 FEATURES_DUMP=/var/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.cO9WpgtAvo DESTDIR=/tmp/tmp.jjguTPlLWt
  BUILD:   Doing 'make -j32' parallel build
  HOSTCC  /tmp/tmp.cO9WpgtAvo/fixdep.o
  HOSTLD  /tmp/tmp.cO9WpgtAvo/fixdep-in.o
  LINK    /tmp/tmp.cO9WpgtAvo/fixdep
Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
Makefile.config:563: *** Error: No libbpf devel library found, please install libbpf-devel.  Stop.
make[3]: *** [Makefile.perf:236: sub-make] Error 2
make[2]: *** [Makefile:70: all] Error 2
make[1]: *** [tests/make:326: make_libbpf_dynamic_O] Error 1


But:

⬢[acme@toolbox perf-tools-next]$ rpm -qa | grep libbpf
libbpf-0.8.0-2.fc37.x86_64
libbpf-devel-0.8.0-2.fc37.x86_64
⬢[acme@toolbox perf-tools-next]$

⬢[acme@toolbox perf-tools-next]$ cat /etc/os-release
NAME="Fedora Linux"
VERSION="37 (Container Image)"


I'll see if this is just a matter of tweaking the error message to
something like "libbpf-devel not found or older than 1.0.0, please install/update"

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
  2023-03-13 20:59         ` Arnaldo Carvalho de Melo
@ 2023-03-13 21:05           ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 21:05 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Mon, Mar 13, 2023 at 05:59:35PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, Mar 13, 2023 at 05:34:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Mon, Mar 13, 2023 at 01:27:21PM -0700, Ian Rogers escreveu:
> > > On Mon, Mar 13, 2023 at 1:19 PM Arnaldo Carvalho de Melo
> > > > (.text+0x1b): undefined reference to `main'
> > > > /usr/bin/ld: final link failed: file in wrong format
> > > > collect2: error: ld returned 1 exit status
> > > > clang-15: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
> > > > make[4]: *** [Makefile.perf:1081: /tmp/tmp.Rr5xDuXo13/util/bpf_skel/.tmp/bperf_cgroup.bpf.o] Error 1
> > > > make[3]: *** [Makefile.perf:236: sub-make] Error 2
> > > > make[2]: *** [Makefile:70: all] Error 2
> > > > make[1]: *** [tests/make:326: make_libbpf_dynamic_O] Error 1
> > > > make: *** [Makefile:103: build-test] Error 2
> > > > make: Leaving directory '/var/home/acme/git/perf-tools-next/tools/perf'
> > > >
> > > > real    5m55.192s
> > > > user    62m31.596s
> > > > sys     14m30.828s
> > > > ⬢[acme@toolbox perf-tools-next]$
> > > 
> > > Sorry, I was testing this on top of:
> > > https://lore.kernel.org/lkml/20230116010115.490713-1-irogers@google.com/
> > > The issue being that we're trying to use an old libbpf that the has
> > > meant disabling things but:
> > >   NO_BPF_SKEL := 1
> > > hadn't been set as part of this. I can address in v2, but with the
> > > "assume libbpf 1.0+" patch I hadn't been worrying about this as we'd
> > > error out for this case  - rather than build error. The erroring out
> > > can be worked around by just not having libbpf be dynamic (ie static
> > > or not at all by adding NO_LIBBPF=1).
> > 
> > I'll try adding that 3-patch series before this one.
> 
> ⬢[acme@toolbox perf-tools-next]$ git log --oneline -16
> 76c8a07f51703787 (HEAD -> perf-tools-next) perf build: Error if no libelf and NO_LIBELF isn't set
> 030a6c72b38e334d perf build: Remove redundant NO_NEWT build option
> 5d1360fc84cd2e3b perf build: If libtraceevent isn't present error the build
> e25e0db4700aa39a perf build: Switch libpfm4 to opt-out rather than opt-in
> 39f53202a8961d3d perf symbol: Add abi::__cxa_demangle C++ demangling support
> d857f258f3d1214a tools build: Add feature test for abi::__cxa_demangle
> 7aae0d8341c9c373 perf build: Make binutil libraries opt in
> dc4890e772aba1e9 perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set
> 334e64172816623d perf util: Remove weak sched_getcpu
> e44d7e7c60fc4ded perf build: Remove unused HAVE_GLIBC_SUPPORT
> 14ea53be45758450 perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL
> eb03903c5c119254 perf build: Support python/perf.so testing
> f8b579c1996ba4a9 perf bpf: Remove pre libbpf 1.0 conditional logic
> 2cce43c63d4d0abc perf build: Remove libbpf pre-1.0 feature tests
> a24ebff6cce14a34 tools build: Pass libbpf feature only if libbpf 1.0+
> 17535a33a9c1e4fb perf lock contention: Fix compiler builtin detection
> ⬢[acme@toolbox perf-tools-next]$
> 
>        make_libbpf_dynamic_O: cd . && make LIBBPF_DYNAMIC=1 FEATURES_DUMP=/var/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.cO9WpgtAvo DESTDIR=/tmp/tmp.jjguTPlLWt
> ldd: /tmp/tmp.cO9WpgtAvo/perf: No such file or directory
> cd . && make LIBBPF_DYNAMIC=1 FEATURES_DUMP=/var/home/acme/git/perf-tools-next/tools/perf/BUILD_TEST_FEATURE_DUMP -j32 O=/tmp/tmp.cO9WpgtAvo DESTDIR=/tmp/tmp.jjguTPlLWt
>   BUILD:   Doing 'make -j32' parallel build
>   HOSTCC  /tmp/tmp.cO9WpgtAvo/fixdep.o
>   HOSTLD  /tmp/tmp.cO9WpgtAvo/fixdep-in.o
>   LINK    /tmp/tmp.cO9WpgtAvo/fixdep
> Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h'
> diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
> Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
> diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
> Warning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h'
> diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
> Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h' differs from latest version at 'include/linux/coresight-pmu.h'
> diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
> Makefile.config:563: *** Error: No libbpf devel library found, please install libbpf-devel.  Stop.
> make[3]: *** [Makefile.perf:236: sub-make] Error 2
> make[2]: *** [Makefile:70: all] Error 2
> make[1]: *** [tests/make:326: make_libbpf_dynamic_O] Error 1
> 
> 
> But:
> 
> ⬢[acme@toolbox perf-tools-next]$ rpm -qa | grep libbpf
> libbpf-0.8.0-2.fc37.x86_64
> libbpf-devel-0.8.0-2.fc37.x86_64
> ⬢[acme@toolbox perf-tools-next]$
> 
> ⬢[acme@toolbox perf-tools-next]$ cat /etc/os-release
> NAME="Fedora Linux"
> VERSION="37 (Container Image)"
> 
> 
> I'll see if this is just a matter of tweaking the error message to
> something like "libbpf-devel not found or older than 1.0.0, please install/update"

Yeah, I'll tweak the warning:

⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-libbpf.make.output
test-libbpf.c:5:2: error: #error At least libbpf 1.0 is required for Linux tools.
    5 | #error At least libbpf 1.0 is required for Linux tools.
      |  ^~~~~
⬢[acme@toolbox perf-tools-next]$

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 00/13] Perf tool build improvements
  2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
                   ` (12 preceding siblings ...)
  2023-03-11  6:57 ` [PATCH v1 13/13] perf build: Remove redundant NO_NEWT build option Ian Rogers
@ 2023-03-14 12:11 ` Arnaldo Carvalho de Melo
  2023-03-14 12:12   ` Arnaldo Carvalho de Melo
  2023-03-14 12:21   ` Adrian Hunter
  13 siblings, 2 replies; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-14 12:11 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Fri, Mar 10, 2023 at 10:57:40PM -0800, Ian Rogers escreveu:
> Make the default build options a more preferred set, such as making
> BPF skeletons default and failing the build if jevents or libtracevent
> dependencies fail. The binutil dependencies are opt-in given license
> restrictions. abi::__cxa_demangle demangling support is added so that
> libiberty, from binutils, isn't necessary for C++ demangling.
> 
> Some build/test dependencies are fixed and the code cleaned up.

I'll continue fixing more stuff, like adding NO_LIBTRACEEVENT=1 to
things like amazonlinux devel, that still doesn't package libtraceevent,
but so far...

[perfbuilder@five ~]$ export BUILD_TARBALL=http://192.168.86.10/perf/perf-6.3.0-rc1.tar.xz
[perfbuilder@five ~]$ time dm
   1     5.58 almalinux:8                   : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
   2     5.38 almalinux:9                   : FAIL gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)
   3     4.57 alpine:3.15                   : FAIL gcc version 10.3.1 20211027 (Alpine 10.3.1_git20211027)
   4     4.27 alpine:3.16                   : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219)
   5     4.27 alpine:3.17                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4)
   6     4.67 alpine:edge                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r9)
   7     4.47 alt:p9                        : FAIL gcc version 8.4.1 20200305 (ALT p9 8.4.1-alt0.p9.1) (GCC)
   8     4.58 alt:p10                       : FAIL gcc version 10.3.1 20210703 (ALT Sisyphus 10.3.1-alt2) (GCC)
   9     4.57 alt:sisyphus                  : FAIL gcc version 12.1.1 20220518 (ALT Sisyphus 12.1.1-alt2) (GCC)
  10     3.97 amazonlinux:2                 : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-15) (GCC)
  11     5.77 amazonlinux:devel             : FAIL gcc version 11.3.1 20220421 (Red Hat 11.3.1-2) (GCC)
  12   160.30 archlinux:base                : Ok   gcc (GCC) 12.2.0 , clang version 14.0.6
  13     4.68 centos:8                      : FAIL gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)
  14     5.07 centos:stream                 : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)
  15     5.27 clearlinux:latest             : FAIL gcc version 12.2.1 20230202 releases/gcc-12.2.0-400-gd31bd71386 (Clear Linux OS for Intel Architecture)
  16     3.37 debian:10                     : FAIL gcc version 8.3.0 (Debian 8.3.0-6)
  17     3.57 debian:11                     : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
  18     4.08 debian:experimental           : FAIL gcc version 12.2.0 (Debian 12.2.0-10)
  19     3.78 debian:experimental-x-arm64   : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
  20     2.77 debian:experimental-x-mips    : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
  21     3.47 debian:experimental-x-mips64  : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
  22     3.47 debian:experimental-x-mipsel  : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
  23     4.37 fedora:26                     : FAIL gcc version 7.3.1 20180130 (Red Hat 7.3.1-2) (GCC)
  24     4.27 fedora:27                     : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-6) (GCC)
  25     4.27 fedora:28                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
  26     4.87 fedora:29                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
  27     4.97 fedora:30                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
  28     5.38 fedora:31                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
  29     5.48 fedora:32                     : FAIL gcc version 10.3.1 20210422 (Red Hat 10.3.1-1) (GCC)


Yeah, I'll take the opportunity and prune the older ones.

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 00/13] Perf tool build improvements
  2023-03-14 12:11 ` [PATCH v1 00/13] Perf tool build improvements Arnaldo Carvalho de Melo
@ 2023-03-14 12:12   ` Arnaldo Carvalho de Melo
  2023-03-14 12:27     ` Arnaldo Carvalho de Melo
  2023-03-14 12:21   ` Adrian Hunter
  1 sibling, 1 reply; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-14 12:12 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Tue, Mar 14, 2023 at 09:11:04AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Mar 10, 2023 at 10:57:40PM -0800, Ian Rogers escreveu:
> > Make the default build options a more preferred set, such as making
> > BPF skeletons default and failing the build if jevents or libtracevent
> > dependencies fail. The binutil dependencies are opt-in given license
> > restrictions. abi::__cxa_demangle demangling support is added so that
> > libiberty, from binutils, isn't necessary for C++ demangling.
> > 
> > Some build/test dependencies are fixed and the code cleaned up.
> 
> I'll continue fixing more stuff, like adding NO_LIBTRACEEVENT=1 to
> things like amazonlinux devel, that still doesn't package libtraceevent,
> but so far...
> 
> [perfbuilder@five ~]$ export BUILD_TARBALL=http://192.168.86.10/perf/perf-6.3.0-rc1.tar.xz
> [perfbuilder@five ~]$ time dm
>    1     5.58 almalinux:8                   : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
>    2     5.38 almalinux:9                   : FAIL gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)
>    3     4.57 alpine:3.15                   : FAIL gcc version 10.3.1 20211027 (Alpine 10.3.1_git20211027)
>    4     4.27 alpine:3.16                   : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219)
>    5     4.27 alpine:3.17                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4)
>    6     4.67 alpine:edge                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r9)
>    7     4.47 alt:p9                        : FAIL gcc version 8.4.1 20200305 (ALT p9 8.4.1-alt0.p9.1) (GCC)
>    8     4.58 alt:p10                       : FAIL gcc version 10.3.1 20210703 (ALT Sisyphus 10.3.1-alt2) (GCC)
>    9     4.57 alt:sisyphus                  : FAIL gcc version 12.1.1 20220518 (ALT Sisyphus 12.1.1-alt2) (GCC)
>   10     3.97 amazonlinux:2                 : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-15) (GCC)
>   11     5.77 amazonlinux:devel             : FAIL gcc version 11.3.1 20220421 (Red Hat 11.3.1-2) (GCC)
>   12   160.30 archlinux:base                : Ok   gcc (GCC) 12.2.0 , clang version 14.0.6
>   13     4.68 centos:8                      : FAIL gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)
>   14     5.07 centos:stream                 : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)
>   15     5.27 clearlinux:latest             : FAIL gcc version 12.2.1 20230202 releases/gcc-12.2.0-400-gd31bd71386 (Clear Linux OS for Intel Architecture)
>   16     3.37 debian:10                     : FAIL gcc version 8.3.0 (Debian 8.3.0-6)
>   17     3.57 debian:11                     : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
>   18     4.08 debian:experimental           : FAIL gcc version 12.2.0 (Debian 12.2.0-10)
>   19     3.78 debian:experimental-x-arm64   : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
>   20     2.77 debian:experimental-x-mips    : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
>   21     3.47 debian:experimental-x-mips64  : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
>   22     3.47 debian:experimental-x-mipsel  : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
>   23     4.37 fedora:26                     : FAIL gcc version 7.3.1 20180130 (Red Hat 7.3.1-2) (GCC)
>   24     4.27 fedora:27                     : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-6) (GCC)
>   25     4.27 fedora:28                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
>   26     4.87 fedora:29                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
>   27     4.97 fedora:30                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
>   28     5.38 fedora:31                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
>   29     5.48 fedora:32                     : FAIL gcc version 10.3.1 20210422 (Red Hat 10.3.1-1) (GCC)
> 
> 
> Yeah, I'll take the opportunity and prune the older ones.

One more!

  30   181.19 fedora:33                     : Ok   gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1) , clang version 11.0.0 (Fedora 11.0.0-3.fc33)


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 00/13] Perf tool build improvements
  2023-03-14 12:11 ` [PATCH v1 00/13] Perf tool build improvements Arnaldo Carvalho de Melo
  2023-03-14 12:12   ` Arnaldo Carvalho de Melo
@ 2023-03-14 12:21   ` Adrian Hunter
  2023-03-14 12:28     ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 34+ messages in thread
From: Adrian Hunter @ 2023-03-14 12:21 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Leo Yan,
	Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

On 14/03/23 14:11, Arnaldo Carvalho de Melo wrote:
> Em Fri, Mar 10, 2023 at 10:57:40PM -0800, Ian Rogers escreveu:
>> Make the default build options a more preferred set, such as making
>> BPF skeletons default and failing the build if jevents or libtracevent
>> dependencies fail. The binutil dependencies are opt-in given license
>> restrictions. abi::__cxa_demangle demangling support is added so that
>> libiberty, from binutils, isn't necessary for C++ demangling.
>>
>> Some build/test dependencies are fixed and the code cleaned up.
> 
> I'll continue fixing more stuff, like adding NO_LIBTRACEEVENT=1 to
> things like amazonlinux devel, that still doesn't package libtraceevent,

FYI I'm currently testing a patch to allow python scripting without
also requiring libtraceevent


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 00/13] Perf tool build improvements
  2023-03-14 12:12   ` Arnaldo Carvalho de Melo
@ 2023-03-14 12:27     ` Arnaldo Carvalho de Melo
  2023-03-14 12:29       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-14 12:27 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Tue, Mar 14, 2023 at 09:12:03AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Mar 14, 2023 at 09:11:04AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Mar 10, 2023 at 10:57:40PM -0800, Ian Rogers escreveu:
> > > Make the default build options a more preferred set, such as making
> > > BPF skeletons default and failing the build if jevents or libtracevent
> > > dependencies fail. The binutil dependencies are opt-in given license
> > > restrictions. abi::__cxa_demangle demangling support is added so that
> > > libiberty, from binutils, isn't necessary for C++ demangling.
> > > 
> > > Some build/test dependencies are fixed and the code cleaned up.
> > 
> > I'll continue fixing more stuff, like adding NO_LIBTRACEEVENT=1 to
> > things like amazonlinux devel, that still doesn't package libtraceevent,
> > but so far...
> > 
> > [perfbuilder@five ~]$ export BUILD_TARBALL=http://192.168.86.10/perf/perf-6.3.0-rc1.tar.xz
> > [perfbuilder@five ~]$ time dm
> >    1     5.58 almalinux:8                   : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
> >    2     5.38 almalinux:9                   : FAIL gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)

This one seems to have an old libtraceevent, so this message:

Makefile.config:635: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
Makefile.config:1046: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev
Makefile.config:1137: libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev
Makefile.config:1155: *** ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel or build with NO_LIBTRACEEVENT=1.  Stop.

Has to change a bit, like for libbpf, I'll check

> >    3     4.57 alpine:3.15                   : FAIL gcc version 10.3.1 20211027 (Alpine 10.3.1_git20211027)
> >    4     4.27 alpine:3.16                   : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219)
> >    5     4.27 alpine:3.17                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4)
> >    6     4.67 alpine:edge                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r9)
> >    7     4.47 alt:p9                        : FAIL gcc version 8.4.1 20200305 (ALT p9 8.4.1-alt0.p9.1) (GCC)
> >    8     4.58 alt:p10                       : FAIL gcc version 10.3.1 20210703 (ALT Sisyphus 10.3.1-alt2) (GCC)
> >    9     4.57 alt:sisyphus                  : FAIL gcc version 12.1.1 20220518 (ALT Sisyphus 12.1.1-alt2) (GCC)
> >   10     3.97 amazonlinux:2                 : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-15) (GCC)
> >   11     5.77 amazonlinux:devel             : FAIL gcc version 11.3.1 20220421 (Red Hat 11.3.1-2) (GCC)
> >   12   160.30 archlinux:base                : Ok   gcc (GCC) 12.2.0 , clang version 14.0.6
> >   13     4.68 centos:8                      : FAIL gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)
> >   14     5.07 centos:stream                 : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)
> >   15     5.27 clearlinux:latest             : FAIL gcc version 12.2.1 20230202 releases/gcc-12.2.0-400-gd31bd71386 (Clear Linux OS for Intel Architecture)
> >   16     3.37 debian:10                     : FAIL gcc version 8.3.0 (Debian 8.3.0-6)
> >   17     3.57 debian:11                     : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
> >   18     4.08 debian:experimental           : FAIL gcc version 12.2.0 (Debian 12.2.0-10)
> >   19     3.78 debian:experimental-x-arm64   : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
> >   20     2.77 debian:experimental-x-mips    : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
> >   21     3.47 debian:experimental-x-mips64  : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
> >   22     3.47 debian:experimental-x-mipsel  : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
> >   23     4.37 fedora:26                     : FAIL gcc version 7.3.1 20180130 (Red Hat 7.3.1-2) (GCC)
> >   24     4.27 fedora:27                     : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-6) (GCC)
> >   25     4.27 fedora:28                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
> >   26     4.87 fedora:29                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
> >   27     4.97 fedora:30                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
> >   28     5.38 fedora:31                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
> >   29     5.48 fedora:32                     : FAIL gcc version 10.3.1 20210422 (Red Hat 10.3.1-1) (GCC)
> > 
> > 
> > Yeah, I'll take the opportunity and prune the older ones.
> 
> One more!
> 
>   30   181.19 fedora:33                     : Ok   gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1) , clang version 11.0.0 (Fedora 11.0.0-3.fc33)
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 00/13] Perf tool build improvements
  2023-03-14 12:21   ` Adrian Hunter
@ 2023-03-14 12:28     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-14 12:28 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Roberto Sassu, Quentin Monnet,
	Andres Freund, Tiezhu Yang, Pavithra Gurushankar, Yang Jihong,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Tue, Mar 14, 2023 at 02:21:23PM +0200, Adrian Hunter escreveu:
> On 14/03/23 14:11, Arnaldo Carvalho de Melo wrote:
> > Em Fri, Mar 10, 2023 at 10:57:40PM -0800, Ian Rogers escreveu:
> >> Make the default build options a more preferred set, such as making
> >> BPF skeletons default and failing the build if jevents or libtracevent
> >> dependencies fail. The binutil dependencies are opt-in given license
> >> restrictions. abi::__cxa_demangle demangling support is added so that
> >> libiberty, from binutils, isn't necessary for C++ demangling.
> >>
> >> Some build/test dependencies are fixed and the code cleaned up.
> > 
> > I'll continue fixing more stuff, like adding NO_LIBTRACEEVENT=1 to
> > things like amazonlinux devel, that still doesn't package libtraceevent,
> 
> FYI I'm currently testing a patch to allow python scripting without
> also requiring libtraceevent

Cool!

- Arnaldo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 00/13] Perf tool build improvements
  2023-03-14 12:27     ` Arnaldo Carvalho de Melo
@ 2023-03-14 12:29       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 34+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-14 12:29 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Nathan Chancellor, Nick Desaulniers,
	Tom Rix, Roberto Sassu, Quentin Monnet, Andres Freund,
	Tiezhu Yang, Pavithra Gurushankar, Yang Jihong, Adrian Hunter,
	Leo Yan, Martin Liška, linux-kernel, linux-perf-users, llvm,
	Stephane Eranian

Em Tue, Mar 14, 2023 at 09:27:46AM -0300, Arnaldo Carvalho de Melo escreveu:
> > >    3     4.57 alpine:3.15                   : FAIL gcc version 10.3.1 20211027 (Alpine 10.3.1_git20211027)
> > >    4     4.27 alpine:3.16                   : FAIL gcc version 11.2.1 20220219 (Alpine 11.2.1_git20220219)
> > >    5     4.27 alpine:3.17                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4)
> > >    6     4.67 alpine:edge                   : FAIL gcc version 12.2.1 20220924 (Alpine 12.2.1_git20220924-r9)
> > >    7     4.47 alt:p9                        : FAIL gcc version 8.4.1 20200305 (ALT p9 8.4.1-alt0.p9.1) (GCC)
> > >    8     4.58 alt:p10                       : FAIL gcc version 10.3.1 20210703 (ALT Sisyphus 10.3.1-alt2) (GCC)
> > >    9     4.57 alt:sisyphus                  : FAIL gcc version 12.1.1 20220518 (ALT Sisyphus 12.1.1-alt2) (GCC)
> > >   10     3.97 amazonlinux:2                 : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-15) (GCC)
> > >   11     5.77 amazonlinux:devel             : FAIL gcc version 11.3.1 20220421 (Red Hat 11.3.1-2) (GCC)
> > >   12   160.30 archlinux:base                : Ok   gcc (GCC) 12.2.0 , clang version 14.0.6
> > >   13     4.68 centos:8                      : FAIL gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)
> > >   14     5.07 centos:stream                 : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)
> > >   15     5.27 clearlinux:latest             : FAIL gcc version 12.2.1 20230202 releases/gcc-12.2.0-400-gd31bd71386 (Clear Linux OS for Intel Architecture)
> > >   16     3.37 debian:10                     : FAIL gcc version 8.3.0 (Debian 8.3.0-6)
> > >   17     3.57 debian:11                     : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
> > >   18     4.08 debian:experimental           : FAIL gcc version 12.2.0 (Debian 12.2.0-10)
> > >   19     3.78 debian:experimental-x-arm64   : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
> > >   20     2.77 debian:experimental-x-mips    : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
> > >   21     3.47 debian:experimental-x-mips64  : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
> > >   22     3.47 debian:experimental-x-mipsel  : FAIL gcc version 12.2.0 (Debian 12.2.0-14)
> > >   23     4.37 fedora:26                     : FAIL gcc version 7.3.1 20180130 (Red Hat 7.3.1-2) (GCC)
> > >   24     4.27 fedora:27                     : FAIL gcc version 7.3.1 20180712 (Red Hat 7.3.1-6) (GCC)
> > >   25     4.27 fedora:28                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
> > >   26     4.87 fedora:29                     : FAIL gcc version 8.3.1 20190223 (Red Hat 8.3.1-2) (GCC)
> > >   27     4.97 fedora:30                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
> > >   28     5.38 fedora:31                     : FAIL gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)
> > >   29     5.48 fedora:32                     : FAIL gcc version 10.3.1 20210422 (Red Hat 10.3.1-1) (GCC)
> > > 
> > > 
> > > Yeah, I'll take the opportunity and prune the older ones.
> > 
> > One more!
> > 
> >   30   181.19 fedora:33                     : Ok   gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1) , clang version 11.0.0 (Fedora 11.0.0-3.fc33)

 31   222.81 fedora:34                     : Ok   gcc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2) , clang version 12.0.1 (Fedora 12.0.1-1.fc34)
  32     3.07 fedora:34-x-ARC-glibc         : FAIL gcc version 8.3.1 20190225 (ARC HS GNU/Linux glibc toolchain 2019.03-rc1)
  33     2.67 fedora:34-x-ARC-uClibc        : FAIL gcc version 8.3.1 20190225 (ARCv2 ISA Linux uClibc toolchain 2019.03-rc1)
  34   182.17 fedora:35                     : Ok   gcc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-3) , clang version 13.0.1 (Fedora 13.0.1-1.fc35)
  35   180.73 fedora:36                     : Ok   gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4) , clang version 14.0.5 (Fedora 14.0.5-2.fc36)
  36   179.27 fedora:37                     : Ok   gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4) , clang version 15.0.7 (Fedora 15.0.7-1.fc37)
  37   169.45 fedora:38                     : Ok   gcc (GCC) 13.0.1 20230208 (Red Hat 13.0.1-0) , clang version 15.0.7 (Fedora 15.0.7-2.fc38)


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support
  2023-03-11  6:57 ` [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support Ian Rogers
@ 2023-03-30 14:08   ` James Clark
  2023-03-30 16:50     ` Ian Rogers
  0 siblings, 1 reply; 34+ messages in thread
From: James Clark @ 2023-03-30 14:08 UTC (permalink / raw)
  To: Ian Rogers, Arnaldo Carvalho de Melo
  Cc: Stephane Eranian, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Roberto Sassu, Quentin Monnet, Andres Freund, Tiezhu Yang,
	Pavithra Gurushankar, Yang Jihong, Adrian Hunter, Leo Yan,
	Martin Liška, linux-kernel, linux-perf-users, llvm,
	Peter Zijlstra, Ingo Molnar



On 11/03/2023 06:57, Ian Rogers wrote:
> Refactor C++ demangling out of symbol-elf into its own files similar
> to other languages. Add abi::__cxa_demangle support. As the other
> demanglers are not shippable with distributions, this brings back C++
> demangling in a common case. It isn't perfect as the support for
> optionally demangling arguments and modifiers isn't present.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/Makefile.config       | 29 +++++++++---------
>  tools/perf/util/Build            |  1 +
>  tools/perf/util/demangle-cxx.cpp | 50 ++++++++++++++++++++++++++++++++
>  tools/perf/util/demangle-cxx.h   | 16 ++++++++++
>  tools/perf/util/symbol-elf.c     | 37 +++++------------------
>  5 files changed, 88 insertions(+), 45 deletions(-)
>  create mode 100644 tools/perf/util/demangle-cxx.cpp
>  create mode 100644 tools/perf/util/demangle-cxx.h
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 5756498248e0..fdeca45cf15f 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -906,6 +906,7 @@ ifdef BUILD_NONDISTRO
>    endif
>  
>    CFLAGS += -DHAVE_LIBBFD_SUPPORT
> +  CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
>    ifeq ($(feature-libbfd-buildid), 1)
>      CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
>    else
> @@ -913,26 +914,24 @@ ifdef BUILD_NONDISTRO
>    endif
>  endif
>  
> -ifdef NO_DEMANGLE
> -  CFLAGS += -DNO_DEMANGLE
> -else
> +ifndef NO_DEMANGLE
> +  $(call feature_check,cxa-demangle)
> +  ifeq ($(feature-cxa-demangle), 1)
> +    EXTLIBS += -lstdc++

Hi Ian,

I think cross compilation for arm on x86 isn't working after this change
(at least on Ubuntu).

Even with all of the arm64 libstdc++ stuff installed, you can only link
to it using g++, but the perf build tries to link to it using gcc. Not
sure it's some quirk with the search paths on Ubuntu or something else:

  $ aarch64-linux-gnu-gcc -lstdc++

   /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-
gnu/bin/ld: cannot find -lstdc++: No such file or directory
  collect2: error: ld returned 1 exit status

g++ gets further:

  $ aarch64-linux-gnu-g++ -lstdc++

  ...
  (.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

At the end of the perf build it looks like something similar is
happening (with all the non interesting bits deleted):

   $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
NO_BPF_SKEL=1 V=1

  aarch64-linux-gnu-gcc ... -o perf

/usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld:
cannot find -lstdc++: No such file or directory

If I build with NO_DEMANGLE=1 then the build works, but I think it would
at be best to autodetect rather than have to do this. Or maybe even link
at the end with g++ if we're going to use libstdc++?

Thanks
James

> +    CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> +    CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> +  endif
>    ifdef BUILD_NONDISTRO
>      ifeq ($(filter -liberty,$(EXTLIBS)),)
> -      ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
> +      $(call feature_check,cplus-demangle)
> +      ifeq ($(feature-cplus-demangle), 1)
>          EXTLIBS += -liberty
> -      else
> -        $(call feature_check,cplus-demangle)
> -        ifeq ($(feature-cplus-demangle), 1)
> -          EXTLIBS += -liberty
> -        endif
>        endif
>      endif
> -  endif
> -
> -  ifneq ($(filter -liberty,$(EXTLIBS)),)
> -    CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> -  else
> -    CFLAGS += -DNO_DEMANGLE
> +    ifneq ($(filter -liberty,$(EXTLIBS)),)
> +      CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> +      CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> +    endif
>    endif
>  endif
>  
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 918b501f9bd8..8607575183a9 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -211,6 +211,7 @@ perf-$(CONFIG_ZSTD) += zstd.o
>  
>  perf-$(CONFIG_LIBCAP) += cap.o
>  
> +perf-y += demangle-cxx.o
>  perf-y += demangle-ocaml.o
>  perf-y += demangle-java.o
>  perf-y += demangle-rust.o
> diff --git a/tools/perf/util/demangle-cxx.cpp b/tools/perf/util/demangle-cxx.cpp
> new file mode 100644
> index 000000000000..8708bcafd370
> --- /dev/null
> +++ b/tools/perf/util/demangle-cxx.cpp
> @@ -0,0 +1,50 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include "demangle-cxx.h"
> +#include <stdlib.h>
> +#include <string.h>
> +#include <linux/compiler.h>
> +
> +#ifdef HAVE_LIBBFD_SUPPORT
> +#define PACKAGE 'perf'
> +#include <bfd.h>
> +#endif
> +
> +#ifdef HAVE_CXA_DEMANGLE_SUPPORT
> +#include <cxxabi.h>
> +#endif
> +
> +#if defined(HAVE_LIBBFD_SUPPORT) || defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> +#ifndef DMGL_PARAMS
> +#define DMGL_PARAMS     (1 << 0)  /* Include function args */
> +#define DMGL_ANSI       (1 << 1)  /* Include const, volatile, etc */
> +#endif
> +#endif
> +
> +/*
> + * Demangle C++ function signature
> + *
> + * Note: caller is responsible for freeing demangled string
> + */
> +extern "C"
> +char *cxx_demangle_sym(const char *str, bool params __maybe_unused,
> +                       bool modifiers __maybe_unused)
> +{
> +#ifdef HAVE_LIBBFD_SUPPORT
> +        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> +
> +        return bfd_demangle(NULL, str, flags);
> +#elif defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> +        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> +
> +        return cplus_demangle(str, flags);
> +#elif defined(HAVE_CXA_DEMANGLE_SUPPORT)
> +        size_t len = strlen(str);
> +        char *output = (char*)malloc(len);
> +        int status;
> +
> +        output = abi::__cxa_demangle(str, output, &len, &status);
> +        return output;
> +#else
> +        return NULL;
> +#endif
> +}
> diff --git a/tools/perf/util/demangle-cxx.h b/tools/perf/util/demangle-cxx.h
> new file mode 100644
> index 000000000000..26b5b66c0b4e
> --- /dev/null
> +++ b/tools/perf/util/demangle-cxx.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __PERF_DEMANGLE_CXX
> +#define __PERF_DEMANGLE_CXX 1
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +char *cxx_demangle_sym(const char *str, bool params, bool modifiers);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +
> +#endif /* __PERF_DEMANGLE_CXX */
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index 41882ae8452e..c0a2de42c51b 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -12,6 +12,7 @@
>  #include "maps.h"
>  #include "symbol.h"
>  #include "symsrc.h"
> +#include "demangle-cxx.h"
>  #include "demangle-ocaml.h"
>  #include "demangle-java.h"
>  #include "demangle-rust.h"
> @@ -25,6 +26,11 @@
>  #include <symbol/kallsyms.h>
>  #include <internal/lib.h>
>  
> +#ifdef HAVE_LIBBFD_SUPPORT
> +#define PACKAGE 'perf'
> +#include <bfd.h>
> +#endif
> +
>  #ifndef EM_AARCH64
>  #define EM_AARCH64	183  /* ARM 64 bit */
>  #endif
> @@ -45,34 +51,6 @@
>  
>  typedef Elf64_Nhdr GElf_Nhdr;
>  
> -#ifndef DMGL_PARAMS
> -#define DMGL_NO_OPTS     0              /* For readability... */
> -#define DMGL_PARAMS      (1 << 0)       /* Include function args */
> -#define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
> -#endif
> -
> -#ifdef HAVE_LIBBFD_SUPPORT
> -#define PACKAGE 'perf'
> -#include <bfd.h>
> -#else
> -#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
> -extern char *cplus_demangle(const char *, int);
> -
> -static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
> -{
> -	return cplus_demangle(c, i);
> -}
> -#else
> -#ifdef NO_DEMANGLE
> -static inline char *bfd_demangle(void __maybe_unused *v,
> -				 const char __maybe_unused *c,
> -				 int __maybe_unused i)
> -{
> -	return NULL;
> -}
> -#endif
> -#endif
> -#endif
>  
>  #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
>  static int elf_getphdrnum(Elf *elf, size_t *dst)
> @@ -295,7 +273,6 @@ static bool want_demangle(bool is_kernel_sym)
>  
>  static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
>  {
> -	int demangle_flags = verbose > 0 ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
>  	char *demangled = NULL;
>  
>  	/*
> @@ -306,7 +283,7 @@ static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
>  	if (!want_demangle(dso->kernel || kmodule))
>  	    return demangled;
>  
> -	demangled = bfd_demangle(NULL, elf_name, demangle_flags);
> +	demangled = cxx_demangle_sym(elf_name, verbose > 0, verbose > 0);
>  	if (demangled == NULL) {
>  		demangled = ocaml_demangle_sym(elf_name);
>  		if (demangled == NULL) {

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support
  2023-03-30 14:08   ` James Clark
@ 2023-03-30 16:50     ` Ian Rogers
  2023-03-30 19:03       ` Ian Rogers
  0 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-30 16:50 UTC (permalink / raw)
  To: James Clark
  Cc: Arnaldo Carvalho de Melo, Stephane Eranian, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Roberto Sassu, Quentin Monnet,
	Andres Freund, Tiezhu Yang, Pavithra Gurushankar, Yang Jihong,
	Adrian Hunter, Leo Yan, Martin Liška, linux-kernel,
	linux-perf-users, llvm, Peter Zijlstra, Ingo Molnar

On Thu, Mar 30, 2023 at 7:08 AM James Clark <james.clark@arm.com> wrote:
>
>
>
> On 11/03/2023 06:57, Ian Rogers wrote:
> > Refactor C++ demangling out of symbol-elf into its own files similar
> > to other languages. Add abi::__cxa_demangle support. As the other
> > demanglers are not shippable with distributions, this brings back C++
> > demangling in a common case. It isn't perfect as the support for
> > optionally demangling arguments and modifiers isn't present.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/Makefile.config       | 29 +++++++++---------
> >  tools/perf/util/Build            |  1 +
> >  tools/perf/util/demangle-cxx.cpp | 50 ++++++++++++++++++++++++++++++++
> >  tools/perf/util/demangle-cxx.h   | 16 ++++++++++
> >  tools/perf/util/symbol-elf.c     | 37 +++++------------------
> >  5 files changed, 88 insertions(+), 45 deletions(-)
> >  create mode 100644 tools/perf/util/demangle-cxx.cpp
> >  create mode 100644 tools/perf/util/demangle-cxx.h
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 5756498248e0..fdeca45cf15f 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -906,6 +906,7 @@ ifdef BUILD_NONDISTRO
> >    endif
> >
> >    CFLAGS += -DHAVE_LIBBFD_SUPPORT
> > +  CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
> >    ifeq ($(feature-libbfd-buildid), 1)
> >      CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
> >    else
> > @@ -913,26 +914,24 @@ ifdef BUILD_NONDISTRO
> >    endif
> >  endif
> >
> > -ifdef NO_DEMANGLE
> > -  CFLAGS += -DNO_DEMANGLE
> > -else
> > +ifndef NO_DEMANGLE
> > +  $(call feature_check,cxa-demangle)
> > +  ifeq ($(feature-cxa-demangle), 1)
> > +    EXTLIBS += -lstdc++
>
> Hi Ian,
>
> I think cross compilation for arm on x86 isn't working after this change
> (at least on Ubuntu).
>
> Even with all of the arm64 libstdc++ stuff installed, you can only link
> to it using g++, but the perf build tries to link to it using gcc. Not
> sure it's some quirk with the search paths on Ubuntu or something else:
>
>   $ aarch64-linux-gnu-gcc -lstdc++
>
>    /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-
> gnu/bin/ld: cannot find -lstdc++: No such file or directory
>   collect2: error: ld returned 1 exit status
>
> g++ gets further:
>
>   $ aarch64-linux-gnu-g++ -lstdc++
>
>   ...
>   (.text+0x20): undefined reference to `main'
> collect2: error: ld returned 1 exit status
>
> At the end of the perf build it looks like something similar is
> happening (with all the non interesting bits deleted):
>
>    $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
> NO_BPF_SKEL=1 V=1
>
>   aarch64-linux-gnu-gcc ... -o perf
>
> /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld:
> cannot find -lstdc++: No such file or directory
>
> If I build with NO_DEMANGLE=1 then the build works, but I think it would
> at be best to autodetect rather than have to do this. Or maybe even link
> at the end with g++ if we're going to use libstdc++?

Hi James,

sorry for the problems you are having, I'll see if I can get a repo. I
did add a feature test with this change in the same set:
https://lore.kernel.org/lkml/20230311065753.3012826-9-irogers@google.com/
So it should be feature testing and only enabling when
HAVE_CXA_DEMANGLE_SUPPORT is present. Obviously something is up, so
I'll have a think about it.

Thanks,
Ian

> Thanks
> James
>
> > +    CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> > +    CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> > +  endif
> >    ifdef BUILD_NONDISTRO
> >      ifeq ($(filter -liberty,$(EXTLIBS)),)
> > -      ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
> > +      $(call feature_check,cplus-demangle)
> > +      ifeq ($(feature-cplus-demangle), 1)
> >          EXTLIBS += -liberty
> > -      else
> > -        $(call feature_check,cplus-demangle)
> > -        ifeq ($(feature-cplus-demangle), 1)
> > -          EXTLIBS += -liberty
> > -        endif
> >        endif
> >      endif
> > -  endif
> > -
> > -  ifneq ($(filter -liberty,$(EXTLIBS)),)
> > -    CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> > -  else
> > -    CFLAGS += -DNO_DEMANGLE
> > +    ifneq ($(filter -liberty,$(EXTLIBS)),)
> > +      CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> > +      CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> > +    endif
> >    endif
> >  endif
> >
> > diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> > index 918b501f9bd8..8607575183a9 100644
> > --- a/tools/perf/util/Build
> > +++ b/tools/perf/util/Build
> > @@ -211,6 +211,7 @@ perf-$(CONFIG_ZSTD) += zstd.o
> >
> >  perf-$(CONFIG_LIBCAP) += cap.o
> >
> > +perf-y += demangle-cxx.o
> >  perf-y += demangle-ocaml.o
> >  perf-y += demangle-java.o
> >  perf-y += demangle-rust.o
> > diff --git a/tools/perf/util/demangle-cxx.cpp b/tools/perf/util/demangle-cxx.cpp
> > new file mode 100644
> > index 000000000000..8708bcafd370
> > --- /dev/null
> > +++ b/tools/perf/util/demangle-cxx.cpp
> > @@ -0,0 +1,50 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +#include "demangle-cxx.h"
> > +#include <stdlib.h>
> > +#include <string.h>
> > +#include <linux/compiler.h>
> > +
> > +#ifdef HAVE_LIBBFD_SUPPORT
> > +#define PACKAGE 'perf'
> > +#include <bfd.h>
> > +#endif
> > +
> > +#ifdef HAVE_CXA_DEMANGLE_SUPPORT
> > +#include <cxxabi.h>
> > +#endif
> > +
> > +#if defined(HAVE_LIBBFD_SUPPORT) || defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> > +#ifndef DMGL_PARAMS
> > +#define DMGL_PARAMS     (1 << 0)  /* Include function args */
> > +#define DMGL_ANSI       (1 << 1)  /* Include const, volatile, etc */
> > +#endif
> > +#endif
> > +
> > +/*
> > + * Demangle C++ function signature
> > + *
> > + * Note: caller is responsible for freeing demangled string
> > + */
> > +extern "C"
> > +char *cxx_demangle_sym(const char *str, bool params __maybe_unused,
> > +                       bool modifiers __maybe_unused)
> > +{
> > +#ifdef HAVE_LIBBFD_SUPPORT
> > +        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> > +
> > +        return bfd_demangle(NULL, str, flags);
> > +#elif defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> > +        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> > +
> > +        return cplus_demangle(str, flags);
> > +#elif defined(HAVE_CXA_DEMANGLE_SUPPORT)
> > +        size_t len = strlen(str);
> > +        char *output = (char*)malloc(len);
> > +        int status;
> > +
> > +        output = abi::__cxa_demangle(str, output, &len, &status);
> > +        return output;
> > +#else
> > +        return NULL;
> > +#endif
> > +}
> > diff --git a/tools/perf/util/demangle-cxx.h b/tools/perf/util/demangle-cxx.h
> > new file mode 100644
> > index 000000000000..26b5b66c0b4e
> > --- /dev/null
> > +++ b/tools/perf/util/demangle-cxx.h
> > @@ -0,0 +1,16 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef __PERF_DEMANGLE_CXX
> > +#define __PERF_DEMANGLE_CXX 1
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +char *cxx_demangle_sym(const char *str, bool params, bool modifiers);
> > +
> > +#ifdef __cplusplus
> > +}
> > +#endif
> > +
> > +
> > +#endif /* __PERF_DEMANGLE_CXX */
> > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > index 41882ae8452e..c0a2de42c51b 100644
> > --- a/tools/perf/util/symbol-elf.c
> > +++ b/tools/perf/util/symbol-elf.c
> > @@ -12,6 +12,7 @@
> >  #include "maps.h"
> >  #include "symbol.h"
> >  #include "symsrc.h"
> > +#include "demangle-cxx.h"
> >  #include "demangle-ocaml.h"
> >  #include "demangle-java.h"
> >  #include "demangle-rust.h"
> > @@ -25,6 +26,11 @@
> >  #include <symbol/kallsyms.h>
> >  #include <internal/lib.h>
> >
> > +#ifdef HAVE_LIBBFD_SUPPORT
> > +#define PACKAGE 'perf'
> > +#include <bfd.h>
> > +#endif
> > +
> >  #ifndef EM_AARCH64
> >  #define EM_AARCH64   183  /* ARM 64 bit */
> >  #endif
> > @@ -45,34 +51,6 @@
> >
> >  typedef Elf64_Nhdr GElf_Nhdr;
> >
> > -#ifndef DMGL_PARAMS
> > -#define DMGL_NO_OPTS     0              /* For readability... */
> > -#define DMGL_PARAMS      (1 << 0)       /* Include function args */
> > -#define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
> > -#endif
> > -
> > -#ifdef HAVE_LIBBFD_SUPPORT
> > -#define PACKAGE 'perf'
> > -#include <bfd.h>
> > -#else
> > -#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
> > -extern char *cplus_demangle(const char *, int);
> > -
> > -static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
> > -{
> > -     return cplus_demangle(c, i);
> > -}
> > -#else
> > -#ifdef NO_DEMANGLE
> > -static inline char *bfd_demangle(void __maybe_unused *v,
> > -                              const char __maybe_unused *c,
> > -                              int __maybe_unused i)
> > -{
> > -     return NULL;
> > -}
> > -#endif
> > -#endif
> > -#endif
> >
> >  #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
> >  static int elf_getphdrnum(Elf *elf, size_t *dst)
> > @@ -295,7 +273,6 @@ static bool want_demangle(bool is_kernel_sym)
> >
> >  static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
> >  {
> > -     int demangle_flags = verbose > 0 ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
> >       char *demangled = NULL;
> >
> >       /*
> > @@ -306,7 +283,7 @@ static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
> >       if (!want_demangle(dso->kernel || kmodule))
> >           return demangled;
> >
> > -     demangled = bfd_demangle(NULL, elf_name, demangle_flags);
> > +     demangled = cxx_demangle_sym(elf_name, verbose > 0, verbose > 0);
> >       if (demangled == NULL) {
> >               demangled = ocaml_demangle_sym(elf_name);
> >               if (demangled == NULL) {

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support
  2023-03-30 16:50     ` Ian Rogers
@ 2023-03-30 19:03       ` Ian Rogers
  2023-03-31  9:27         ` James Clark
  0 siblings, 1 reply; 34+ messages in thread
From: Ian Rogers @ 2023-03-30 19:03 UTC (permalink / raw)
  To: James Clark
  Cc: Arnaldo Carvalho de Melo, Stephane Eranian, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Roberto Sassu, Quentin Monnet,
	Andres Freund, Tiezhu Yang, Pavithra Gurushankar, Yang Jihong,
	Adrian Hunter, Leo Yan, Martin Liška, linux-kernel,
	linux-perf-users, llvm, Peter Zijlstra, Ingo Molnar

On Thu, Mar 30, 2023 at 9:50 AM Ian Rogers <irogers@google.com> wrote:
>
> On Thu, Mar 30, 2023 at 7:08 AM James Clark <james.clark@arm.com> wrote:
> >
> >
> >
> > On 11/03/2023 06:57, Ian Rogers wrote:
> > > Refactor C++ demangling out of symbol-elf into its own files similar
> > > to other languages. Add abi::__cxa_demangle support. As the other
> > > demanglers are not shippable with distributions, this brings back C++
> > > demangling in a common case. It isn't perfect as the support for
> > > optionally demangling arguments and modifiers isn't present.
> > >
> > > Signed-off-by: Ian Rogers <irogers@google.com>
> > > ---
> > >  tools/perf/Makefile.config       | 29 +++++++++---------
> > >  tools/perf/util/Build            |  1 +
> > >  tools/perf/util/demangle-cxx.cpp | 50 ++++++++++++++++++++++++++++++++
> > >  tools/perf/util/demangle-cxx.h   | 16 ++++++++++
> > >  tools/perf/util/symbol-elf.c     | 37 +++++------------------
> > >  5 files changed, 88 insertions(+), 45 deletions(-)
> > >  create mode 100644 tools/perf/util/demangle-cxx.cpp
> > >  create mode 100644 tools/perf/util/demangle-cxx.h
> > >
> > > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > > index 5756498248e0..fdeca45cf15f 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -906,6 +906,7 @@ ifdef BUILD_NONDISTRO
> > >    endif
> > >
> > >    CFLAGS += -DHAVE_LIBBFD_SUPPORT
> > > +  CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
> > >    ifeq ($(feature-libbfd-buildid), 1)
> > >      CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
> > >    else
> > > @@ -913,26 +914,24 @@ ifdef BUILD_NONDISTRO
> > >    endif
> > >  endif
> > >
> > > -ifdef NO_DEMANGLE
> > > -  CFLAGS += -DNO_DEMANGLE
> > > -else
> > > +ifndef NO_DEMANGLE
> > > +  $(call feature_check,cxa-demangle)
> > > +  ifeq ($(feature-cxa-demangle), 1)
> > > +    EXTLIBS += -lstdc++
> >
> > Hi Ian,
> >
> > I think cross compilation for arm on x86 isn't working after this change
> > (at least on Ubuntu).
> >
> > Even with all of the arm64 libstdc++ stuff installed, you can only link
> > to it using g++, but the perf build tries to link to it using gcc. Not
> > sure it's some quirk with the search paths on Ubuntu or something else:
> >
> >   $ aarch64-linux-gnu-gcc -lstdc++
> >
> >    /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-
> > gnu/bin/ld: cannot find -lstdc++: No such file or directory
> >   collect2: error: ld returned 1 exit status
> >
> > g++ gets further:
> >
> >   $ aarch64-linux-gnu-g++ -lstdc++
> >
> >   ...
> >   (.text+0x20): undefined reference to `main'
> > collect2: error: ld returned 1 exit status
> >
> > At the end of the perf build it looks like something similar is
> > happening (with all the non interesting bits deleted):
> >
> >    $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
> > NO_BPF_SKEL=1 V=1
> >
> >   aarch64-linux-gnu-gcc ... -o perf
> >
> > /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld:
> > cannot find -lstdc++: No such file or directory
> >
> > If I build with NO_DEMANGLE=1 then the build works, but I think it would
> > at be best to autodetect rather than have to do this. Or maybe even link
> > at the end with g++ if we're going to use libstdc++?
>
> Hi James,
>
> sorry for the problems you are having, I'll see if I can get a repo. I
> did add a feature test with this change in the same set:
> https://lore.kernel.org/lkml/20230311065753.3012826-9-irogers@google.com/
> So it should be feature testing and only enabling when
> HAVE_CXA_DEMANGLE_SUPPORT is present. Obviously something is up, so
> I'll have a think about it.
>
> Thanks,
> Ian

Sorry to say I couldn't repro on Debian:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
NO_LIBELF=1 NO_LIBTRACEEVENT=1
make: Entering directory '/home/irogers/kernel.org/tools/perf'
 BUILD:   Doing 'make -j16' parallel build
Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs
from latest version at 'include/uapi/linux/in.h'
diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
Warning: Kernel ABI header at
'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version
at 'arch/x86/include/asm/cpufeatures.h'
diff -u tools/arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/cpufeatures.h
Warning: Kernel ABI header at
'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest
version at 'arch/arm64/include/uapi/asm/perf_regs.h'
diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h
arch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/include/linux/coresight-pmu.h'
differs from latest version at 'include/linux/coresight-pmu.h'
diff -u tools/include/linux/coresight-pmu.h include/linux/coresight-pmu.h
Makefile.config:588: No sys/sdt.h found, no SDT events are defined,
please install systemtap-sdt-devel or systemtap-sdt-dev
Makefile.config:679: Disabling post unwind, no support found.
Makefile.config:747: No libcrypto.h found, disables jitted code
injection, please install openssl-devel or libssl-dev
Makefile.config:759: slang not found, disables TUI support. Please
install slang-devel, libslang-devor libslang2-dev
Makefile.config:806: Missing perl devel files. Disabling perl
scripting support, please install perl-ExtUtils-Embed/libperl-dev
Makefile.config:846: No 'Python.h' was found: disables Python support
- please install python-devel/python-dev
Makefile.config:951: No liblzma found, disables xz kernel module
decompression, please install xz-devel/liblzma-dev
Makefile.config:964: No libzstd found, disables trace compression,
please install libzstd-dev[el] and/or set LIBZSTD_DIR
Makefile.config:975: No libcap found, disables capability support,
please install libcap-devel/libcap-dev
Makefile.config:988: No numa.h found, disables 'perf bench numa mem'
benchmark, please install numactl-devel/libnuma-devel/libnuma-dev
Makefile.config:1047: No libbabeltrace found, disables 'perf data' CTF
format support, please install
libbabeltrace-dev[el]/libbabeltrace-ctf-dev
Makefile.config:1138: libpfm4 not found, disables libpfm4 support.
Please install libpfm4-dev

Auto-detecting system features:
...                                   dwarf: [ OFF ]
...                      dwarf_getlocations: [ OFF ]
...                                   glibc: [ on  ]
...                                  libbfd: [ OFF ]
...                          libbfd-buildid: [ OFF ]
...                                  libcap: [ OFF ]
...                                  libelf: [ OFF ]
...                                 libnuma: [ OFF ]
...                  numa_num_possible_cpus: [ OFF ]
...                                 libperl: [ OFF ]
...                               libpython: [ OFF ]
...                               libcrypto: [ OFF ]
...                               libunwind: [ OFF ]
...                      libdw-dwarf-unwind: [ OFF ]
...                                    zlib: [ OFF ]
...                                    lzma: [ OFF ]
...                               get_cpuid: [ OFF ]
...                                     bpf: [ on  ]
...                                  libaio: [ on  ]
...                                 libzstd: [ OFF ]

 INSTALL libsubcmd_headers
 INSTALL libsymbol_headers
 INSTALL libapi_headers
 INSTALL libperf_headers
 FLEX    util/parse-events-flex.c
 FLEX    util/pmu-flex.c
 CC      util/pmu-bison.o
 FLEX    util/expr-flex.c
 CC      util/expr-bison.o
 CXX     util/demangle-cxx.o
 CC      util/demangle-ocaml.o
 CC      util/demangle-java.o
 CC      util/demangle-rust.o
 CC      util/perf-hooks.o
 CC      util/parse-events.o
 CC      util/parse-events-flex.o
 CC      util/pmu.o
 CC      util/pmu-flex.o
 CC      util/expr-flex.o
 CC      util/expr.o
 LD      util/perf-in.o
 LD      perf-in.o
 LINK    perf
make: Leaving directory '.../tools/perf'

Thanks,
Ian

> > Thanks
> > James
> >
> > > +    CFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> > > +    CXXFLAGS += -DHAVE_CXA_DEMANGLE_SUPPORT
> > > +  endif
> > >    ifdef BUILD_NONDISTRO
> > >      ifeq ($(filter -liberty,$(EXTLIBS)),)
> > > -      ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
> > > +      $(call feature_check,cplus-demangle)
> > > +      ifeq ($(feature-cplus-demangle), 1)
> > >          EXTLIBS += -liberty
> > > -      else
> > > -        $(call feature_check,cplus-demangle)
> > > -        ifeq ($(feature-cplus-demangle), 1)
> > > -          EXTLIBS += -liberty
> > > -        endif
> > >        endif
> > >      endif
> > > -  endif
> > > -
> > > -  ifneq ($(filter -liberty,$(EXTLIBS)),)
> > > -    CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> > > -  else
> > > -    CFLAGS += -DNO_DEMANGLE
> > > +    ifneq ($(filter -liberty,$(EXTLIBS)),)
> > > +      CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> > > +      CXXFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
> > > +    endif
> > >    endif
> > >  endif
> > >
> > > diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> > > index 918b501f9bd8..8607575183a9 100644
> > > --- a/tools/perf/util/Build
> > > +++ b/tools/perf/util/Build
> > > @@ -211,6 +211,7 @@ perf-$(CONFIG_ZSTD) += zstd.o
> > >
> > >  perf-$(CONFIG_LIBCAP) += cap.o
> > >
> > > +perf-y += demangle-cxx.o
> > >  perf-y += demangle-ocaml.o
> > >  perf-y += demangle-java.o
> > >  perf-y += demangle-rust.o
> > > diff --git a/tools/perf/util/demangle-cxx.cpp b/tools/perf/util/demangle-cxx.cpp
> > > new file mode 100644
> > > index 000000000000..8708bcafd370
> > > --- /dev/null
> > > +++ b/tools/perf/util/demangle-cxx.cpp
> > > @@ -0,0 +1,50 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +#include "demangle-cxx.h"
> > > +#include <stdlib.h>
> > > +#include <string.h>
> > > +#include <linux/compiler.h>
> > > +
> > > +#ifdef HAVE_LIBBFD_SUPPORT
> > > +#define PACKAGE 'perf'
> > > +#include <bfd.h>
> > > +#endif
> > > +
> > > +#ifdef HAVE_CXA_DEMANGLE_SUPPORT
> > > +#include <cxxabi.h>
> > > +#endif
> > > +
> > > +#if defined(HAVE_LIBBFD_SUPPORT) || defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> > > +#ifndef DMGL_PARAMS
> > > +#define DMGL_PARAMS     (1 << 0)  /* Include function args */
> > > +#define DMGL_ANSI       (1 << 1)  /* Include const, volatile, etc */
> > > +#endif
> > > +#endif
> > > +
> > > +/*
> > > + * Demangle C++ function signature
> > > + *
> > > + * Note: caller is responsible for freeing demangled string
> > > + */
> > > +extern "C"
> > > +char *cxx_demangle_sym(const char *str, bool params __maybe_unused,
> > > +                       bool modifiers __maybe_unused)
> > > +{
> > > +#ifdef HAVE_LIBBFD_SUPPORT
> > > +        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> > > +
> > > +        return bfd_demangle(NULL, str, flags);
> > > +#elif defined(HAVE_CPLUS_DEMANGLE_SUPPORT)
> > > +        int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> > > +
> > > +        return cplus_demangle(str, flags);
> > > +#elif defined(HAVE_CXA_DEMANGLE_SUPPORT)
> > > +        size_t len = strlen(str);
> > > +        char *output = (char*)malloc(len);
> > > +        int status;
> > > +
> > > +        output = abi::__cxa_demangle(str, output, &len, &status);
> > > +        return output;
> > > +#else
> > > +        return NULL;
> > > +#endif
> > > +}
> > > diff --git a/tools/perf/util/demangle-cxx.h b/tools/perf/util/demangle-cxx.h
> > > new file mode 100644
> > > index 000000000000..26b5b66c0b4e
> > > --- /dev/null
> > > +++ b/tools/perf/util/demangle-cxx.h
> > > @@ -0,0 +1,16 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > > +#ifndef __PERF_DEMANGLE_CXX
> > > +#define __PERF_DEMANGLE_CXX 1
> > > +
> > > +#ifdef __cplusplus
> > > +extern "C" {
> > > +#endif
> > > +
> > > +char *cxx_demangle_sym(const char *str, bool params, bool modifiers);
> > > +
> > > +#ifdef __cplusplus
> > > +}
> > > +#endif
> > > +
> > > +
> > > +#endif /* __PERF_DEMANGLE_CXX */
> > > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > > index 41882ae8452e..c0a2de42c51b 100644
> > > --- a/tools/perf/util/symbol-elf.c
> > > +++ b/tools/perf/util/symbol-elf.c
> > > @@ -12,6 +12,7 @@
> > >  #include "maps.h"
> > >  #include "symbol.h"
> > >  #include "symsrc.h"
> > > +#include "demangle-cxx.h"
> > >  #include "demangle-ocaml.h"
> > >  #include "demangle-java.h"
> > >  #include "demangle-rust.h"
> > > @@ -25,6 +26,11 @@
> > >  #include <symbol/kallsyms.h>
> > >  #include <internal/lib.h>
> > >
> > > +#ifdef HAVE_LIBBFD_SUPPORT
> > > +#define PACKAGE 'perf'
> > > +#include <bfd.h>
> > > +#endif
> > > +
> > >  #ifndef EM_AARCH64
> > >  #define EM_AARCH64   183  /* ARM 64 bit */
> > >  #endif
> > > @@ -45,34 +51,6 @@
> > >
> > >  typedef Elf64_Nhdr GElf_Nhdr;
> > >
> > > -#ifndef DMGL_PARAMS
> > > -#define DMGL_NO_OPTS     0              /* For readability... */
> > > -#define DMGL_PARAMS      (1 << 0)       /* Include function args */
> > > -#define DMGL_ANSI        (1 << 1)       /* Include const, volatile, etc */
> > > -#endif
> > > -
> > > -#ifdef HAVE_LIBBFD_SUPPORT
> > > -#define PACKAGE 'perf'
> > > -#include <bfd.h>
> > > -#else
> > > -#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
> > > -extern char *cplus_demangle(const char *, int);
> > > -
> > > -static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
> > > -{
> > > -     return cplus_demangle(c, i);
> > > -}
> > > -#else
> > > -#ifdef NO_DEMANGLE
> > > -static inline char *bfd_demangle(void __maybe_unused *v,
> > > -                              const char __maybe_unused *c,
> > > -                              int __maybe_unused i)
> > > -{
> > > -     return NULL;
> > > -}
> > > -#endif
> > > -#endif
> > > -#endif
> > >
> > >  #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
> > >  static int elf_getphdrnum(Elf *elf, size_t *dst)
> > > @@ -295,7 +273,6 @@ static bool want_demangle(bool is_kernel_sym)
> > >
> > >  static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
> > >  {
> > > -     int demangle_flags = verbose > 0 ? (DMGL_PARAMS | DMGL_ANSI) : DMGL_NO_OPTS;
> > >       char *demangled = NULL;
> > >
> > >       /*
> > > @@ -306,7 +283,7 @@ static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
> > >       if (!want_demangle(dso->kernel || kmodule))
> > >           return demangled;
> > >
> > > -     demangled = bfd_demangle(NULL, elf_name, demangle_flags);
> > > +     demangled = cxx_demangle_sym(elf_name, verbose > 0, verbose > 0);
> > >       if (demangled == NULL) {
> > >               demangled = ocaml_demangle_sym(elf_name);
> > >               if (demangled == NULL) {

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support
  2023-03-30 19:03       ` Ian Rogers
@ 2023-03-31  9:27         ` James Clark
  0 siblings, 0 replies; 34+ messages in thread
From: James Clark @ 2023-03-31  9:27 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Arnaldo Carvalho de Melo, Stephane Eranian, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Roberto Sassu, Quentin Monnet,
	Andres Freund, Tiezhu Yang, Pavithra Gurushankar, Yang Jihong,
	Adrian Hunter, Leo Yan, Martin Liška, linux-kernel,
	linux-perf-users, llvm, Peter Zijlstra, Ingo Molnar



On 30/03/2023 20:03, Ian Rogers wrote:
> On Thu, Mar 30, 2023 at 9:50 AM Ian Rogers <irogers@google.com> wrote:
>>
>> On Thu, Mar 30, 2023 at 7:08 AM James Clark <james.clark@arm.com> wrote:
>>>
>>>
>>>
>>> On 11/03/2023 06:57, Ian Rogers wrote:
>>>> Refactor C++ demangling out of symbol-elf into its own files similar
>>>> to other languages. Add abi::__cxa_demangle support. As the other
>>>> demanglers are not shippable with distributions, this brings back C++
>>>> demangling in a common case. It isn't perfect as the support for
>>>> optionally demangling arguments and modifiers isn't present.
>>>>
>>>> Signed-off-by: Ian Rogers <irogers@google.com>
>>>> ---
>>>>  tools/perf/Makefile.config       | 29 +++++++++---------
>>>>  tools/perf/util/Build            |  1 +
>>>>  tools/perf/util/demangle-cxx.cpp | 50 ++++++++++++++++++++++++++++++++
>>>>  tools/perf/util/demangle-cxx.h   | 16 ++++++++++
>>>>  tools/perf/util/symbol-elf.c     | 37 +++++------------------
>>>>  5 files changed, 88 insertions(+), 45 deletions(-)
>>>>  create mode 100644 tools/perf/util/demangle-cxx.cpp
>>>>  create mode 100644 tools/perf/util/demangle-cxx.h
>>>>
>>>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>>>> index 5756498248e0..fdeca45cf15f 100644
>>>> --- a/tools/perf/Makefile.config
>>>> +++ b/tools/perf/Makefile.config
>>>> @@ -906,6 +906,7 @@ ifdef BUILD_NONDISTRO
>>>>    endif
>>>>
>>>>    CFLAGS += -DHAVE_LIBBFD_SUPPORT
>>>> +  CXXFLAGS += -DHAVE_LIBBFD_SUPPORT
>>>>    ifeq ($(feature-libbfd-buildid), 1)
>>>>      CFLAGS += -DHAVE_LIBBFD_BUILDID_SUPPORT
>>>>    else
>>>> @@ -913,26 +914,24 @@ ifdef BUILD_NONDISTRO
>>>>    endif
>>>>  endif
>>>>
>>>> -ifdef NO_DEMANGLE
>>>> -  CFLAGS += -DNO_DEMANGLE
>>>> -else
>>>> +ifndef NO_DEMANGLE
>>>> +  $(call feature_check,cxa-demangle)
>>>> +  ifeq ($(feature-cxa-demangle), 1)
>>>> +    EXTLIBS += -lstdc++
>>>
>>> Hi Ian,
>>>
>>> I think cross compilation for arm on x86 isn't working after this change
>>> (at least on Ubuntu).
>>>
>>> Even with all of the arm64 libstdc++ stuff installed, you can only link
>>> to it using g++, but the perf build tries to link to it using gcc. Not
>>> sure it's some quirk with the search paths on Ubuntu or something else:
>>>
>>>   $ aarch64-linux-gnu-gcc -lstdc++
>>>
>>>    /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-
>>> gnu/bin/ld: cannot find -lstdc++: No such file or directory
>>>   collect2: error: ld returned 1 exit status
>>>
>>> g++ gets further:
>>>
>>>   $ aarch64-linux-gnu-g++ -lstdc++
>>>
>>>   ...
>>>   (.text+0x20): undefined reference to `main'
>>> collect2: error: ld returned 1 exit status
>>>
>>> At the end of the perf build it looks like something similar is
>>> happening (with all the non interesting bits deleted):
>>>
>>>    $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
>>> NO_BPF_SKEL=1 V=1
>>>
>>>   aarch64-linux-gnu-gcc ... -o perf
>>>
>>> /usr/lib/gcc-cross/aarch64-linux-gnu/12/../../../../aarch64-linux-gnu/bin/ld:
>>> cannot find -lstdc++: No such file or directory
>>>
>>> If I build with NO_DEMANGLE=1 then the build works, but I think it would
>>> at be best to autodetect rather than have to do this. Or maybe even link
>>> at the end with g++ if we're going to use libstdc++?
>>
>> Hi James,
>>
>> sorry for the problems you are having, I'll see if I can get a repo. I
>> did add a feature test with this change in the same set:
>> https://lore.kernel.org/lkml/20230311065753.3012826-9-irogers@google.com/
>> So it should be feature testing and only enabling when
>> HAVE_CXA_DEMANGLE_SUPPORT is present. Obviously something is up, so
>> I'll have a think about it.
>>
>> Thanks,
>> Ian
> 
> Sorry to say I couldn't repro on Debian:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf
> NO_LIBELF=1 NO_LIBTRACEEVENT=1

If you have NO_LIBELF=1 it sets NO_DEMANGLE=1 automatically so it skips
the c++ linking step. If you run with V=1 you can see that it doesn't
have -lstdc++ on the last link line.

But, having said that, I went to make a full reproducer in docker but it
actually worked. Turns out that the issue was on my end. I'd used
update-alternatives for a different compiler version and looks like I
had half of one gcc and half of another g++. Completely my fault, sorry
for the noise!

James

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2023-03-31  9:29 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-11  6:57 [PATCH v1 00/13] Perf tool build improvements Ian Rogers
2023-03-11  6:57 ` [PATCH v1 01/13] perf build: Support python/perf.so testing Ian Rogers
2023-03-11  6:57 ` [PATCH v1 02/13] perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL Ian Rogers
2023-03-13 20:19   ` Arnaldo Carvalho de Melo
2023-03-13 20:27     ` Ian Rogers
2023-03-13 20:34       ` Arnaldo Carvalho de Melo
2023-03-13 20:59         ` Arnaldo Carvalho de Melo
2023-03-13 21:05           ` Arnaldo Carvalho de Melo
2023-03-11  6:57 ` [PATCH v1 03/13] perf build: Remove unused HAVE_GLIBC_SUPPORT Ian Rogers
2023-03-11  6:57 ` [PATCH v1 04/13] perf build: Error if no libelf and NO_LIBELF isn't set Ian Rogers
2023-03-13 19:45   ` Arnaldo Carvalho de Melo
2023-03-13 20:18     ` Ian Rogers
2023-03-11  6:57 ` [PATCH v1 05/13] perf util: Remove weak sched_getcpu Ian Rogers
2023-03-11  6:57 ` [PATCH v1 06/13] perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set Ian Rogers
2023-03-11  6:57 ` [PATCH v1 07/13] perf build: Make binutil libraries opt in Ian Rogers
2023-03-13 19:37   ` Arnaldo Carvalho de Melo
2023-03-11  6:57 ` [PATCH v1 08/13] tools build: Add feature test for abi::__cxa_demangle Ian Rogers
2023-03-11  6:57 ` [PATCH v1 09/13] perf symbol: Add abi::__cxa_demangle C++ demangling support Ian Rogers
2023-03-30 14:08   ` James Clark
2023-03-30 16:50     ` Ian Rogers
2023-03-30 19:03       ` Ian Rogers
2023-03-31  9:27         ` James Clark
2023-03-11  6:57 ` [PATCH v1 10/13] perf build: Switch libpfm4 to opt-out rather than opt-in Ian Rogers
2023-03-11  6:57 ` [PATCH v1 11/13] perf build: If libtraceevent isn't present error the build Ian Rogers
2023-03-11  6:57 ` [PATCH v1 12/13] tools headers: Make the difference output easier to read Ian Rogers
2023-03-13 19:35   ` Arnaldo Carvalho de Melo
2023-03-13 20:14     ` Ian Rogers
2023-03-11  6:57 ` [PATCH v1 13/13] perf build: Remove redundant NO_NEWT build option Ian Rogers
2023-03-14 12:11 ` [PATCH v1 00/13] Perf tool build improvements Arnaldo Carvalho de Melo
2023-03-14 12:12   ` Arnaldo Carvalho de Melo
2023-03-14 12:27     ` Arnaldo Carvalho de Melo
2023-03-14 12:29       ` Arnaldo Carvalho de Melo
2023-03-14 12:21   ` Adrian Hunter
2023-03-14 12:28     ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).