Blob Blame History Raw
From 12250baa02584dc713cdb1a12fb366f643fdc8b3 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio-ab@nec.com>
Date: Mon, 9 Mar 2020 17:17:31 -0400
Subject: [PATCH 5/7] [PATCH] Makefile: Fix build errors in static build

When building makedumpfile statically (without LINKTYPE=dynamic),
the following error is observed:

  /usr/bin/ld: /usr/lib/makedumpfile-1.6.7/gcc/x86_64-redhat-linux/9/../../../../lib64/libdw.a(lzma.o): in function `__libdw_unlzma':
  (.text+0xbd): undefined reference to `lzma_auto_decoder'
  /usr/bin/ld: (.text+0x23a): undefined reference to `lzma_code'
  /usr/bin/ld: (.text+0x269): undefined reference to `lzma_end'
  /usr/bin/ld: (.text+0x2aa): undefined reference to `lzma_end'
  /usr/bin/ld: (.text+0x3ac): undefined reference to `lzma_end'
  /usr/bin/ld: (.text+0x427): undefined reference to `lzma_end'
  /usr/bin/ld: (.text+0x62b): undefined reference to `lzma_end'
  collect2: error: ld returned 1 exit status
  make: *** [Makefile:97: makedumpfile] Error 1

Also, when doing it with USESNAPPY=on:

  /usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::WorkingMemory(unsigned long)':
  snappy.cc:(.text+0x7d4): undefined reference to `std::allocator<char>::allocator()'
  /usr/bin/ld: snappy.cc:(.text+0x803): undefined reference to `std::allocator<char>::~allocator()'
  /usr/bin/ld: snappy.cc:(.text+0x853): undefined reference to `std::allocator<char>::~allocator()'
  /usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::~WorkingMemory()':
  snappy.cc:(.text+0x87e): undefined reference to `std::allocator<char>::allocator()'
  /usr/bin/ld: snappy.cc:(.text+0x8a8): undefined reference to `std::allocator<char>::~allocator()'
  ...

Fix these errors by adding -llzma and -lstd++ to LIBS respectively
if LINKTYPE=dynamic is not specified.

Reported-by: Prabhakar Kushwaha <prabhakar.pkin@gmail.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
---
 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/makedumpfile-1.6.7/Makefile b/makedumpfile-1.6.7/Makefile
index 868eea6..ef20672 100644
--- a/makedumpfile-1.6.7/Makefile
+++ b/makedumpfile-1.6.7/Makefile
@@ -52,7 +52,7 @@ OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
 
 LIBS = -ldw -lbz2 -ldl -lelf -lz
 ifneq ($(LINKTYPE), dynamic)
-LIBS := -static $(LIBS)
+LIBS := -static $(LIBS) -llzma
 endif
 
 ifeq ($(USELZO), on)
@@ -62,6 +62,9 @@ endif
 
 ifeq ($(USESNAPPY), on)
 LIBS := -lsnappy $(LIBS)
+ifneq ($(LINKTYPE), dynamic)
+LIBS := $(LIBS) -lstdc++
+endif
 CFLAGS += -DUSESNAPPY
 endif
 
-- 
2.7.5