Skip to contentSkip to conversation

libtraceevent: Add -ldl to the libtraceevent.so

PATCH New Steven Rostedt 1 participant 1 message Dec 3, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtraceevent: Add -ldl to the libtraceevent.so

From: "Steven Rostedt (VMware)" <[email protected]>

libtraceevent.so does some dlopen() and other dynamic linking features that requires the libdl library. There's no reason that users of libtraceevent.so need to include -ldl if the application itself is not doing dynamic linking.

Have the build include -ldl into libtraceevent.so, such that it's in the binary for the user to use.

---
 Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Makefile +4 -2
index 318ec55..ea00085 100644
@@ -107,6 +107,8 @@ else
   CFLAGS := -g -Wall
 endif
 
+LIBS = -ldl
+
 # Append required CFLAGS
 override CFLAGS += -fPIC
 override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
@@ -141,7 +143,7 @@ $(TE_IN): force
 	$(Q)$(MAKE) $(build)=libtraceevent
 
 $(OUTPUT)libtraceevent.so.$(EVENT_PARSE_VERSION): $(TE_IN)
-	$(QUIET_LINK)$(CC) --shared $(LDFLAGS) $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@
+	$(QUIET_LINK)$(CC) --shared $(LDFLAGS) $^ -Wl,-soname,libtraceevent.so.$(EP_VERSION) -o $@  $(LIBS)
 
 $(OUTPUT)libtraceevent.so: $(OUTPUT)libtraceevent.so.$(EP_VERSION)
 	@ln -sf $(<F) $@
@@ -153,7 +155,7 @@ $(OUTPUT)libtraceevent.a: $(TE_IN)
 	$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
 
 $(OUTPUT)%.so: $(OUTPUT)%-in.o
-	$(QUIET_LINK)$(CC) $(CFLAGS) -shared $(LDFLAGS) -nostartfiles -o $@ $^
+	$(QUIET_LINK)$(CC) $(CFLAGS) -shared $(LDFLAGS) -nostartfiles -o $@ $^ $(LIBS)
 
 define make_version.h
   (echo '/* This file is automatically generated. Do not modify. */';		\
Signature · 1 line
2.25.4