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