This patch makes libperf.a complete. Initially it misses the symbols
fdarray_* that makes it unusable:
$ nm tools/lib/perf/libperf.a | grep fdarray_
U fdarray__add
0000000000002b3e t fdarray__available_entries
U fdarray__exit
U fdarray__filter
U fdarray__grow
U fdarray__init
U fdarray__poll
After this patch is applied:
$ nm tools/lib/perf/libperf.a | grep fdarray_
00000000000063f7 T fdarray__add
......
00000000000065d4 T fdarray__poll
Signed-off-by: "Jinshan Xiong" <[email protected]>
---
tools/lib/perf/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/perf/Makefile b/tools/lib/perf/Makefile
index 08fe6e3c4089..840366584fc1 100644
--- a/tools/lib/perf/Makefile
+++ b/tools/lib/perf/Makefile
@@ -121,8 +121,8 @@ $(LIBAPI)-clean:
$(LIBPERF_IN): FORCE
$(Q)$(MAKE) $(build)=libperf
-$(LIBPERF_A): $(LIBPERF_IN)
- $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN)
+$(LIBPERF_A): $(LIBPERF_IN) $(LIBAPI)
+ $(QUIET_AR)$(RM) $@ && $(LD) -r -o libperf-ar.o $^ && $(AR) rcs $@ libperf-ar.o
$(LIBPERF_SO): $(LIBPERF_IN) $(LIBAPI)
$(QUIET_LINK)$(CC) --shared -Wl,-soname,libperf.so \
--
2.30.2
Em Sat, Sep 25, 2021 at 07:30:24PM -0700, Jinshan Xiong escreveu:
> This patch makes libperf.a complete. Initially it misses the symbols
> fdarray_* that makes it unusable:
> $ nm tools/lib/perf/libperf.a | grep fdarray_
> U fdarray__add
> 0000000000002b3e t fdarray__available_entries
> U fdarray__exit
> U fdarray__filter
> U fdarray__grow
> U fdarray__init
> U fdarray__poll
>
> After this patch is applied:
> $ nm tools/lib/perf/libperf.a | grep fdarray_
> 00000000000063f7 T fdarray__add
> ......
> 00000000000065d4 T fdarray__poll
Have you tried to build tools/perf/ with this?
LINK /tmp/build/perf/plugins/plugin_futex.so
LINK /tmp/build/perf/plugins/plugin_jbd2.so
INSTALL trace_plugins
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o):/var/home/acme/git/perf/tools/lib/api/debug.c:20: multiple definition of `__pr_debug'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/debug.c:20: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `sysfs__read_bool':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:505: multiple definition of `sysfs__read_bool'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:505: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `fdarray__poll':
/var/home/acme/git/perf/tools/lib/api/fd/array.c:120: multiple definition of `fdarray__poll'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fd/array.c:120: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `tracefs__configured':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:316: multiple definition of `tracefs__configured'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:316: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `sysfs__read_int':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:479: multiple definition of `sysfs__read_int'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:479: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `fdarray__fprintf':
/var/home/acme/git/perf/tools/lib/api/fd/array.c:125: multiple definition of `fdarray__fprintf'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fd/array.c:125: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `sysfs__write_int':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:547: multiple definition of `sysfs__write_int'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:547: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `filename__read_str':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:378: multiple definition of `filename__read_str'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:378: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `hugetlbfs__mountpoint':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:317: multiple definition of `hugetlbfs__mountpoint'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:317: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `debugfs__mountpoint':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:315: multiple definition of `debugfs__mountpoint'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:315: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `fdarray__delete':
/var/home/acme/git/perf/tools/lib/api/fd/array.c:71: multiple definition of `fdarray__delete'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fd/array.c:71: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `procfs__mountpoint':
/var/home/acme/git/perf/tools/lib/api/fs/fs.c:314: multiple definition of `procfs__mountpoint'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:314: first defined here
/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `get_tracing_file':
/var/home/acme/git/perf/tools/lib/api/fs/tracing_path.c:74: multiple definition of `get_tracing_file'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/tracing_path.c:74: first defined here
You probably need to include libapi.a as well.
- Arnaldo
Thanks for pointing it out. I will make the static library a separate
target for installation. Patch is coming soon.
Jinshan
On Sun, Sep 26, 2021 at 5:14 AM Arnaldo Carvalho de Melo
<[email protected]> wrote:
>
> Em Sat, Sep 25, 2021 at 07:30:24PM -0700, Jinshan Xiong escreveu:
> > This patch makes libperf.a complete. Initially it misses the symbols
> > fdarray_* that makes it unusable:
> > $ nm tools/lib/perf/libperf.a | grep fdarray_
> > U fdarray__add
> > 0000000000002b3e t fdarray__available_entries
> > U fdarray__exit
> > U fdarray__filter
> > U fdarray__grow
> > U fdarray__init
> > U fdarray__poll
> >
> > After this patch is applied:
> > $ nm tools/lib/perf/libperf.a | grep fdarray_
> > 00000000000063f7 T fdarray__add
> > ......
> > 00000000000065d4 T fdarray__poll
>
> Have you tried to build tools/perf/ with this?
>
> LINK /tmp/build/perf/plugins/plugin_futex.so
> LINK /tmp/build/perf/plugins/plugin_jbd2.so
> INSTALL trace_plugins
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o):/var/home/acme/git/perf/tools/lib/api/debug.c:20: multiple definition of `__pr_debug'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/debug.c:20: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `sysfs__read_bool':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:505: multiple definition of `sysfs__read_bool'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:505: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `fdarray__poll':
> /var/home/acme/git/perf/tools/lib/api/fd/array.c:120: multiple definition of `fdarray__poll'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fd/array.c:120: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `tracefs__configured':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:316: multiple definition of `tracefs__configured'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:316: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `sysfs__read_int':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:479: multiple definition of `sysfs__read_int'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:479: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `fdarray__fprintf':
> /var/home/acme/git/perf/tools/lib/api/fd/array.c:125: multiple definition of `fdarray__fprintf'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fd/array.c:125: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `sysfs__write_int':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:547: multiple definition of `sysfs__write_int'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:547: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `filename__read_str':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:378: multiple definition of `filename__read_str'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:378: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `hugetlbfs__mountpoint':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:317: multiple definition of `hugetlbfs__mountpoint'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:317: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `debugfs__mountpoint':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:315: multiple definition of `debugfs__mountpoint'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:315: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `fdarray__delete':
> /var/home/acme/git/perf/tools/lib/api/fd/array.c:71: multiple definition of `fdarray__delete'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fd/array.c:71: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `procfs__mountpoint':
> /var/home/acme/git/perf/tools/lib/api/fs/fs.c:314: multiple definition of `procfs__mountpoint'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/fs.c:314: first defined here
> /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-ar.o): in function `get_tracing_file':
> /var/home/acme/git/perf/tools/lib/api/fs/tracing_path.c:74: multiple definition of `get_tracing_file'; /tmp/build/perf/libapi.a(libapi-in.o):/var/home/acme/git/perf/tools/lib/api/fs/tracing_path.c:74: first defined here
>
> You probably need to include libapi.a as well.
>
> - Arnaldo
This patch makes libperf.a complete. Initially it misses the symbols
fdarray_* that makes it unusable after being installed by:
$ make install DESTDIR=<install_dir>
Check missing symbols:
$ nm tools/lib/perf/libperf.a | grep fdarray_
U fdarray__add
0000000000002b3e t fdarray__available_entries
U fdarray__exit
U fdarray__filter
U fdarray__grow
U fdarray__init
U fdarray__poll
After this patch is applied:
$ nm tools/lib/perf/libperf-ext.a | grep fdarray_
00000000000063f7 T fdarray__add
......
00000000000065d4 T fdarray__poll
Signed-off-by: "Jinshan Xiong" <[email protected]>
---
tools/lib/perf/Makefile | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/lib/perf/Makefile b/tools/lib/perf/Makefile
index 08fe6e3c4089..b2f7f4fd7065 100644
--- a/tools/lib/perf/Makefile
+++ b/tools/lib/perf/Makefile
@@ -94,7 +94,8 @@ LIBPERF_A := $(OUTPUT)libperf.a
LIBPERF_IN := $(OUTPUT)libperf-in.o
LIBPERF_PC := $(OUTPUT)libperf.pc
-LIBPERF_ALL := $(LIBPERF_A) $(OUTPUT)libperf.so*
+LIBPERF_A_EXT := $(OUTPUT)libperf-ext.a
+LIBPERF_LIBS_INSTALL := $(LIBPERF_A_EXT) $(OUTPUT)libperf.so*
LIB_DIR := $(srctree)/tools/lib/api/
@@ -124,6 +125,9 @@ $(LIBPERF_IN): FORCE
$(LIBPERF_A): $(LIBPERF_IN)
$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN)
+$(LIBPERF_A_EXT): $(LIBPERF_IN) $(LIBAPI)
+ $(QUIET_AR)$(RM) $@ && $(LD) -r -o libperf-ext.o $^ && $(AR) rcs $@ libperf-ext.o
+
$(LIBPERF_SO): $(LIBPERF_IN) $(LIBAPI)
$(QUIET_LINK)$(CC) --shared -Wl,-soname,libperf.so \
-Wl,--version-script=$(VERSION_SCRIPT) $^ -o $@
@@ -131,7 +135,7 @@ $(LIBPERF_SO): $(LIBPERF_IN) $(LIBAPI)
@ln -sf $(@F) $(OUTPUT)libperf.so.$(LIBPERF_VERSION)
-libs: $(LIBPERF_A) $(LIBPERF_SO) $(LIBPERF_PC)
+libs: $(LIBPERF_A) $(LIBPERF_A_EXT) $(LIBPERF_SO) $(LIBPERF_PC)
all: fixdep
$(Q)$(MAKE) libs
@@ -183,9 +187,9 @@ define do_install
endef
install_lib: libs
- $(call QUIET_INSTALL, $(LIBPERF_ALL)) \
+ $(call QUIET_INSTALL, $(LIBPERF_LIBS_INSTALL)) \
$(call do_install_mkdir,$(libdir_SQ)); \
- cp -fpR $(LIBPERF_ALL) $(DESTDIR)$(libdir_SQ)
+ cp -fpR $(LIBPERF_LIBS_INSTALL) $(DESTDIR)$(libdir_SQ)
install_headers:
$(call QUIET_INSTALL, headers) \
--
2.30.2
On Mon, Sep 27, 2021 at 03:30:26PM -0700, Jinshan Xiong wrote:
> This patch makes libperf.a complete. Initially it misses the symbols
> fdarray_* that makes it unusable after being installed by:
> $ make install DESTDIR=<install_dir>
>
> Check missing symbols:
> $ nm tools/lib/perf/libperf.a | grep fdarray_
> U fdarray__add
> 0000000000002b3e t fdarray__available_entries
> U fdarray__exit
> U fdarray__filter
> U fdarray__grow
> U fdarray__init
> U fdarray__poll
right, libperf.a should be complete.. but how about we use libperf.a
as source for libapi.a and include it directly in there.. and remove
libapi.a from perf
we will have complete libperf.a without new -ext.a file and perf
compiles properly.. should be also ok for future perf dynamic linking
with libperf.so
I did just quick build test.. I might have missed something
jirka
---
diff --git a/tools/lib/perf/Makefile b/tools/lib/perf/Makefile
index 08fe6e3c4089..e1150408e095 100644
--- a/tools/lib/perf/Makefile
+++ b/tools/lib/perf/Makefile
@@ -109,7 +109,7 @@ else
endif
LIBAPI = $(API_PATH)libapi.a
-export LIBAPI
+LIBAPI_IN = $(API_PATH)libapi-in.o
$(LIBAPI): FORCE
$(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
@@ -121,8 +121,8 @@ $(LIBAPI)-clean:
$(LIBPERF_IN): FORCE
$(Q)$(MAKE) $(build)=libperf
-$(LIBPERF_A): $(LIBPERF_IN)
- $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN)
+$(LIBPERF_A): $(LIBPERF_IN) $(LIBAPI)
+ $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIBPERF_IN) $(LIBAPI_IN)
$(LIBPERF_SO): $(LIBPERF_IN) $(LIBAPI)
$(QUIET_LINK)$(CC) --shared -Wl,-soname,libperf.so \
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index e04313c4d840..a500fd6fe5ea 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -321,9 +321,6 @@ LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list
DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS))
-LIBAPI = $(API_PATH)libapi.a
-export LIBAPI
-
LIBBPF = $(BPF_PATH)libbpf.a
LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a
@@ -340,7 +337,7 @@ export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
-PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
+PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT)
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
@@ -379,7 +376,7 @@ endif
export PERL_PATH
-PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF)
+PERFLIBS = $(LIBSUBCMD) $(LIBPERF)
ifndef NO_LIBBPF
ifndef LIBBPF_DYNAMIC
PERFLIBS += $(LIBBPF)
@@ -820,13 +817,6 @@ $(LIBTRACEEVENT)-clean:
install-traceevent-plugins: libtraceevent_plugins
$(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins
-$(LIBAPI): FORCE
- $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a
-
-$(LIBAPI)-clean:
- $(call QUIET_CLEAN, libapi)
- $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
-
$(LIBBPF): FORCE
$(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
@@ -1078,7 +1068,7 @@ endif # BUILD_BPF_SKEL
bpf-skel-clean:
$(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)
-clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean
+clean:: $(LIBTRACEEVENT)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean
$(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(OUTPUT)perf-iostat $(LANG_BINDINGS)
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
$(Q)$(RM) $(OUTPUT).config-detected
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 483f05004e68..c470a67d2b77 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -51,7 +51,6 @@ src_perf = getenv('srctree') + '/tools/perf'
build_lib = getenv('PYTHON_EXTBUILD_LIB')
build_tmp = getenv('PYTHON_EXTBUILD_TMP')
libtraceevent = getenv('LIBTRACEEVENT')
-libapikfs = getenv('LIBAPI')
libperf = getenv('LIBPERF')
ext_sources = [f.strip() for f in open('util/python-ext-sources')
@@ -71,7 +70,7 @@ perf = Extension('perf',
include_dirs = ['util/include'],
libraries = extra_libraries,
extra_compile_args = cflags,
- extra_objects = [libtraceevent, libapikfs, libperf],
+ extra_objects = [libtraceevent, libperf],
)
setup(name='perf',