Skip to contentSkip to conversation

tools lib traceevent: Install fixes

RFC In review Jiri Olsa 6 participants 25 messages Aug 1, 2016 – Jan 26, 2018

lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

cover tools lib traceevent: Install fixes

hi,
sending traceevent changes to make this lib installable under rpm spec.

Basically adding support to:
- install header files
- install version links

Having this patchset applied over the fedora source, I could built following rpms:

kernel-tools-libs
kernel-tools-libs-devel

with added libtraceevent stuff:

  $ rpm -ql kernel-tools-libs
  /usr/lib64/libcpupower.so.0
  /usr/lib64/libcpupower.so.0.0.0
  /usr/lib64/libtraceevent.so.1
  /usr/lib64/libtraceevent.so.1.1.0
  $ rpm -ql kernel-tools-libs-devel
  /usr/include/cpufreq.h
  /usr/include/traceevent
  /usr/include/traceevent/event-parse.h
  /usr/include/traceevent/event-utils.h
  /usr/include/traceevent/kbuffer.h
  /usr/lib64/libcpupower.so
  /usr/lib64/libtraceevent.a
  /usr/lib64/libtraceevent.so

and could build following ex.c outside the kernel tree:

  $ cat ex.c 
  #include <traceevent/event-parse.h>
  int main(void)
  {
          struct pevent *pevent = pevent_alloc();
          printf("krava %p\n", pevent);
          return 0;
  }
  $ gcc -o ex ex.c -ltraceevent -ldl
  $ ./ex
  krava 0x10c6010
  $

I'll send out fedora rpm build changes once we decide on this patchset.

Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
traceevent/install

thanks,
jirka

---
Jiri Olsa (4):
tools lib traceevent: Add install_headers target tools lib traceevent: Add do_install_mkdir Makefile function tools lib traceevent: Rename LIB_FILE to LIB_TARGET tools lib traceevent: Add version for traceevent shared object

 tools/lib/traceevent/Makefile | 40 +++++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 13 deletions(-)
author
#1 lore raw

PATCH 1/4 tools lib traceevent: Add install_headers target

Adding install_headers target to install all headers under 'include/traceevent' path, like:

  $ make DESTDIR=/tmp/krava prefix=/usr install_headers
  $ find /tmp/krava/ -type f
  /tmp/krava/usr/include/traceevent/kbuffer.h
  /tmp/krava/usr/include/traceevent/event-utils.h
  /tmp/krava/usr/include/traceevent/event-parse.h
---
 tools/lib/traceevent/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/lib/traceevent/Makefile +7 -1
index 7851df1490e0..8e44bea646ee 100644
@@ -240,7 +240,7 @@ define do_install
 	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
 	fi;						\
-	$(INSTALL) $1 '$(DESTDIR_SQ)$2'
+	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
 endef
 
 define do_install_plugins
@@ -264,6 +264,12 @@ install_plugins: $(PLUGINS)
 	$(call QUIET_INSTALL, trace_plugins) \
 		$(call do_install_plugins, $(PLUGINS))
 
+install_headers:
+	$(call QUIET_INSTALL, headers) \
+		$(call do_install,event-parse.h,$(prefix)/include/traceevent,644); \
+		$(call do_install,event-utils.h,$(prefix)/include/traceevent,644); \
+		$(call do_install,kbuffer.h,$(prefix)/include/traceevent,644)
+
 install: install_lib
 
 clean:
Signature · 1 line
2.4.11
#2 lore raw

Re: [PATCH 1/4] tools lib traceevent: Add install_headers target

Hi Jiri,

Quoted 30 lines · Jiri Olsa

Adding install_headers target to install all headers under 'include/traceevent' path, like:

  $ make DESTDIR=/tmp/krava prefix=/usr install_headers
  $ find /tmp/krava/ -type f
  /tmp/krava/usr/include/traceevent/kbuffer.h
  /tmp/krava/usr/include/traceevent/event-utils.h
  /tmp/krava/usr/include/traceevent/event-parse.h
---
 tools/lib/traceevent/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/lib/traceevent/Makefile +1 -1
index 7851df1490e0..8e44bea646ee 100644
@@ -240,7 +240,7 @@ define do_install
 	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
 	fi;						\
-	$(INSTALL) $1 '$(DESTDIR_SQ)$2'
+	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
 endef
 
 define do_install_plugins

tools/lib/traceevent/Makefile install_plugins: $(PLUGINS) · line 271

Quoted 8 lines
tools/lib/traceevent/Makefile +5 -0
@@ -264,6 +264,12 @@ install_plugins: $(PLUGINS)
 	$(call QUIET_INSTALL, trace_plugins) \
 		$(call do_install_plugins, $(PLUGINS))
 
+install_headers:
+	$(call QUIET_INSTALL, headers) \
+		$(call do_install,event-parse.h,$(prefix)/include/traceevent,644); \
+		$(call do_install,event-utils.h,$(prefix)/include/traceevent,644); \
+		$(call do_install,kbuffer.h,$(prefix)/include/traceevent,644)

For possible future changes, what about making it to use the wildcard somehow? Or else, we could define HEADER_FILES variable..

Thanks,
Namhyung

Quoted 7 lines
tools/lib/traceevent/Makefile +1 -0
+
 install: install_lib
 
 clean:
Signature · 1 line
2.4.11
#3 lore raw

Re: [PATCH 1/4] tools lib traceevent: Add install_headers target

Quoted 36 lines · Namhyung Kim

Hi Jiri,

Quoted 33 lines · Jiri Olsa

Adding install_headers target to install all headers under 'include/traceevent' path, like:

  $ make DESTDIR=/tmp/krava prefix=/usr install_headers
  $ find /tmp/krava/ -type f
  /tmp/krava/usr/include/traceevent/kbuffer.h
  /tmp/krava/usr/include/traceevent/event-utils.h
  /tmp/krava/usr/include/traceevent/event-parse.h
---
 tools/lib/traceevent/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/lib/traceevent/Makefile +1 -1
index 7851df1490e0..8e44bea646ee 100644
@@ -240,7 +240,7 @@ define do_install
 	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
 	fi;						\
-	$(INSTALL) $1 '$(DESTDIR_SQ)$2'
+	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
 endef
 
 define do_install_plugins
@@ -264,6 +264,12 @@ install_plugins: $(PLUGINS)
 	$(call QUIET_INSTALL, trace_plugins) \
 		$(call do_install_plugins, $(PLUGINS))
 
Quoted 8 lines

tools/lib/traceevent/Makefile install_plugins: $(PLUGINS) · line 271

Quoted 5 lines
tools/lib/traceevent/Makefile +5 -0
+install_headers:
+	$(call QUIET_INSTALL, headers) \
+		$(call do_install,event-parse.h,$(prefix)/include/traceevent,644); \
+		$(call do_install,event-utils.h,$(prefix)/include/traceevent,644); \
+		$(call do_install,kbuffer.h,$(prefix)/include/traceevent,644)

For possible future changes, what about making it to use the wildcard somehow? Or else, we could define HEADER_FILES variable..

right we can.. but I dont expect increase of header files any time soon ;-)

jirka

author
#4 lore raw

PATCH 2/4 tools lib traceevent: Add do_install_mkdir Makefile function

In reply to Jiri Olsa

Decompose the do_install function to ease up
the following patch a little.

---
 tools/lib/traceevent/Makefile | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tools/lib/traceevent/Makefile +7 -3
index 8e44bea646ee..deeae5201ec9 100644
@@ -236,10 +236,14 @@ TAGS:	force
 	find . -name '*.[ch]' | xargs etags \
 	--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'
 
+define do_install_mkdir
+	if [ ! -d '$(DESTDIR_SQ)$1' ]; then		\
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1';	\
+	fi
+endef
+
 define do_install
-	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
-	fi;						\
+	$(call do_install_mkdir,$2);			\
 	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
 endef
 
Signature · 1 line
2.4.11
author
#5 lore raw

PATCH 3/4 tools lib traceevent: Rename LIB_FILE to LIB_TARGET

In reply to Jiri Olsa

To ease up following patch.

---
 tools/lib/traceevent/Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/lib/traceevent/Makefile +6 -6
index deeae5201ec9..0d7e1725a0f8 100644
@@ -99,7 +99,7 @@ libdir_SQ = $(subst ','\'',$(libdir))
 libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
 plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
 
-LIB_FILE = libtraceevent.a libtraceevent.so
+LIB_TARGET = libtraceevent.a libtraceevent.so
 
 CONFIG_INCLUDES = 
 CONFIG_LIBS	=
@@ -156,11 +156,11 @@ PLUGINS += plugin_cfg80211.so
 PLUGINS    := $(addprefix $(OUTPUT),$(PLUGINS))
 PLUGINS_IN := $(PLUGINS:.so=-in.o)
 
-TE_IN    := $(OUTPUT)libtraceevent-in.o
-LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE))
+TE_IN      := $(OUTPUT)libtraceevent-in.o
+LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET))
 DYNAMIC_LIST_FILE := $(OUTPUT)libtraceevent-dynamic-list
 
-CMD_TARGETS = $(LIB_FILE) $(PLUGINS) $(DYNAMIC_LIST_FILE)
+CMD_TARGETS = $(LIB_TARGET) $(PLUGINS) $(DYNAMIC_LIST_FILE)
 
 TARGETS = $(CMD_TARGETS)
 
@@ -261,8 +261,8 @@ define do_generate_dynamic_list_file
 endef
 
 install_lib: all_cmd install_plugins
-	$(call QUIET_INSTALL, $(LIB_FILE)) \
-		$(call do_install,$(LIB_FILE),$(libdir_SQ))
+	$(call QUIET_INSTALL, $(LIB_TARGET)) \
+		$(call do_install,$(LIB_TARGET),$(libdir_SQ))
 
 install_plugins: $(PLUGINS)
 	$(call QUIET_INSTALL, trace_plugins) \
Signature · 1 line
2.4.11
author
#6 lore raw

PATCH 4/4 tools lib traceevent: Add version for traceevent shared object

In reply to Jiri Olsa

Adding version support for libtraceevent.so object.

Using the existing EVENT_PARSE_VERSION variable to construct the .so object version string, which now consists of:

  $(EP_VERSION).$(EP_PATCHLEVEL).$(EP_EXTRAVERSION)

Looks like it was created for this purpose anyway.

The build will now produce following traeceevent libraries:

  $ ll libtraceevent*
  libtraceevent.a
  libtraceevent.so -> libtraceevent.so.1.1.0
  libtraceevent.so.1 -> libtraceevent.so.1.1.0
  libtraceevent.so.1.1.0

Also the install target will carry them:

  $ make DESTDIR=/tmp/krava prefix=/usr install
  INSTALL  trace_plugins
  INSTALL  libtraceevent.a
  INSTALL  libtraceevent.so.1.1.0
  $ find /tmp/krava/ | xargs ls -l
  ...
  /tmp/krava/usr/lib64:
  total 572
  libtraceevent.a
  libtraceevent.so -> libtraceevent.so.1.1.0
  libtraceevent.so.1 -> libtraceevent.so.1.1.0
  libtraceevent.so.1.1.0
  ...
---
 tools/lib/traceevent/Makefile | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
tools/lib/traceevent/Makefile +9 -5
index 0d7e1725a0f8..c76012ebdb9c 100644
@@ -99,8 +99,6 @@ libdir_SQ = $(subst ','\'',$(libdir))
 libdir_relative_SQ = $(subst ','\'',$(libdir_relative))
 plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
 
-LIB_TARGET = libtraceevent.a libtraceevent.so
-
 CONFIG_INCLUDES = 
 CONFIG_LIBS	=
 CONFIG_FLAGS	=
@@ -114,6 +112,9 @@ N		=
 
 EVENT_PARSE_VERSION = $(EP_VERSION).$(EP_PATCHLEVEL).$(EP_EXTRAVERSION)
 
+LIB_TARGET  = libtraceevent.a libtraceevent.so.$(EVENT_PARSE_VERSION)
+LIB_INSTALL = libtraceevent.a libtraceevent.so*
+
 INCLUDES = -I. -I $(srctree)/tools/include $(CONFIG_INCLUDES)
 
 # Set compile option CFLAGS
@@ -171,8 +172,10 @@ all_cmd: $(CMD_TARGETS)
 $(TE_IN): force
 	$(Q)$(MAKE) $(build)=libtraceevent
 
-$(OUTPUT)libtraceevent.so: $(TE_IN)
-	$(QUIET_LINK)$(CC) --shared $^ -o $@
+$(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN)
+	$(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
+	@ln -sf $(@F) $(OUTPUT)libtraceevent.so
+	@ln -sf $(@F) $(OUTPUT)libtraceevent.so.$(EP_VERSION)
 
 $(OUTPUT)libtraceevent.a: $(TE_IN)
 	$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
@@ -262,7 +265,8 @@ endef
 
 install_lib: all_cmd install_plugins
 	$(call QUIET_INSTALL, $(LIB_TARGET)) \
-		$(call do_install,$(LIB_TARGET),$(libdir_SQ))
+		$(call do_install_mkdir,$(libdir_SQ)); \
+		cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
 
 install_plugins: $(PLUGINS)
 	$(call QUIET_INSTALL, trace_plugins) \
Signature · 1 line
2.4.11
#7 lore raw
In reply to Jiri Olsa
Quoted 37 lines · Jiri Olsa

hi,
sending traceevent changes to make this lib installable under rpm spec.

Basically adding support to:
- install header files
- install version links

Having this patchset applied over the fedora source, I could built following rpms:

kernel-tools-libs
kernel-tools-libs-devel

with added libtraceevent stuff:

  $ rpm -ql kernel-tools-libs
  /usr/lib64/libcpupower.so.0
  /usr/lib64/libcpupower.so.0.0.0
  /usr/lib64/libtraceevent.so.1
  /usr/lib64/libtraceevent.so.1.1.0
  $ rpm -ql kernel-tools-libs-devel
  /usr/include/cpufreq.h
  /usr/include/traceevent
  /usr/include/traceevent/event-parse.h
  /usr/include/traceevent/event-utils.h
  /usr/include/traceevent/kbuffer.h
  /usr/lib64/libcpupower.so
  /usr/lib64/libtraceevent.a
  /usr/lib64/libtraceevent.so

and could build following ex.c outside the kernel tree:

  $ cat ex.c 
  #include <traceevent/event-parse.h>
Quoted 10 lines
  int main(void)
  {
          struct pevent *pevent = pevent_alloc();
          printf("krava %p\n", pevent);
          return 0;
  }
  $ gcc -o ex ex.c -ltraceevent -ldl
  $ ./ex
  krava 0x10c6010
  $

On my system, building ex.c with libtraceevent failed:

$ gcc -I ~/.local/include/ ex.c -L ~/.local/lib64 -ltraceevent -ldl
/home/namhyung/.local/lib64/libtraceevent.so: undefined reference to `str_error_r'
collect2: error: ld returned 1 exit status

Also I think it'd be better for libtraceevent has dependency to libdl explicitly so that we can get rid of -ldl at the end.

Quoted 1 line

From ac7dc027274cb31f5860c4cf6219ea7584611e17 Mon Sep 17 00:00:00 2001

From: Namhyung Kim <[email protected]>
Date: Tue, 2 Aug 2016 12:03:00 +0900
Subject: [PATCH] tools lib traceevent: Add dependency to libdl

The libtraceevent has dependency to libdl due to plugins. So if external program wants to link libtraceevent it also needs to add -ldl to the compiler command line. Make it explicit so that external programs doesn't care about the internel dependency of libtraceevent anymore.

---
 tools/lib/traceevent/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/Makefile +1 -1
index c76012ebdb9c..bae0c090c638 100644
@@ -173,7 +173,7 @@ $(TE_IN): force
 	$(Q)$(MAKE) $(build)=libtraceevent
 
 $(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN)
-	$(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
+	$(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@ -ldl
 	@ln -sf $(@F) $(OUTPUT)libtraceevent.so
 	@ln -sf $(@F) $(OUTPUT)libtraceevent.so.$(EP_VERSION)
 
Signature · 1 line
2.9.2
#8 lore raw

PATCH 1/2 tools lib traceevent: Ignore generated library files

---
 tools/lib/traceevent/.gitignore | 1 +
 1 file changed, 1 insertion(+)
tools/lib/traceevent/.gitignore +1 -0
index 3c60335fe7be..9e9f25fb1922 100644
@@ -1,2 +1,3 @@
 TRACEEVENT-CFLAGS
 libtraceevent-dynamic-list
+libtraceevent.so.*
Signature · 1 line
2.9.2
#9 lore raw

PATCH 2/2 tools lib traceevent: Add str_error_r()

The libtraceevent uses str_error_r() but its implementation is outside of the library. So if an external program wants to link the libtraceevent it'd fail due to missing str_error_r. Add it.

---
 tools/lib/traceevent/Build | 4 ++++
 1 file changed, 4 insertions(+)
tools/lib/traceevent/Build +4 -0
index c681d0575d16..a4efdf7876ce 100644
@@ -4,6 +4,10 @@ libtraceevent-y += trace-seq.o
 libtraceevent-y += parse-filter.o
 libtraceevent-y += parse-utils.o
 libtraceevent-y += kbuffer-parse.o
+libtraceevent-y += str_error_r.o
+
+str_error_r.o: ../str_error_r.c
+	$(call if_changed_dep,cc_o_c)
 
 plugin_jbd2-y         += plugin_jbd2.o
 plugin_hrtimer-y      += plugin_hrtimer.o
Signature · 1 line
2.9.2
#10 lore raw

Re: [PATCH 2/2] tools lib traceevent: Add str_error_r()

Quoted 3 lines · Namhyung Kim

The libtraceevent uses str_error_r() but its implementation is outside of the library. So if an external program wants to link the libtraceevent it'd fail due to missing str_error_r. Add it.

Please ignore this as it breaks perf build due to multiple definition. :-/

Thanks,
Namhyung

Quoted 24 lines
---
 tools/lib/traceevent/Build | 4 ++++
 1 file changed, 4 insertions(+)
tools/lib/traceevent/Build +4 -1
index c681d0575d16..a4efdf7876ce 100644
@@ -4,6 +4,10 @@ libtraceevent-y += trace-seq.o
 libtraceevent-y += parse-filter.o
 libtraceevent-y += parse-utils.o
 libtraceevent-y += kbuffer-parse.o
+libtraceevent-y += str_error_r.o
+
+str_error_r.o: ../str_error_r.c
+       $(call if_changed_dep,cc_o_c)
 
 plugin_jbd2-y         += plugin_jbd2.o
 plugin_hrtimer-y      += plugin_hrtimer.o
--

2.9.2

Signature · 2 lines
Thanks,
Namhyung
#11 lore raw

[tip:perf/urgent] tools lib traceevent: Ignore generated library files

In reply to Namhyung Kim
tools lib traceevent: Ignore generated library files
Commit-ID:  979a70a237efb68e15b1cee36f9f92037e71d1fd
Gitweb:     http://git.kernel.org/tip/979a70a237efb68e15b1cee36f9f92037e71d1fd
Author:     Namhyung Kim <[email protected]>
AuthorDate: Tue, 2 Aug 2016 14:01:47 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 2 Aug 2016 12:16:13 -0300

tools lib traceevent: Ignore generated library files

---
 tools/lib/traceevent/.gitignore | 1 +
 1 file changed, 1 insertion(+)
tools/lib/traceevent/.gitignore +1 -0
index 3c60335..9e9f25f 100644
@@ -1,2 +1,3 @@
 TRACEEVENT-CFLAGS
 libtraceevent-dynamic-list
+libtraceevent.so.*
#12 lore raw
In reply to Namhyung Kim
Quoted 51 lines · Namhyung Kim
Quoted 37 lines · Jiri Olsa

hi,
sending traceevent changes to make this lib installable under rpm spec.

Basically adding support to:
- install header files
- install version links

Having this patchset applied over the fedora source, I could built following rpms:

kernel-tools-libs
kernel-tools-libs-devel

with added libtraceevent stuff:

  $ rpm -ql kernel-tools-libs
  /usr/lib64/libcpupower.so.0
  /usr/lib64/libcpupower.so.0.0.0
  /usr/lib64/libtraceevent.so.1
  /usr/lib64/libtraceevent.so.1.1.0
  $ rpm -ql kernel-tools-libs-devel
  /usr/include/cpufreq.h
  /usr/include/traceevent
  /usr/include/traceevent/event-parse.h
  /usr/include/traceevent/event-utils.h
  /usr/include/traceevent/kbuffer.h
  /usr/lib64/libcpupower.so
  /usr/lib64/libtraceevent.a
  /usr/lib64/libtraceevent.so

and could build following ex.c outside the kernel tree:

  $ cat ex.c 
  #include <traceevent/event-parse.h>
Quoted 10 lines
  int main(void)
  {
          struct pevent *pevent = pevent_alloc();
          printf("krava %p\n", pevent);
          return 0;
  }
  $ gcc -o ex ex.c -ltraceevent -ldl
  $ ./ex
  krava 0x10c6010
  $

On my system, building ex.c with libtraceevent failed:

Quoted 7 lines
$ gcc -I ~/.local/include/ ex.c -L ~/.local/lib64 -ltraceevent -ldl
/home/namhyung/.local/lib64/libtraceevent.so: undefined reference to `str_error_r'
collect2: error: ld returned 1 exit status

Also I think it'd be better for libtraceevent has dependency to libdl explicitly so that we can get rid of -ldl at the end.

agreed, I'll queue your patch if v2 is needed

thanks,
jirka

Quoted 34 lines

From ac7dc027274cb31f5860c4cf6219ea7584611e17 Mon Sep 17 00:00:00 2001
From: Namhyung Kim <[email protected]>
Date: Tue, 2 Aug 2016 12:03:00 +0900
Subject: [PATCH] tools lib traceevent: Add dependency to libdl

The libtraceevent has dependency to libdl due to plugins. So if external program wants to link libtraceevent it also needs to add -ldl to the compiler command line. Make it explicit so that external programs doesn't care about the internel dependency of libtraceevent anymore.

---
 tools/lib/traceevent/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/Makefile +1 -1
index c76012ebdb9c..bae0c090c638 100644
@@ -173,7 +173,7 @@ $(TE_IN): force
 	$(Q)$(MAKE) $(build)=libtraceevent
 
 $(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN)
-	$(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
+	$(QUIET_LINK)$(CC) --shared $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@ -ldl
 	@ln -sf $(@F) $(OUTPUT)libtraceevent.so
 	@ln -sf $(@F) $(OUTPUT)libtraceevent.so.$(EP_VERSION)
 
Signature · 1 line
2.9.2
#13 lore raw
Quoted 57 lines · On Tue, 2 Aug 2016 11:31:34 +0200 Jiri Olsa <[email protected]> wrote:
Quoted 56 lines · Namhyung Kim
Quoted 37 lines · Jiri Olsa

hi,
sending traceevent changes to make this lib installable under rpm spec.

Basically adding support to:
- install header files
- install version links

Having this patchset applied over the fedora source, I could built following rpms:

kernel-tools-libs
kernel-tools-libs-devel

with added libtraceevent stuff:

  $ rpm -ql kernel-tools-libs
  /usr/lib64/libcpupower.so.0
  /usr/lib64/libcpupower.so.0.0.0
  /usr/lib64/libtraceevent.so.1
  /usr/lib64/libtraceevent.so.1.1.0
  $ rpm -ql kernel-tools-libs-devel
  /usr/include/cpufreq.h
  /usr/include/traceevent
  /usr/include/traceevent/event-parse.h
  /usr/include/traceevent/event-utils.h
  /usr/include/traceevent/kbuffer.h
  /usr/lib64/libcpupower.so
  /usr/lib64/libtraceevent.a
  /usr/lib64/libtraceevent.so

and could build following ex.c outside the kernel tree:

  $ cat ex.c 
  #include <traceevent/event-parse.h>
Quoted 10 lines
  int main(void)
  {
          struct pevent *pevent = pevent_alloc();
          printf("krava %p\n", pevent);
          return 0;
  }
  $ gcc -o ex ex.c -ltraceevent -ldl
  $ ./ex
  krava 0x10c6010
  $  

On my system, building ex.c with libtraceevent failed:

$ gcc -I ~/.local/include/ ex.c -L ~/.local/lib64 -ltraceevent -ldl
/home/namhyung/.local/lib64/libtraceevent.so: undefined reference to `str_error_r'
collect2: error: ld returned 1 exit status
Quoted 5 lines
Quoted 2 lines

Also I think it'd be better for libtraceevent has dependency to libdl explicitly so that we can get rid of -ldl at the end.

agreed, I'll queue your patch if v2 is needed

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Perhaps we should change them to pevent_event and pevent_field?

-- Steve

#14 lore raw

On Tue, Aug 02, 2016 at 09:48:23AM -0400, Steven Rostedt wrote:

SNIP

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Also I think it'd be better for libtraceevent has dependency to libdl explicitly so that we can get rid of -ldl at the end.

Quoted 8 lines
Quoted 2 lines

agreed, I'll queue your patch if v2 is needed

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Perhaps we should change them to pevent_event and pevent_field?

right, it does not have any global prefix for public symbols

I'd actualy expect something like 'traceevent_',
but 'pevent' is ok as well I guess

jirka

#15 lore raw
Quoted 16 lines · Jiri Olsa

On Tue, Aug 02, 2016 at 09:48:23AM -0400, Steven Rostedt wrote:

SNIP

Quoted 12 lines
Quoted 7 lines
Quoted 4 lines

Also I think it'd be better for libtraceevent has dependency to libdl explicitly so that we can get rid of -ldl at the end.

agreed, I'll queue your patch if v2 is needed

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Quoted 6 lines
Quoted 1 line

Perhaps we should change them to pevent_event and pevent_field?

right, it does not have any global prefix for public symbols

I'd actualy expect something like 'traceevent_',
but 'pevent' is ok as well I guess

The 'pevent' prefix would be more consistent to similar APIs IMHO.

Maybe it's worth splitting public header and internal header files?

Thanks,
Namhyung

#16 lore raw

Em Tue, Aug 02, 2016 at 11:14:11PM +0900, Namhyung Kim escreveu:

Quoted 19 lines · Jiri Olsa
Quoted 18 lines · Steven Rostedt

SNIP

Quoted 13 lines
Quoted 7 lines
Quoted 4 lines

Also I think it'd be better for libtraceevent has dependency to libdl explicitly so that we can get rid of -ldl at the end.

agreed, I'll queue your patch if v2 is needed

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Perhaps we should change them to pevent_event and pevent_field?

Quoted 8 lines
Quoted 4 lines

right, it does not have any global prefix for public symbols

I'd actualy expect something like 'traceevent_',
but 'pevent' is ok as well I guess

The 'pevent' prefix would be more consistent to similar APIs IMHO.

Maybe it's worth splitting public header and internal header files?

I'd suggest exporting just what is already used by tools, exposing more as the need arises.

- Arnaldo

#17 lore raw
In reply to Jiri Olsa
Quoted 3 lines · On Tue, 2 Aug 2016 16:01:44 +0200 Jiri Olsa <[email protected]> wrote:

I'd actualy expect something like 'traceevent_',
but 'pevent' is ok as well I guess

Hmm, I like pevent because it is short (less typing ;-), but as this is going to be in libtracevent, I'm wondering if we want to rename it to traceevent_ or maybe tevent? or what about kevent?

-- Steve

#18 lore raw
In reply to Jiri Olsa
Quoted 10 lines · On Tue, 2 Aug 2016 16:01:44 +0200 Jiri Olsa <[email protected]> wrote:
Quoted 5 lines

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Perhaps we should change them to pevent_event and pevent_field?

right, it does not have any global prefix for public symbols

I'd actualy expect something like 'traceevent_',
but 'pevent' is ok as well I guess

OK, what's the consensus here? Should we keep "pevent_" or switch to the longer "traceevent_"?

I want to make the patch that gets this ready to ship!

-- Steve

#19 lore raw

Em Fri, Aug 05, 2016 at 10:13:52AM -0400, Steven Rostedt escreveu:

Quoted 8 lines
Quoted 6 lines · On Tue, 2 Aug 2016 16:01:44 +0200 Jiri Olsa <[email protected]> wrote:
Quoted 5 lines

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Perhaps we should change them to pevent_event and pevent_field?

Quoted 7 lines
Quoted 4 lines

right, it does not have any global prefix for public symbols

I'd actualy expect something like 'traceevent_',
but 'pevent' is ok as well I guess

OK, what's the consensus here? Should we keep "pevent_" or switch to the longer "traceevent_"?

traceevent_ matches libtraceevent, so I think would be more obvious the association of code with the library.

- Arnaldo

Quoted 3 lines

I want to make the patch that gets this ready to ship!

-- Steve

#20 lore raw
Quoted 11 lines · Arnaldo Carvalho de Melo

Em Fri, Aug 05, 2016 at 10:13:52AM -0400, Steven Rostedt escreveu:

Quoted 10 lines
Quoted 8 lines · On Tue, 2 Aug 2016 16:01:44 +0200 Jiri Olsa <[email protected]> wrote:
Quoted 5 lines

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Perhaps we should change them to pevent_event and pevent_field?

right, it does not have any global prefix for public symbols

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'd actualy expect something like 'traceevent_',
but 'pevent' is ok as well I guess

OK, what's the consensus here? Should we keep "pevent_" or switch to the longer "traceevent_"?

traceevent_ matches libtraceevent, so I think would be more obvious the association of code with the library.

+1 for traceevent_ ... makes more sense to me

jirka

#21 lore raw
In reply to Steven Rostedt
Quoted 63 lines · Steven Rostedt
Quoted 60 lines · On Tue, 2 Aug 2016 11:31:34 +0200 Jiri Olsa <[email protected]> wrote:
Quoted 58 lines · Namhyung Kim
Quoted 37 lines · Jiri Olsa

hi,
sending traceevent changes to make this lib installable under rpm spec.

Basically adding support to:
- install header files
- install version links

Having this patchset applied over the fedora source, I could built following rpms:

kernel-tools-libs
kernel-tools-libs-devel

with added libtraceevent stuff:

  $ rpm -ql kernel-tools-libs
  /usr/lib64/libcpupower.so.0
  /usr/lib64/libcpupower.so.0.0.0
  /usr/lib64/libtraceevent.so.1
  /usr/lib64/libtraceevent.so.1.1.0
  $ rpm -ql kernel-tools-libs-devel
  /usr/include/cpufreq.h
  /usr/include/traceevent
  /usr/include/traceevent/event-parse.h
  /usr/include/traceevent/event-utils.h
  /usr/include/traceevent/kbuffer.h
  /usr/lib64/libcpupower.so
  /usr/lib64/libtraceevent.a
  /usr/lib64/libtraceevent.so

and could build following ex.c outside the kernel tree:

  $ cat ex.c 
  #include <traceevent/event-parse.h>
Quoted 10 lines
  int main(void)
  {
          struct pevent *pevent = pevent_alloc();
          printf("krava %p\n", pevent);
          return 0;
  }
  $ gcc -o ex ex.c -ltraceevent -ldl
  $ ./ex
  krava 0x10c6010
  $  

On my system, building ex.c with libtraceevent failed:

$ gcc -I ~/.local/include/ ex.c -L ~/.local/lib64 -ltraceevent -ldl
/home/namhyung/.local/lib64/libtraceevent.so: undefined reference to `str_error_r'
collect2: error: ld returned 1 exit status

Also I think it'd be better for libtraceevent has dependency to libdl explicitly so that we can get rid of -ldl at the end.

Quoted 8 lines
Quoted 2 lines

agreed, I'll queue your patch if v2 is needed

BTW, before we start making this ready for their own libraries, I'd like to make some changes with the naming convention. Mainly with event_format and format_field.

Perhaps we should change them to pevent_event and pevent_field?

hi,
I checked on this one and was surprised last email is from 2016 ;-) so we did not move much with this.. is there still will to do that?

I think we were kind of waiting for the namespace changes in traceevent library.. like to have some common prefix for public functions/struct, like 'traceevent_' ?

thoughts? thanks,
jirka

#22 lore raw
Quoted 9 lines · On Fri, 19 Jan 2018 11:37:13 +0100 Jiri Olsa <[email protected]> wrote:

hi,
I checked on this one and was surprised last email is from 2016 ;-) so we did not move much with this.. is there still will to do that?

I think we were kind of waiting for the namespace changes in traceevent library.. like to have some common prefix for public functions/struct, like 'traceevent_' ?

thoughts? thanks,

Yes, actually this is back on my radar. I now have full time staff working on trace-cmd and kernelshark. One of the up coming changes is to start pushing libtraceevent as a real library which means changing this.

Thus, do we think "traceevent_" is the proper naming? Could we shorten it to "tevent_"? Need to get this bike-shedding exercise out of the way first ;-)

-- Steve

#23 lore raw
Quoted 13 lines · Steven Rostedt
Quoted 9 lines · On Fri, 19 Jan 2018 11:37:13 +0100 Jiri Olsa <[email protected]> wrote:

hi,
I checked on this one and was surprised last email is from 2016 ;-) so we did not move much with this.. is there still will to do that?

I think we were kind of waiting for the namespace changes in traceevent library.. like to have some common prefix for public functions/struct, like 'traceevent_' ?

thoughts? thanks,

Quoted 8 lines

Yes, actually this is back on my radar. I now have full time staff working on trace-cmd and kernelshark. One of the up coming changes is to start pushing libtraceevent as a real library which means changing this.

Thus, do we think "traceevent_" is the proper naming? Could we shorten it to "tevent_"? Need to get this bike-shedding exercise out of the way first ;-)

tevent is ok with me.. one character far from the current one ;-)

jirka

#24 lore raw

Hi Jiri and Steve,

Quoted 19 lines · Jiri Olsa
Quoted 18 lines · Steven Rostedt
Quoted 9 lines · On Fri, 19 Jan 2018 11:37:13 +0100 Jiri Olsa <[email protected]> wrote:

hi,
I checked on this one and was surprised last email is from 2016 ;-) so we did not move much with this.. is there still will to do that?

I think we were kind of waiting for the namespace changes in traceevent library.. like to have some common prefix for public functions/struct, like 'traceevent_' ?

thoughts? thanks,

Yes, actually this is back on my radar. I now have full time staff working on trace-cmd and kernelshark. One of the up coming changes is to start pushing libtraceevent as a real library which means changing this.

Quoted 5 lines
Quoted 3 lines

Thus, do we think "traceevent_" is the proper naming? Could we shorten it to "tevent_"? Need to get this bike-shedding exercise out of the way first ;-)

tevent is ok with me.. one character far from the current one ;-)

I'd suggest 'trev'.

Thanks,
Namhyung