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

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