Blame SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Makefile-Fix-build-errors-in-static-build.patch

f8bec6
From 12250baa02584dc713cdb1a12fb366f643fdc8b3 Mon Sep 17 00:00:00 2001
f8bec6
From: Kazuhito Hagio <k-hagio-ab@nec.com>
f8bec6
Date: Mon, 9 Mar 2020 17:17:31 -0400
f8bec6
Subject: [PATCH 5/7] [PATCH] Makefile: Fix build errors in static build
f8bec6
f8bec6
When building makedumpfile statically (without LINKTYPE=dynamic),
f8bec6
the following error is observed:
f8bec6
f8bec6
  /usr/bin/ld: /usr/lib/makedumpfile-1.6.7/gcc/x86_64-redhat-linux/9/../../../../lib64/libdw.a(lzma.o): in function `__libdw_unlzma':
f8bec6
  (.text+0xbd): undefined reference to `lzma_auto_decoder'
f8bec6
  /usr/bin/ld: (.text+0x23a): undefined reference to `lzma_code'
f8bec6
  /usr/bin/ld: (.text+0x269): undefined reference to `lzma_end'
f8bec6
  /usr/bin/ld: (.text+0x2aa): undefined reference to `lzma_end'
f8bec6
  /usr/bin/ld: (.text+0x3ac): undefined reference to `lzma_end'
f8bec6
  /usr/bin/ld: (.text+0x427): undefined reference to `lzma_end'
f8bec6
  /usr/bin/ld: (.text+0x62b): undefined reference to `lzma_end'
f8bec6
  collect2: error: ld returned 1 exit status
f8bec6
  make: *** [Makefile:97: makedumpfile] Error 1
f8bec6
f8bec6
Also, when doing it with USESNAPPY=on:
f8bec6
f8bec6
  /usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::WorkingMemory(unsigned long)':
f8bec6
  snappy.cc:(.text+0x7d4): undefined reference to `std::allocator<char>::allocator()'
f8bec6
  /usr/bin/ld: snappy.cc:(.text+0x803): undefined reference to `std::allocator<char>::~allocator()'
f8bec6
  /usr/bin/ld: snappy.cc:(.text+0x853): undefined reference to `std::allocator<char>::~allocator()'
f8bec6
  /usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::~WorkingMemory()':
f8bec6
  snappy.cc:(.text+0x87e): undefined reference to `std::allocator<char>::allocator()'
f8bec6
  /usr/bin/ld: snappy.cc:(.text+0x8a8): undefined reference to `std::allocator<char>::~allocator()'
f8bec6
  ...
f8bec6
f8bec6
Fix these errors by adding -llzma and -lstd++ to LIBS respectively
f8bec6
if LINKTYPE=dynamic is not specified.
f8bec6
f8bec6
Reported-by: Prabhakar Kushwaha <prabhakar.pkin@gmail.com>
f8bec6
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
f8bec6
---
f8bec6
 Makefile | 5 ++++-
f8bec6
 1 file changed, 4 insertions(+), 1 deletion(-)
f8bec6
f8bec6
diff --git a/makedumpfile-1.6.7/Makefile b/makedumpfile-1.6.7/Makefile
f8bec6
index 868eea6..ef20672 100644
f8bec6
--- a/makedumpfile-1.6.7/Makefile
f8bec6
+++ b/makedumpfile-1.6.7/Makefile
f8bec6
@@ -52,7 +52,7 @@ OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
f8bec6
 
f8bec6
 LIBS = -ldw -lbz2 -ldl -lelf -lz
f8bec6
 ifneq ($(LINKTYPE), dynamic)
f8bec6
-LIBS := -static $(LIBS)
f8bec6
+LIBS := -static $(LIBS) -llzma
f8bec6
 endif
f8bec6
 
f8bec6
 ifeq ($(USELZO), on)
f8bec6
@@ -62,6 +62,9 @@ endif
f8bec6
 
f8bec6
 ifeq ($(USESNAPPY), on)
f8bec6
 LIBS := -lsnappy $(LIBS)
f8bec6
+ifneq ($(LINKTYPE), dynamic)
f8bec6
+LIBS := $(LIBS) -lstdc++
f8bec6
+endif
f8bec6
 CFLAGS += -DUSESNAPPY
f8bec6
 endif
f8bec6
 
f8bec6
-- 
f8bec6
2.7.5
f8bec6