linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures
@ 2024-09-19  1:35 Yang Jihong
  2024-09-19  1:35 ` [PATCH RESEND v3 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Yang Jihong @ 2024-09-19  1:35 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang, james.clark,
	linux-perf-users, linux-kernel, leo.yan
  Cc: yangjihong

Changes since v3:
 - Add reviewed-by tag from Leo. (see Link[1])
 - Resend the patchset with no code changes.

Link[1]: https://lore.kernel.org/all/b5688d4a-9389-4998-8031-3f002302311e@arm.com/

Changes since v2:
 - patch1: change LIBDW_VERSION to follow up the style of
   LIBTRACEEVENT_VERSION. (by Leo's suggestion)
 - patch2: Use a new line for the -ldl dependency and with comment,
   synchronize tools/perf/Makefile.config. (by Leo's suggestion)
 - patch3: include header files in alphabetical order,
   add reviewed-by tag from Leo. (by Leo's suggestion)

Changes since v1:
 - patch3: Remove UTF-8 characters from build failure logs

Yang Jihong (3):
  perf: build: Fix static compilation error when libdw is not installed
  perf: build: Fix build feature-dwarf_getlocations fail for old libdw
  perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT
    undefined

 tools/build/feature/Makefile | 5 ++++-
 tools/perf/Makefile.config   | 7 +++++--
 tools/perf/util/dwarf-aux.h  | 1 +
 3 files changed, 10 insertions(+), 3 deletions(-)

-- 
2.25.1


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

* [PATCH RESEND v3 1/3] perf: build: Fix static compilation error when libdw is not installed
  2024-09-19  1:35 [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Yang Jihong
@ 2024-09-19  1:35 ` Yang Jihong
  2024-09-19  1:35 ` [PATCH RESEND v3 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw Yang Jihong
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yang Jihong @ 2024-09-19  1:35 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang, james.clark,
	linux-perf-users, linux-kernel, leo.yan
  Cc: yangjihong

If libdw is not installed in build environment, the output of
'pkg-config --modversion libdw' is empty, causing LIBDW_VERSION_2
to be empty and the shell test will have the following error:

  /bin/sh: 1: test: -lt: unexpected operator

Before:

  $ pkg-config --modversion libdw
  Package libdw was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libdw.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libdw' found
  $ make LDFLAGS=-static -j16
    BUILD:   Doing 'make -j20' parallel build
  <SNIP>
  Package libdw was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libdw.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libdw' found
  /bin/sh: 1: test: -lt: unexpected operator

After:

  1. libdw is not installed:

  $ pkg-config --modversion libdw
  Package libdw was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libdw.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libdw' found
  $ make LDFLAGS=-static -j16
    BUILD:   Doing 'make -j20' parallel build
  <SNIP>
  Package libdw was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libdw.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libdw' found
  Makefile.config:473: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR

  2. libdw version is lower than 0.177

  $ pkg-config --modversion libdw
  0.176
  $ make LDFLAGS=-static -j16
    BUILD:   Doing 'make -j20' parallel build
  <SNIP>

  Auto-detecting system features:
  ...                                   dwarf: [ on  ]
  <SNIP>
    INSTALL libsubcmd_headers
    INSTALL libapi_headers
    INSTALL libperf_headers
    INSTALL libsymbol_headers
    INSTALL libbpf_headers
    LINK    perf

  3. libdw version is higher than 0.177

  $ pkg-config --modversion libdw
  0.186
  $ make LDFLAGS=-static -j16
    BUILD:   Doing 'make -j20' parallel build
  <SNIP>

  Auto-detecting system features:
  ...                                   dwarf: [ on  ]
  <SNIP>
    CC      util/bpf-utils.o
    CC      util/pfm.o
    LD      util/perf-util-in.o
    LD      perf-util-in.o
    AR      libperf-util.a
    LINK    perf

Fixes: 536661da6ea1 ("perf: build: Only link libebl.a for old libdw")
Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
---
 tools/build/feature/Makefile | 2 +-
 tools/perf/Makefile.config   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 5938cf799dc6..6f1c961f0ede 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -172,7 +172,7 @@ DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
   DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd
 
-  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
+  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
   LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
   LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
 
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 4dcf7a0fd235..0049fd41cf57 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -149,7 +149,7 @@ DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
   DWARFLIBS += -lelf -ldl -lz -llzma -lbz2 -lzstd
 
-  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw)
+  LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
   LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
   LIBDW_VERSION_2 := $(word 2, $(subst ., ,$(LIBDW_VERSION)))
 
-- 
2.25.1


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

* [PATCH RESEND v3 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw
  2024-09-19  1:35 [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Yang Jihong
  2024-09-19  1:35 ` [PATCH RESEND v3 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
@ 2024-09-19  1:35 ` Yang Jihong
  2024-09-19  1:35 ` [PATCH RESEND v3 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined Yang Jihong
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yang Jihong @ 2024-09-19  1:35 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang, james.clark,
	linux-perf-users, linux-kernel, leo.yan
  Cc: yangjihong

For libdw versions below 0.177, need to link libdl.a in addition to
libbebl.a during static compilation, otherwise feature-dwarf_getlocations
compilation will fail.

Before:

  $ make LDFLAGS=-static
    BUILD:   Doing 'make -j20' parallel build
  <SNIP>
  Makefile.config:483: Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157
  <SNIP>

  $ cat ../build/feature/test-dwarf_getlocations.make.output
  /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libebl.a(eblclosebackend.o): in function `ebl_closebackend':
  (.text+0x20): undefined reference to `dlclose'
  collect2: error: ld returned 1 exit status

After:

  $ make LDFLAGS=-static
  <SNIP>
    Auto-detecting system features:
  ...                                   dwarf: [ on  ]
  <SNIP>

    $ ./perf probe
   Usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
      or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
      or: perf probe [<options>] --del '[GROUP:]EVENT' ...
      or: perf probe --list [GROUP:]EVENT ...
  <SNIP>

Fixes: 536661da6ea1 ("perf: build: Only link libebl.a for old libdw")
Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
---
 tools/build/feature/Makefile | 3 +++
 tools/perf/Makefile.config   | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 6f1c961f0ede..1658596188bf 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -181,6 +181,9 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
   ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
     DWARFLIBS += -lebl
   endif
+
+  # Must put -ldl after -lebl for dependency
+  DWARFLIBS += -ldl
 endif
 
 $(OUTPUT)test-dwarf.bin:
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 0049fd41cf57..4ddb27a48eed 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -147,7 +147,7 @@ ifdef LIBDW_DIR
 endif
 DWARFLIBS := -ldw
 ifeq ($(findstring -static,${LDFLAGS}),-static)
-  DWARFLIBS += -lelf -ldl -lz -llzma -lbz2 -lzstd
+  DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd
 
   LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
   LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
@@ -158,6 +158,9 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
   ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
     DWARFLIBS += -lebl
   endif
+
+  # Must put -ldl after -lebl for dependency
+  DWARFLIBS += -ldl
 endif
 FEATURE_CHECK_CFLAGS-libdw-dwarf-unwind := $(LIBDW_CFLAGS)
 FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind := $(LIBDW_LDFLAGS) $(DWARFLIBS)
-- 
2.25.1


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

* [PATCH RESEND v3 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined
  2024-09-19  1:35 [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Yang Jihong
  2024-09-19  1:35 ` [PATCH RESEND v3 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
  2024-09-19  1:35 ` [PATCH RESEND v3 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw Yang Jihong
@ 2024-09-19  1:35 ` Yang Jihong
  2024-09-24 18:42 ` [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Namhyung Kim
  2024-10-01 18:38 ` Arnaldo Carvalho de Melo
  4 siblings, 0 replies; 6+ messages in thread
From: Yang Jihong @ 2024-09-19  1:35 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang, james.clark,
	linux-perf-users, linux-kernel, leo.yan
  Cc: yangjihong

commit 3796eba7c137 move #else block of #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
code from dwarf-aux.c to dwarf-aux.h, in which die_get_var_range() used ENOTSUP
macro, but dwarf-aux.h was not self-contained and did not include file errno.h.

As a result, the build failed when HAVE_DWARF_GETLOCATIONS_SUPPORT macro was not
defined, and the error log is as follows:

  In file included from util/disasm.h:8,
                   from util/annotate.h:16,
                   from builtin-top.c:23:
  util/dwarf-aux.h: In function 'die_get_var_range':
  util/dwarf-aux.h:184:10: error: 'ENOTSUP' undeclared (first use in this function)
    184 |  return -ENOTSUP;
        |          ^~~~~~~
  util/dwarf-aux.h:184:10: note: each undeclared identifier is reported only once for each function it appears

Fixes: 3796eba7c137 ("perf dwarf-aux: Move #else block of #ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT code to the header file")
Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
---
 tools/perf/util/dwarf-aux.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/dwarf-aux.h b/tools/perf/util/dwarf-aux.h
index 336a3a183a78..f0d702b9ad75 100644
--- a/tools/perf/util/dwarf-aux.h
+++ b/tools/perf/util/dwarf-aux.h
@@ -6,6 +6,7 @@
  */
 
 #include <dwarf.h>
+#include <errno.h>
 #include <elfutils/libdw.h>
 #include <elfutils/libdwfl.h>
 #include <elfutils/version.h>
-- 
2.25.1


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

* Re: [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures
  2024-09-19  1:35 [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Yang Jihong
                   ` (2 preceding siblings ...)
  2024-09-19  1:35 ` [PATCH RESEND v3 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined Yang Jihong
@ 2024-09-24 18:42 ` Namhyung Kim
  2024-10-01 18:38 ` Arnaldo Carvalho de Melo
  4 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2024-09-24 18:42 UTC (permalink / raw)
  To: acme, Yang Jihong
  Cc: peterz, mingo, mark.rutland, alexander.shishkin, jolsa, irogers,
	adrian.hunter, kan.liang, james.clark, linux-perf-users,
	linux-kernel, leo.yan

On Thu, Sep 19, 2024 at 09:35:10AM +0800, Yang Jihong wrote:
> Changes since v3:
>  - Add reviewed-by tag from Leo. (see Link[1])
>  - Resend the patchset with no code changes.
> 
> Link[1]: https://lore.kernel.org/all/b5688d4a-9389-4998-8031-3f002302311e@arm.com/
> 
> Changes since v2:
>  - patch1: change LIBDW_VERSION to follow up the style of
>    LIBTRACEEVENT_VERSION. (by Leo's suggestion)
>  - patch2: Use a new line for the -ldl dependency and with comment,
>    synchronize tools/perf/Makefile.config. (by Leo's suggestion)
>  - patch3: include header files in alphabetical order,
>    add reviewed-by tag from Leo. (by Leo's suggestion)
> 
> Changes since v1:
>  - patch3: Remove UTF-8 characters from build failure logs
> 
> Yang Jihong (3):
>   perf: build: Fix static compilation error when libdw is not installed
>   perf: build: Fix build feature-dwarf_getlocations fail for old libdw
>   perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT
>     undefined

Acked-by: Namhyung Kim <namhyung@kernel.org>

Arnaldo, can you please pick this up to perf-tools tree?

Thanks,
Namhyung

> 
>  tools/build/feature/Makefile | 5 ++++-
>  tools/perf/Makefile.config   | 7 +++++--
>  tools/perf/util/dwarf-aux.h  | 1 +
>  3 files changed, 10 insertions(+), 3 deletions(-)
> 
> -- 
> 2.25.1
> 

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

* Re: [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures
  2024-09-19  1:35 [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Yang Jihong
                   ` (3 preceding siblings ...)
  2024-09-24 18:42 ` [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Namhyung Kim
@ 2024-10-01 18:38 ` Arnaldo Carvalho de Melo
  4 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-01 18:38 UTC (permalink / raw)
  To: Yang Jihong
  Cc: peterz, mingo, namhyung, mark.rutland, alexander.shishkin, jolsa,
	irogers, adrian.hunter, kan.liang, james.clark, linux-perf-users,
	linux-kernel, leo.yan

On Thu, Sep 19, 2024 at 09:35:10AM +0800, Yang Jihong wrote:
> Changes since v3:
>  - Add reviewed-by tag from Leo. (see Link[1])
>  - Resend the patchset with no code changes.

Thanks, applied the first two, the last one I had already picked a patch
from James with what seems a more appropriate Fixes tag.

- Arnaldo
 
> Link[1]: https://lore.kernel.org/all/b5688d4a-9389-4998-8031-3f002302311e@arm.com/
> 
> Changes since v2:
>  - patch1: change LIBDW_VERSION to follow up the style of
>    LIBTRACEEVENT_VERSION. (by Leo's suggestion)
>  - patch2: Use a new line for the -ldl dependency and with comment,
>    synchronize tools/perf/Makefile.config. (by Leo's suggestion)
>  - patch3: include header files in alphabetical order,
>    add reviewed-by tag from Leo. (by Leo's suggestion)
> 
> Changes since v1:
>  - patch3: Remove UTF-8 characters from build failure logs
> 
> Yang Jihong (3):
>   perf: build: Fix static compilation error when libdw is not installed
>   perf: build: Fix build feature-dwarf_getlocations fail for old libdw
>   perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT
>     undefined
> 
>  tools/build/feature/Makefile | 5 ++++-
>  tools/perf/Makefile.config   | 7 +++++--
>  tools/perf/util/dwarf-aux.h  | 1 +
>  3 files changed, 10 insertions(+), 3 deletions(-)
> 
> -- 
> 2.25.1

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

end of thread, other threads:[~2024-10-01 18:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-19  1:35 [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Yang Jihong
2024-09-19  1:35 ` [PATCH RESEND v3 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
2024-09-19  1:35 ` [PATCH RESEND v3 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw Yang Jihong
2024-09-19  1:35 ` [PATCH RESEND v3 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined Yang Jihong
2024-09-24 18:42 ` [PATCH RESEND v3 0/3] perf: build: Minor fixes for build failures Namhyung Kim
2024-10-01 18:38 ` 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).