blob: f751a2ecdbec6694b75ca9bf57506c0f6dcc7e7a [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From 8ccf3d92b8766b53f203df7e01b489604ef851f3 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Fri, 23 Aug 2019 10:17:25 +0800
4Subject: [PATCH 1/4] musl-obstack-fts
5
6Look for libfts and libobstack during configure, these
7libraries are external to libc when using musl, whereas
8on glibc these libraries are provided in libc itself.
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11Upstream-Status: Inappropriate [workaround for musl]
12
13Rebase to 0.177
14Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
15
16---
17 configure.ac | 54 +++++++++++++++++++++++++++++++++++++++++++++++
18 libdw/Makefile.am | 2 +-
19 src/Makefile.am | 6 +++---
20 3 files changed, 58 insertions(+), 4 deletions(-)
21
22diff --git a/configure.ac b/configure.ac
23index cad7b2b..6d4229b 100644
24--- a/configure.ac
25+++ b/configure.ac
26@@ -529,6 +529,60 @@ else
27 fi
28 AC_SUBST([argp_LDADD])
29
30+dnl Check if we have fts available from our libc
31+AC_LINK_IFELSE(
32+ [AC_LANG_PROGRAM(
33+ [#if !defined(__x86_64__)
34+ #undef _FILE_OFFSET_BITS
35+ #define _FILE_OFFSET_BITS 32
36+ #endif
37+ #include <fts.h>],
38+ [FTS* fts = 0; return fts_close(fts); return 0;]
39+ )],
40+ [libc_has_fts="true"],
41+ [libc_has_fts="false"]
42+)
43+
44+dnl If our libc doesn't provide fts, then test for libfts
45+if test "$libc_has_fts" = "false" ; then
46+ AC_MSG_WARN("libc does not have fts")
47+ AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"])
48+
49+ if test "$have_fts" = "false"; then
50+ AC_MSG_ERROR("no libfts found")
51+ else
52+ fts_LDADD="-lfts"
53+ fi
54+else
55+ fts_LDADD=""
56+fi
57+AC_SUBST([fts_LDADD])
58+
59+dnl Check if we have obstack available from our libc
60+AC_LINK_IFELSE(
61+ [AC_LANG_PROGRAM(
62+ [#include <obstack.h>],
63+ [_obstack_begin(0, 0, 0, NULL, NULL); return 0;]
64+ )],
65+ [libc_has_obstack="true"],
66+ [libc_has_obstack="false"]
67+)
68+
69+dnl If our libc doesn't provide obstack, then test for libobstack
70+if test "$libc_has_obstack" = "false" ; then
71+ AC_MSG_WARN("libc does not have obstack")
72+ AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"])
73+
74+ if test "$have_obstack" = "false"; then
75+ AC_MSG_ERROR("no libobstack found")
76+ else
77+ obstack_LDADD="-lobstack"
78+ fi
79+else
80+ obstack_LDADD=""
81+fi
82+AC_SUBST([obstack_LDADD])
83+
84 dnl The directories with content.
85
86 dnl Documentation.
87diff --git a/libdw/Makefile.am b/libdw/Makefile.am
88index 33b5838..ff92e02 100644
89--- a/libdw/Makefile.am
90+++ b/libdw/Makefile.am
91@@ -109,7 +109,7 @@ libdw_so_LIBS = ../libebl/libebl_pic.a ../backends/libebl_backends_pic.a \
92 ../libcpu/libcpu_pic.a libdw_pic.a ../libdwelf/libdwelf_pic.a \
93 ../libdwfl/libdwfl_pic.a
94 libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
95-libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) -pthread
96+libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(zip_LIBS) -pthread
97 libdw_so_SOURCES =
98 libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS)
99 $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \
100diff --git a/src/Makefile.am b/src/Makefile.am
101index 13d9bda..d5a4f7d 100644
102--- a/src/Makefile.am
103+++ b/src/Makefile.am
104@@ -69,7 +69,7 @@ ar_no_Wstack_usage = yes
105 unstrip_no_Wstack_usage = yes
106
107 readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD)
108-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \
109+nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD) \
110 $(demanglelib)
111 size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
112 strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
113@@ -78,9 +78,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
114 addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
115 elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
116 objdump_LDADD = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD)
117-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
118+ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
119 strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
120-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
121+ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD)
122 unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
123 stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
124 elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
125--
1262.17.1
127