From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by sourceware.org (Postfix) with ESMTP id 8ECB43857C73 for ; Mon, 26 Oct 2020 09:32:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8ECB43857C73 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ldv@altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 9284F72CCE7; Mon, 26 Oct 2020 12:32:35 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 8540A7CF9A6; Mon, 26 Oct 2020 12:32:35 +0300 (MSK) Date: Mon, 26 Oct 2020 12:32:35 +0300 From: "Dmitry V. Levin" To: =?utf-8?B?w4lyaWNv?= Nogueira Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] Support building when fts and obstack aren't part of libc. Message-ID: <20201026093235.GB24026@altlinux.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2020 09:32:41 -0000 On Sun, Oct 25, 2020 at 11:41:12PM -0300, Érico Nogueira via Elfutils-devel wrote: > - Make configure.ac test for fts and obstack availability; > - Add fts and obstack ldflags to all files that need them; > - Add missing argp ldflags to programs in debuginfod/. > > Signed-off-by: Érico Rolim > --- > > This is the start of a series of patches that can enable elfutils to be > built on musl-based distros out of the box. > > I will send them as separate mails, since upstreaming any of the > necessary patches should still help with avoiding duplication across > distros as well as lowering the maintenance burden. > > ChangeLog | 4 ++++ > configure.ac | 54 ++++++++++++++++++++++++++++++++++++++++++ > debuginfod/Makefile.am | 6 ++--- > libdw/Makefile.am | 2 +- > src/Makefile.am | 6 ++--- > 5 files changed, 65 insertions(+), 7 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 72e8397c..10587886 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,7 @@ > +2020-10-25 Érico N. Rolim > + > + * configure.ac: Check for fts and obstack from outside libc. > + > 2020-10-01 Frank Ch. Eigler > > PR25461 > diff --git a/configure.ac b/configure.ac > index 973409f1..628e7a74 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -542,6 +542,60 @@ else > fi > AC_SUBST([argp_LDADD]) > > +dnl Check if we have fts available from our libc > +AC_LINK_IFELSE( > + [AC_LANG_PROGRAM( > + [#if !defined(__x86_64__) > + #undef _FILE_OFFSET_BITS > + #define _FILE_OFFSET_BITS 32 > + #endif > + #include ], > + [FTS* fts = 0; return fts_close(fts); return 0;] > + )], > + [libc_has_fts="true"], > + [libc_has_fts="false"] > +) > + > +dnl If our libc doesn't provide fts, then test for libfts > +if test "$libc_has_fts" = "false" ; then > + AC_MSG_WARN("libc does not have fts") > + AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"]) > + > + if test "$have_fts" = "false"; then > + AC_MSG_ERROR("no libfts found") > + else > + fts_LDADD="-lfts" > + fi > +else > + fts_LDADD="" > +fi > +AC_SUBST([fts_LDADD]) If you are looking for fts providers, I suggest using AC_SEARCH_LIBS instead, e.g. saved_LIBS="$LIBS" AC_SEARCH_LIBS([fts_close], [fts]) LIBS="$saved_LIBS" case "$ac_cv_search_fts_close" in no) AC_MSG_FAILURE([failed to find fts_close]) ;; -l*) fts_LIBS="$ac_cv_search_fts_close" ;; *) fts_LIBS= ;; esac AC_SUBST([fts_LIBS]) > +dnl Check if we have obstack available from our libc > +AC_LINK_IFELSE( > + [AC_LANG_PROGRAM( > + [#include ], > + [_obstack_begin(0, 0, 0, NULL, NULL); return 0;] > + )], > + [libc_has_obstack="true"], > + [libc_has_obstack="false"] > +) > + > +dnl If our libc doesn't provide obstack, then test for libobstack > +if test "$libc_has_obstack" = "false" ; then > + AC_MSG_WARN("libc does not have obstack") > + AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"]) > + > + if test "$have_obstack" = "false"; then > + AC_MSG_ERROR("no libobstack found") > + else > + obstack_LDADD="-lobstack" > + fi > +else > + obstack_LDADD="" > +fi > +AC_SUBST([obstack_LDADD]) Likewise, e.g. saved_LIBS="$LIBS" AC_SEARCH_LIBS([obstack_free], [obstack]) LIBS="$saved_LIBS" case "$ac_cv_search_obstack_free" in no) AC_MSG_FAILURE([failed to find obstack_free]) ;; -l*) obstack_LIBS="$ac_cv_search_obstack_free" ;; *) obstack_LIBS= ;; esac AC_SUBST([obstack_LIBS]) -- ldv