* [PATCH v2 0/3] perf: build: Minor fixes for build failures
@ 2024-08-06 11:47 Yang Jihong
2024-08-06 11:47 ` [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Yang Jihong @ 2024-08-06 11:47 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
linux-kernel
Cc: yangjihong
This patchset contains minor fixes for build failures when statically compiling in Ubuntu 20.04.
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 | 4 ++--
tools/perf/Makefile.config | 2 +-
tools/perf/util/dwarf-aux.h | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed
2024-08-06 11:47 [PATCH v2 0/3] perf: build: Minor fixes for build failures Yang Jihong
@ 2024-08-06 11:47 ` Yang Jihong
2024-08-06 21:00 ` Leo Yan
2024-08-06 11:48 ` [PATCH v2 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw Yang Jihong
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Yang Jihong @ 2024-08-06 11:47 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
linux-kernel
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")
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 12796808f07a..b18513ec4da6 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -178,7 +178,7 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
# Elfutils merged libebl.a into libdw.a starting from version 0.177,
# Link libebl.a only if libdw is older than this version.
- ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
+ ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
DWARFLIBS += -lebl
endif
endif
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index fa679db61f62..7d1003d2efb2 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -160,7 +160,7 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
# Elfutils merged libebl.a into libdw.a starting from version 0.177,
# Link libebl.a only if libdw is older than this version.
- ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
+ ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
DWARFLIBS += -lebl
endif
endif
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw
2024-08-06 11:47 [PATCH v2 0/3] perf: build: Minor fixes for build failures Yang Jihong
2024-08-06 11:47 ` [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
@ 2024-08-06 11:48 ` Yang Jihong
2024-08-06 21:28 ` Leo Yan
2024-08-06 11:48 ` [PATCH v2 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined Yang Jihong
2024-08-06 17:58 ` [PATCH v2 0/3] perf: build: Minor fixes for build failures Namhyung Kim
3 siblings, 1 reply; 11+ messages in thread
From: Yang Jihong @ 2024-08-06 11:48 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
linux-kernel
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")
Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
---
tools/build/feature/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index b18513ec4da6..1fc651cae9e5 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -179,7 +179,7 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
# Elfutils merged libebl.a into libdw.a starting from version 0.177,
# Link libebl.a only if libdw is older than this version.
ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
- DWARFLIBS += -lebl
+ DWARFLIBS += -lebl -ldl
endif
endif
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined
2024-08-06 11:47 [PATCH v2 0/3] perf: build: Minor fixes for build failures Yang Jihong
2024-08-06 11:47 ` [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
2024-08-06 11:48 ` [PATCH v2 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw Yang Jihong
@ 2024-08-06 11:48 ` Yang Jihong
2024-08-06 21:34 ` Leo Yan
2024-08-06 17:58 ` [PATCH v2 0/3] perf: build: Minor fixes for build failures Namhyung Kim
3 siblings, 1 reply; 11+ messages in thread
From: Yang Jihong @ 2024-08-06 11:48 UTC (permalink / raw)
To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
linux-kernel
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")
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 24446412b869..d2903894538e 100644
--- a/tools/perf/util/dwarf-aux.h
+++ b/tools/perf/util/dwarf-aux.h
@@ -5,6 +5,7 @@
* dwarf-aux.h : libdw auxiliary interfaces
*/
+#include <errno.h>
#include <dwarf.h>
#include <elfutils/libdw.h>
#include <elfutils/libdwfl.h>
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 0/3] perf: build: Minor fixes for build failures
2024-08-06 11:47 [PATCH v2 0/3] perf: build: Minor fixes for build failures Yang Jihong
` (2 preceding siblings ...)
2024-08-06 11:48 ` [PATCH v2 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined Yang Jihong
@ 2024-08-06 17:58 ` Namhyung Kim
3 siblings, 0 replies; 11+ messages in thread
From: Namhyung Kim @ 2024-08-06 17:58 UTC (permalink / raw)
To: Yang Jihong
Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
irogers, adrian.hunter, kan.liang, linux-perf-users, linux-kernel,
Leo Yan
Add Leo to Cc.
On Tue, Aug 6, 2024 at 4:48 AM Yang Jihong <yangjihong@bytedance.com> wrote:
>
> This patchset contains minor fixes for build failures when statically compiling in Ubuntu 20.04.
>
> 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 | 4 ++--
> tools/perf/Makefile.config | 2 +-
> tools/perf/util/dwarf-aux.h | 1 +
> 3 files changed, 4 insertions(+), 3 deletions(-)
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed
2024-08-06 11:47 ` [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
@ 2024-08-06 21:00 ` Leo Yan
2024-08-07 3:16 ` Yang Jihong
0 siblings, 1 reply; 11+ messages in thread
From: Leo Yan @ 2024-08-06 21:00 UTC (permalink / raw)
To: Yang Jihong, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, kan.liang,
linux-perf-users, linux-kernel
On 8/6/2024 12:47 PM, Yang Jihong wrote:
> 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")
> 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 12796808f07a..b18513ec4da6 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -178,7 +178,7 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
>
> # Elfutils merged libebl.a into libdw.a starting from version 0.177,
> # Link libebl.a only if libdw is older than this version.
> - ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
> + ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
I would like to follow up the style of LIBTRACEEVENT_VERSION and
LIBTRACEFS_VERSION, so change LIBDW_VERSION as below:
LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
Does this work for you?
Thanks,
Leo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw
2024-08-06 11:48 ` [PATCH v2 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw Yang Jihong
@ 2024-08-06 21:28 ` Leo Yan
2024-08-07 3:18 ` Yang Jihong
0 siblings, 1 reply; 11+ messages in thread
From: Leo Yan @ 2024-08-06 21:28 UTC (permalink / raw)
To: Yang Jihong, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, kan.liang,
linux-perf-users, linux-kernel
On 8/6/2024 12:48 PM, Yang Jihong wrote:
>
> 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
Indeed. Thanks for pointing out this.
> 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")
> Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
> ---
> tools/build/feature/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index b18513ec4da6..1fc651cae9e5 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -179,7 +179,7 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
> # Elfutils merged libebl.a into libdw.a starting from version 0.177,
> # Link libebl.a only if libdw is older than this version.
> ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
> - DWARFLIBS += -lebl
> + DWARFLIBS += -lebl -ldl
> endif
One critical thing is the ordering of libs. We must put libdl after libebl,
otherwise, the building still fails (based on my test).
Given libdl is a general lib, I think it is good to add a line after the
`endif` wrapper and with a comment, something like:
ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
DWARFLIBS += -lebl
endif
# Must put -ldl after -lebl for dependency
DWARFLIBS += -ldl
Please update the file tools/perf/Makefile.config for consistency.
Thanks,
Leo
> endif
>
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined
2024-08-06 11:48 ` [PATCH v2 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined Yang Jihong
@ 2024-08-06 21:34 ` Leo Yan
2024-08-07 3:19 ` Yang Jihong
0 siblings, 1 reply; 11+ messages in thread
From: Leo Yan @ 2024-08-06 21:34 UTC (permalink / raw)
To: Yang Jihong, peterz, mingo, acme, namhyung, mark.rutland,
alexander.shishkin, jolsa, irogers, adrian.hunter, kan.liang,
linux-perf-users, linux-kernel
On 8/6/2024 12:48 PM, Yang Jihong wrote:
> 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")
> 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 24446412b869..d2903894538e 100644
> --- a/tools/perf/util/dwarf-aux.h
> +++ b/tools/perf/util/dwarf-aux.h
> @@ -5,6 +5,7 @@
> * dwarf-aux.h : libdw auxiliary interfaces
> */
>
> +#include <errno.h>
> #include <dwarf.h>
Please alphabet ordering. With it:
Reviewed-by: Leo Yan <leo.yan@arm.com>
> #include <elfutils/libdw.h>
> #include <elfutils/libdwfl.h>
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed
2024-08-06 21:00 ` Leo Yan
@ 2024-08-07 3:16 ` Yang Jihong
0 siblings, 0 replies; 11+ messages in thread
From: Yang Jihong @ 2024-08-07 3:16 UTC (permalink / raw)
To: Leo Yan
Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
linux-kernel
Hello,
On 8/7/24 05:00, Leo Yan wrote:
> On 8/6/2024 12:47 PM, Yang Jihong wrote:
>> 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")
>> 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 12796808f07a..b18513ec4da6 100644
>> --- a/tools/build/feature/Makefile
>> +++ b/tools/build/feature/Makefile
>> @@ -178,7 +178,7 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
>>
>> # Elfutils merged libebl.a into libdw.a starting from version 0.177,
>> # Link libebl.a only if libdw is older than this version.
>> - ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
>> + ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
>
> I would like to follow up the style of LIBTRACEEVENT_VERSION and
> LIBTRACEFS_VERSION, so change LIBDW_VERSION as below:
>
> LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
>
> Does this work for you?
Yes, have tested it in my environment and it works for me.
OK, will change in next version.
Thanks,
Yang
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw
2024-08-06 21:28 ` Leo Yan
@ 2024-08-07 3:18 ` Yang Jihong
0 siblings, 0 replies; 11+ messages in thread
From: Yang Jihong @ 2024-08-07 3:18 UTC (permalink / raw)
To: Leo Yan
Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
linux-kernel
Hello,
On 8/7/24 05:28, Leo Yan wrote:
> On 8/6/2024 12:48 PM, Yang Jihong wrote:
>>
>> 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
>
> Indeed. Thanks for pointing out this.
>
>> 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")
>> Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
>> ---
>> tools/build/feature/Makefile | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
>> index b18513ec4da6..1fc651cae9e5 100644
>> --- a/tools/build/feature/Makefile
>> +++ b/tools/build/feature/Makefile
>> @@ -179,7 +179,7 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
>> # Elfutils merged libebl.a into libdw.a starting from version 0.177,
>> # Link libebl.a only if libdw is older than this version.
>> ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
>> - DWARFLIBS += -lebl
>> + DWARFLIBS += -lebl -ldl
>> endif
>
> One critical thing is the ordering of libs. We must put libdl after libebl,
> otherwise, the building still fails (based on my test).
>
> Given libdl is a general lib, I think it is good to add a line after the
> `endif` wrapper and with a comment, something like:
>
> ifeq ($(shell test $(LIBDW_VERSION_2)0 -lt 1770; echo $$?),0)
> DWARFLIBS += -lebl
> endif
>
> # Must put -ldl after -lebl for dependency
> DWARFLIBS += -ldl
>
> Please update the file tools/perf/Makefile.config for consistency.
Okay, will change in next version.
Thanks,
Yang
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined
2024-08-06 21:34 ` Leo Yan
@ 2024-08-07 3:19 ` Yang Jihong
0 siblings, 0 replies; 11+ messages in thread
From: Yang Jihong @ 2024-08-07 3:19 UTC (permalink / raw)
To: Leo Yan
Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
jolsa, irogers, adrian.hunter, kan.liang, linux-perf-users,
linux-kernel
Hello,
On 8/7/24 05:34, Leo Yan wrote:
> On 8/6/2024 12:48 PM, Yang Jihong wrote:
>> 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")
>> 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 24446412b869..d2903894538e 100644
>> --- a/tools/perf/util/dwarf-aux.h
>> +++ b/tools/perf/util/dwarf-aux.h
>> @@ -5,6 +5,7 @@
>> * dwarf-aux.h : libdw auxiliary interfaces
>> */
>>
>> +#include <errno.h>
>> #include <dwarf.h>
>
> Please alphabet ordering. With it:
>
> Reviewed-by: Leo Yan <leo.yan@arm.com>
>
Okay, will change in next version.
Thanks,
Yang
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-08-07 3:19 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-06 11:47 [PATCH v2 0/3] perf: build: Minor fixes for build failures Yang Jihong
2024-08-06 11:47 ` [PATCH v2 1/3] perf: build: Fix static compilation error when libdw is not installed Yang Jihong
2024-08-06 21:00 ` Leo Yan
2024-08-07 3:16 ` Yang Jihong
2024-08-06 11:48 ` [PATCH v2 2/3] perf: build: Fix build feature-dwarf_getlocations fail for old libdw Yang Jihong
2024-08-06 21:28 ` Leo Yan
2024-08-07 3:18 ` Yang Jihong
2024-08-06 11:48 ` [PATCH v2 3/3] perf dwarf-aux: Fix build fail when HAVE_DWARF_GETLOCATIONS_SUPPORT undefined Yang Jihong
2024-08-06 21:34 ` Leo Yan
2024-08-07 3:19 ` Yang Jihong
2024-08-06 17:58 ` [PATCH v2 0/3] perf: build: Minor fixes for build failures Namhyung Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.