Skip to contentSkip to conversation

perf, tools: Support static linking with libdw

PATCH New Andi Kleen 2 participants 2 messages Aug 12, 2015 – Aug 20, 2015 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 perf, tools: Support static linking with libdw

From: Andi Kleen <[email protected]>

The Fedora 22 version of libdw requires a couple of extra libraries to link. With a dynamic link the dependencies are pulled in automatically, but this doesn't work for static linking. Add the needed libraries explicitely to the feature probe and the Makefile.

v2: Explicitly check for static linking and only add the dependencies when -static is set. This is to avoid regressions on Arnaldo's system.

---
 tools/build/feature/Makefile | 7 ++++++-
 tools/perf/config/Makefile   | 6 +++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +6 -1
index 463ed8f..a8a5b7f 100644
@@ -69,8 +69,13 @@ test-libelf.bin:
 test-glibc.bin:
 	$(BUILD)
 
+DWARFLIBS := -ldw
+ifeq ($(findstring -static,${LDFLAGS}),-static)
+DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+endif
+
 test-dwarf.bin:
-	$(BUILD) -ldw
+	$(BUILD) $(DWARFLIBS)
 
 test-libelf-mmap.bin:
 	$(BUILD) -lelf
tools/perf/config/Makefile +5 -1
index 094ddae..e376a45 100644
@@ -297,7 +297,11 @@ ifndef NO_LIBELF
     else
       CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
       LDFLAGS += $(LIBDW_LDFLAGS)
-      EXTLIBS += -ldw
+      DWARFLIBS := -ldw
+      ifeq ($(findstring -static,${LDFLAGS}),-static)
+	DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+      endif
+      EXTLIBS += ${DWARFLIBS}
       $(call detected,CONFIG_DWARF)
     endif # PERF_HAVE_DWARF_REGS
   endif # NO_DWARF
Signature · 1 line
2.4.3
#1 lore raw

[tip:perf/core] perf tools: Support static linking with libdw

perf tools: Support static linking with libdw
Commit-ID:  7aec51cbf0646cc15d719b08caea931576dc7f2a
Gitweb:     http://git.kernel.org/tip/7aec51cbf0646cc15d719b08caea931576dc7f2a
Author:     Andi Kleen <[email protected]>
AuthorDate: Wed, 12 Aug 2015 15:48:37 -0700
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 13 Aug 2015 14:49:11 -0300

perf tools: Support static linking with libdw

The Fedora 22 version of libdw requires a couple of extra libraries to link. With a dynamic link the dependencies are pulled in automatically, but this doesn't work for static linking. Add the needed libraries explicitely to the feature probe and the Makefile.

v2: Explicitly check for static linking and only add the dependencies
when -static is set. This is to avoid regressions on Arnaldo's system.

---
 tools/build/feature/Makefile | 7 ++++++-
 tools/perf/config/Makefile   | 6 +++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +6 -1
index 1c0d69f..74ca420 100644
@@ -70,8 +70,13 @@ test-libelf.bin:
 test-glibc.bin:
 	$(BUILD)
 
+DWARFLIBS := -ldw
+ifeq ($(findstring -static,${LDFLAGS}),-static)
+DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+endif
+
 test-dwarf.bin:
-	$(BUILD) -ldw
+	$(BUILD) $(DWARFLIBS)
 
 test-libelf-mmap.bin:
 	$(BUILD) -lelf
tools/perf/config/Makefile +5 -1
index 823195a..827557f 100644
@@ -297,7 +297,11 @@ ifndef NO_LIBELF
     else
       CFLAGS += -DHAVE_DWARF_SUPPORT $(LIBDW_CFLAGS)
       LDFLAGS += $(LIBDW_LDFLAGS)
-      EXTLIBS += -ldw
+      DWARFLIBS := -ldw
+      ifeq ($(findstring -static,${LDFLAGS}),-static)
+	DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
+      endif
+      EXTLIBS += ${DWARFLIBS}
       $(call detected,CONFIG_DWARF)
     endif # PERF_HAVE_DWARF_REGS
   endif # NO_DWARF