[PATCH v2 2/2] libtraceevent: Have meson build rename hidden global functions
Steven Rostedt <[email protected]> Wed, 12 Nov 2025 09:45:07 -0500
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
From: "Steven Rostedt (Google)" <[email protected]> The meson build needs to perform the same operation as the normal make build with respect to global hidden functions within the static library. Move the redefine_local function to utils.mk and have it take a parameter for what shared library it will read to find the global functions with. Then separate out a target in Makefile.meson for the static library to use this helper function to rename the non "tep_*" global functions to have a "_tep_local_*" prefix. Signed-off-by: Steven Rostedt (Google) <[email protected]> --- Makefile.meson | 15 +++++++++++++-- scripts/utils.mk | 5 +++++ src/Makefile | 7 +------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile.meson b/Makefile.meson index 71d6bf36c654..28c307ff6d9f 100644 --- a/Makefile.meson +++ b/Makefile.meson @@ -16,17 +16,28 @@ endef $(call allow-override,MESON,meson) $(call allow-override,MESON_BUILD_DIR,build) +include $(src)/scripts/utils.mk -all: compile +LIBTRACEEVENT_SHARED_MESON = $(srctree)/build/src/libtraceevent.so +LIBTRACEEVENT_STATIC_MESON = $(srctree)/build/src/libtraceevent.a +TEMP_MESON = $(srctree)/build/src/.tmp.libtraceevent.a + +all: $(LIBTRACEEVENT_STATIC_MESON) $(LIBTRACEEVENT_SHARED_MESON) PHONY += compile compile: $(MESON_BUILD_DIR) force $(MESON) compile -C $(MESON_BUILD_DIR) +$(LIBTRACEEVENT_SHARED_MESON): compile + +$(LIBTRACEEVENT_STATIC_MESON): $(LIBTRACEEVENT_SHARED_MESON) + $(Q)objcopy $(call redefine_local,$(LIBTRACEEVENT_SHARED_MESON)) $(LIBTRACEEVENT_STATIC_MESON) $(TEMP_MESON) + mv $(TEMP_MESON) $(LIBTRACEEVENT_STATIC_MESON) + $(MESON_BUILD_DIR): $(MESON) setup --prefix=$(prefix) $(MESON_BUILD_DIR) -install: compile +install: $(LIBTRACEEVENT_STATIC_MESON) $(MESON) install -C $(MESON_BUILD_DIR) docs: $(MESON_BUILD_DIR) diff --git a/scripts/utils.mk b/scripts/utils.mk index 7139088fbec2..7cd7355b811f 100644 --- a/scripts/utils.mk +++ b/scripts/utils.mk @@ -180,3 +180,8 @@ define do_install_pkgconfig_file (echo Failed to locate pkg-config directory) 1>&2; \ fi endef + +# Make all global functions that do not start with "tep_" have a unique name. +redefine_local = \ + $(shell for f in a `nm $(1) 2>/dev/null | grep ' t ' | cut -d' ' -f3 | sort -u`; do \ + if [ "$${f#tep_}" = "$$f" ]; then echo --redefine-sym $$f=_tep_local_$$f; fi; done) diff --git a/src/Makefile b/src/Makefile index c9e8498c2d05..169bc6af1cbc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,13 +18,8 @@ DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d) $(bdir)/%.o: %.c $(Q)$(call do_fpic_compile) -# Make all global functions that do not start with "tep_" have a unique name. -redefine_local = \ - $(shell for f in a `nm ${LIBTRACEEVENT_SHARED} | grep ' t ' | cut -d' ' -f3 | sort -u`; do \ - if [ "$${f#tep_}" = "$$f" ]; then echo --redefine-sym $$f=_tep_local_$$f; fi; done) - $(LIBTRACEEVENT_STATIC): $(bdir)/.tmp.libtraceevent.a $(LIBTRACEEVENT_SHARED) - $(Q)objcopy $(call redefine_local) $< $@ + $(Q)objcopy $(call redefine_local,${LIBTRACEEVENT_SHARED}) $< $@ $(bdir)/.tmp.libtraceevent.a: $(OBJS) $(Q)$(call do_build_static_lib) -- 2.51.0