All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] trace-cruncher: Build trace-obj-debug.c as library
@ 2022-05-02 10:06 Yordan Karadzhov (VMware)
  2022-05-03  4:16 ` Tzvetomir Stoyanov
  0 siblings, 1 reply; 2+ messages in thread
From: Yordan Karadzhov (VMware) @ 2022-05-02 10:06 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: tz.stoyanov, Yordan Karadzhov (VMware)

The code for resolving virtual address to function name gets build
as shared library. The library is installed as package data. Later
this library can be used by the different sub-modules of tracecruncher.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---

This patch applies on top of the patch:
https://lore.kernel.org/all/20220420080206.252356-2-tz.stoyanov@gmail.com/

Changes in v2:
 - Fixing the problem of '$ORIGIN' not being properly added to
   the 'RUNPATH' of the shared libraries, built by the sub-modules. 

Changes in v3:
 - The name of the library changet to 'libtcrunchbase.so'. Some Makefile
   variables are changed accordingly.

 Makefile | 24 +++++++++++++++++++++---
 setup.py |  4 ++--
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 52428c0..d359ea6 100644
--- a/Makefile
+++ b/Makefile
@@ -13,13 +13,31 @@ NC	:= '\e[0m'
 
 DOCDIR = ./docs
 
-all:
+CC = gcc
+CFLAGS = -fPIC -Wall -Wextra -O2 -g
+LDFLAGS = -shared -lbfd
+RM = rm -rf
+
+TC_BASE_LIB = tracecruncher/libtcrunchbase.so
+PY_SETUP = setup
+
+BASE_SRCS = src/trace-obj-debug.c
+BASE_OBJS = $(BASE_SRCS:.c=.o)
+
+all: $(TC_BASE_LIB) $(PY_SETUP)
 	@ echo ${CYAN}Buildinging trace-cruncher:${NC};
+
+$(PY_SETUP):
 	python3 setup.py build
 
+$(TC_BASE_LIB): $(BASE_OBJS)
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
+
 clean:
-	rm -f src/npdatawrapper.c
-	rm -rf build
+	${RM} src/npdatawrapper.c
+	${RM} $(TC_BASE_LIB)
+	${RM} src/*.o
+	${RM} build
 
 install:
 	@ echo ${CYAN}Installing trace-cruncher:${NC};
diff --git a/setup.py b/setup.py
index 58561cf..aca634c 100644
--- a/setup.py
+++ b/setup.py
@@ -37,7 +37,7 @@ def add_library(lib, min_version,
         libs_found.extend([(lib, lib_version)])
 
 def third_party_paths():
-    library_dirs = []
+    library_dirs = ['$ORIGIN','tracecruncher']
     include_dirs = [np.get_include()]
     libs_required = [('libtraceevent', '1.5.0'),
                      ('libtracefs',    '1.3.0'),
@@ -61,7 +61,6 @@ include_dirs, library_dirs = third_party_paths()
 
 def extension(name, sources, libraries):
     runtime_library_dirs = library_dirs
-    runtime_library_dirs.extend('$ORIGIN')
     return Extension(name, sources=sources,
                            include_dirs=include_dirs,
                            library_dirs=library_dirs,
@@ -91,6 +90,7 @@ def main():
           url='https://github.com/vmware/trace-cruncher',
           license='LGPL-2.1',
           packages=find_packages(),
+          package_data={'tracecruncher': ['*.so']},
           ext_modules=[module_ft, module_data, module_ks],
           classifiers=[
               'Development Status :: 4 - Beta',
-- 
2.32.0


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

* Re: [PATCH v3] trace-cruncher: Build trace-obj-debug.c as library
  2022-05-02 10:06 [PATCH v3] trace-cruncher: Build trace-obj-debug.c as library Yordan Karadzhov (VMware)
@ 2022-05-03  4:16 ` Tzvetomir Stoyanov
  0 siblings, 0 replies; 2+ messages in thread
From: Tzvetomir Stoyanov @ 2022-05-03  4:16 UTC (permalink / raw)
  To: Yordan Karadzhov (VMware); +Cc: Linux Trace Devel

On Mon, May 2, 2022 at 1:06 PM Yordan Karadzhov (VMware)
<y.karadz@gmail.com> wrote:
>
> The code for resolving virtual address to function name gets build
> as shared library. The library is installed as package data. Later
> this library can be used by the different sub-modules of tracecruncher.
>
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> ---
>
> This patch applies on top of the patch:
> https://lore.kernel.org/all/20220420080206.252356-2-tz.stoyanov@gmail.com/
>
> Changes in v2:
>  - Fixing the problem of '$ORIGIN' not being properly added to
>    the 'RUNPATH' of the shared libraries, built by the sub-modules.
>
> Changes in v3:
>  - The name of the library changet to 'libtcrunchbase.so'. Some Makefile
>    variables are changed accordingly.
>
>  Makefile | 24 +++++++++++++++++++++---
>  setup.py |  4 ++--
>  2 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 52428c0..d359ea6 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -13,13 +13,31 @@ NC  := '\e[0m'
>
>  DOCDIR = ./docs
>
> -all:
> +CC = gcc
> +CFLAGS = -fPIC -Wall -Wextra -O2 -g
> +LDFLAGS = -shared -lbfd
> +RM = rm -rf
> +
> +TC_BASE_LIB = tracecruncher/libtcrunchbase.so
> +PY_SETUP = setup
> +
> +BASE_SRCS = src/trace-obj-debug.c
> +BASE_OBJS = $(BASE_SRCS:.c=.o)
> +
> +all: $(TC_BASE_LIB) $(PY_SETUP)
>         @ echo ${CYAN}Buildinging trace-cruncher:${NC};
> +
> +$(PY_SETUP):
>         python3 setup.py build
>
> +$(TC_BASE_LIB): $(BASE_OBJS)
> +       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
> +
>  clean:
> -       rm -f src/npdatawrapper.c
> -       rm -rf build
> +       ${RM} src/npdatawrapper.c
> +       ${RM} $(TC_BASE_LIB)
> +       ${RM} src/*.o
> +       ${RM} build
>
>  install:
>         @ echo ${CYAN}Installing trace-cruncher:${NC};
> diff --git a/setup.py b/setup.py
> index 58561cf..aca634c 100644
> --- a/setup.py
> +++ b/setup.py
> @@ -37,7 +37,7 @@ def add_library(lib, min_version,
>          libs_found.extend([(lib, lib_version)])
>
>  def third_party_paths():
> -    library_dirs = []
> +    library_dirs = ['$ORIGIN','tracecruncher']
>      include_dirs = [np.get_include()]
>      libs_required = [('libtraceevent', '1.5.0'),
>                       ('libtracefs',    '1.3.0'),
> @@ -61,7 +61,6 @@ include_dirs, library_dirs = third_party_paths()
>
>  def extension(name, sources, libraries):
>      runtime_library_dirs = library_dirs
> -    runtime_library_dirs.extend('$ORIGIN')
>      return Extension(name, sources=sources,
>                             include_dirs=include_dirs,
>                             library_dirs=library_dirs,
> @@ -91,6 +90,7 @@ def main():
>            url='https://github.com/vmware/trace-cruncher',
>            license='LGPL-2.1',
>            packages=find_packages(),
> +          package_data={'tracecruncher': ['*.so']},
>            ext_modules=[module_ft, module_data, module_ks],
>            classifiers=[
>                'Development Status :: 4 - Beta',
> --
> 2.32.0
>

Applied,
Thanks Yordan!


-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

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

end of thread, other threads:[~2022-05-03  4:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 10:06 [PATCH v3] trace-cruncher: Build trace-obj-debug.c as library Yordan Karadzhov (VMware)
2022-05-03  4:16 ` Tzvetomir Stoyanov

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.