From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7814) id A15E63858D39; Tue, 27 Sep 2022 03:42:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A15E63858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664250160; bh=Na/xVq8gjunJjWMlSLDeYHp5oL2L46+VOo0Ctmk5JMc=; h=From:To:Subject:Date:From; b=bF4w096pxuBmnzPLccBtk2gxMZG5Kr20p3r58t6mUnfSyLldsu64s4xZcKXT4JWSb CFH+oAM55bqglJI/ZtMYf+py8Mqb7NLU2WZIUvaOXvwXexeSzl3dj8T5G0codFtvkF 5ZYb9idzP1d75PUBk6mGkA9H+uVbTJ21Ph8CM5jw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Fangrui Song To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] libctf: Add ZSTD_LIBS to LIBS so that ac_cv_libctf_bfd_elf can be true X-Act-Checkin: binutils-gdb X-Git-Author: Fangrui Song X-Git-Refname: refs/heads/master X-Git-Oldrev: 2cac01e3ffff74898c54fa5e6418817f5578adb6 X-Git-Newrev: 8818c80cbd4116ef5af171ec47c61167179e225c Message-Id: <20220927034240.A15E63858D39@sourceware.org> Date: Tue, 27 Sep 2022 03:42:40 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D8818c80cbd41= 16ef5af171ec47c61167179e225c commit 8818c80cbd4116ef5af171ec47c61167179e225c Author: Fangrui Song Date: Mon Sep 26 20:41:42 2022 -0700 libctf: Add ZSTD_LIBS to LIBS so that ac_cv_libctf_bfd_elf can be true Diff: --- libctf/Makefile.in | 9 +- libctf/aclocal.m4 | 2 + libctf/config.h.in | 3 + libctf/configure | 269 ++++++++++++++++++++++++++++++++++++++++++++++++= +++- libctf/configure.ac | 3 +- 5 files changed, 280 insertions(+), 6 deletions(-) diff --git a/libctf/Makefile.in b/libctf/Makefile.in index 1984f50867a..036a63fa720 100644 --- a/libctf/Makefile.in +++ b/libctf/Makefile.in @@ -141,8 +141,10 @@ am__aclocal_m4_deps =3D $(top_srcdir)/../bfd/acinclude= .m4 \ $(top_srcdir)/../config/jobserver.m4 \ $(top_srcdir)/../config/lead-dot.m4 \ $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../config/pkg.m4 \ $(top_srcdir)/../config/warnings.m4 \ - $(top_srcdir)/../config/zlib.m4 $(top_srcdir)/../libtool.m4 \ + $(top_srcdir)/../config/zlib.m4 \ + $(top_srcdir)/../config/zstd.m4 $(top_srcdir)/../libtool.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/configure.ac @@ -441,6 +443,9 @@ PACKAGE_TARNAME =3D @PACKAGE_TARNAME@ PACKAGE_URL =3D @PACKAGE_URL@ PACKAGE_VERSION =3D @PACKAGE_VERSION@ PATH_SEPARATOR =3D @PATH_SEPARATOR@ +PKG_CONFIG =3D @PKG_CONFIG@ +PKG_CONFIG_LIBDIR =3D @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH =3D @PKG_CONFIG_PATH@ POSUB =3D @POSUB@ RANLIB =3D @RANLIB@ SED =3D @SED@ @@ -455,6 +460,8 @@ VERSION_FLAGS_NOBFD =3D @VERSION_FLAGS_NOBFD@ WARN_PEDANTIC =3D @WARN_PEDANTIC@ WERROR =3D @WERROR@ XGETTEXT =3D @XGETTEXT@ +ZSTD_CFLAGS =3D @ZSTD_CFLAGS@ +ZSTD_LIBS =3D @ZSTD_LIBS@ abs_builddir =3D @abs_builddir@ abs_srcdir =3D @abs_srcdir@ abs_top_builddir =3D @abs_top_builddir@ diff --git a/libctf/aclocal.m4 b/libctf/aclocal.m4 index 4607d728564..96b27970c9f 100644 --- a/libctf/aclocal.m4 +++ b/libctf/aclocal.m4 @@ -1235,8 +1235,10 @@ m4_include([../config/gettext-sister.m4]) m4_include([../config/jobserver.m4]) m4_include([../config/lead-dot.m4]) m4_include([../config/override.m4]) +m4_include([../config/pkg.m4]) m4_include([../config/warnings.m4]) m4_include([../config/zlib.m4]) +m4_include([../config/zstd.m4]) m4_include([../libtool.m4]) m4_include([../ltoptions.m4]) m4_include([../ltsugar.m4]) diff --git a/libctf/config.h.in b/libctf/config.h.in index 5db637c7903..ef122aea3f2 100644 --- a/libctf/config.h.in +++ b/libctf/config.h.in @@ -97,6 +97,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H =20 +/* Define to 1 if zstd is enabled. */ +#undef HAVE_ZSTD + /* Define to the sub-directory in which libtool stores uninstalled librari= es. */ #undef LT_OBJDIR diff --git a/libctf/configure b/libctf/configure index 8704bc215f4..176b3d6b918 100755 --- a/libctf/configure +++ b/libctf/configure @@ -648,6 +648,11 @@ NEED_CTF_QSORT_R_FALSE NEED_CTF_QSORT_R_TRUE ENABLE_LIBCTF_HASH_DEBUGGING_FALSE ENABLE_LIBCTF_HASH_DEBUGGING_TRUE +ZSTD_LIBS +ZSTD_CFLAGS +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG zlibinc zlibdir ac_libctf_warn_cflags @@ -806,6 +811,7 @@ enable_werror_always enable_maintainer_mode enable_install_libbfd with_system_zlib +with_zstd enable_libctf_hash_debugging ' ac_precious_vars=3D'build_alias @@ -816,7 +822,12 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP' +CPP +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR +ZSTD_CFLAGS +ZSTD_LIBS' =20 =20 # Initialize some variables set by options. @@ -1464,6 +1475,8 @@ Optional Packages: both] --with-gnu-ld assume the C compiler uses GNU ld [default=3Dno] --with-system-zlib use installed libz + --with-zstd support zstd compressed debug sections + (default=3Dauto) =20 Some influential environment variables: CC C compiler command @@ -1474,6 +1487,13 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor + PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path + ZSTD_CFLAGS C compiler flags for ZSTD, overriding pkg-config + ZSTD_LIBS linker flags for ZSTD, overriding pkg-config =20 Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -11635,7 +11655,7 @@ else lt_dlunknown=3D0; lt_dlno_uscore=3D1; lt_dlneed_uscore=3D2 lt_status=3D$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11638 "configure" +#line 11658 "configure" #include "confdefs.h" =20 #if HAVE_DLFCN_H @@ -11741,7 +11761,7 @@ else lt_dlunknown=3D0; lt_dlno_uscore=3D1; lt_dlneed_uscore=3D2 lt_status=3D$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11744 "configure" +#line 11764 "configure" #include "confdefs.h" =20 #if HAVE_DLFCN_H @@ -12921,6 +12941,247 @@ fi =20 =20 =20 + + + + + + +if test "x$ac_cv_env_PKG_CONFIG_set" !=3D "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be = a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=3D$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG=3D"$PKG_CONFIG" # Let the user override the test w= ith a path. + ;; + *) + as_save_IFS=3D$IFS; IFS=3D$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=3D$as_save_IFS + test -z "$as_dir" && as_dir=3D. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG=3D"$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_= ext" >&5 + break 2 + fi +done + done +IFS=3D$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=3D$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=3D$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name wi= th args. +set dummy pkg-config; ac_word=3D$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG=3D"$ac_pt_PKG_CONFIG" # Let the user overrid= e the test with a path. + ;; + *) + as_save_IFS=3D$IFS; IFS=3D$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=3D$as_save_IFS + test -z "$as_dir" && as_dir=3D. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG=3D"$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_= ext" >&5 + break 2 + fi +done + done +IFS=3D$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=3D$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" =3D x; then + PKG_CONFIG=3D"" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not pr= efixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triple= t" >&2;} +ac_tool_warned=3Dyes ;; +esac + PKG_CONFIG=3D$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG=3D"$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=3D0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least = version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... "= >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG=3D"" + fi +fi + + +# Check whether --with-zstd was given. +if test "${with_zstd+set}" =3D set; then : + withval=3D$with_zstd; +else + with_zstd=3Dauto +fi + + +if test "$with_zstd" !=3D no; then : + +pkg_failed=3Dno +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd" >&5 +$as_echo_n "checking for libzstd... " >&6; } + +if test -n "$ZSTD_CFLAGS"; then + pkg_cv_ZSTD_CFLAGS=3D"$ZSTD_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --pri= nt-errors \"libzstd\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5 + ac_status=3D$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? =3D $ac_status" >&5 + test $ac_status =3D 0; }; then + pkg_cv_ZSTD_CFLAGS=3D`$PKG_CONFIG --cflags "libzstd" 2>/dev/null` + test "x$?" !=3D "x0" && pkg_failed=3Dyes +else + pkg_failed=3Dyes +fi + else + pkg_failed=3Duntried +fi +if test -n "$ZSTD_LIBS"; then + pkg_cv_ZSTD_LIBS=3D"$ZSTD_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --pri= nt-errors \"libzstd\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5 + ac_status=3D$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? =3D $ac_status" >&5 + test $ac_status =3D 0; }; then + pkg_cv_ZSTD_LIBS=3D`$PKG_CONFIG --libs "libzstd" 2>/dev/null` + test "x$?" !=3D "x0" && pkg_failed=3Dyes +else + pkg_failed=3Dyes +fi + else + pkg_failed=3Duntried +fi + +if test $pkg_failed =3D no; then + pkg_save_LDFLAGS=3D"$LDFLAGS" + LDFLAGS=3D"$LDFLAGS $pkg_cv_ZSTD_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + pkg_failed=3Dyes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=3D$pkg_save_LDFLAGS +fi + + + +if test $pkg_failed =3D yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=3Dyes +else + _pkg_short_errors_supported=3Dno +fi + if test $_pkg_short_errors_supported =3D yes; then + ZSTD_PKG_ERRORS=3D`$PKG_CONFIG --short-errors --print-errors --cf= lags --libs "libzstd" 2>&1` + else + ZSTD_PKG_ERRORS=3D`$PKG_CONFIG --print-errors --cflags --libs "li= bzstd" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$ZSTD_PKG_ERRORS" >&5 + + + if test "$with_zstd" =3D yes; then + as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is n= ot found" "$LINENO" 5 + fi + +elif test $pkg_failed =3D untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + if test "$with_zstd" =3D yes; then + as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is n= ot found" "$LINENO" 5 + fi + +else + ZSTD_CFLAGS=3D$pkg_cv_ZSTD_CFLAGS + ZSTD_LIBS=3D$pkg_cv_ZSTD_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + +$as_echo "#define HAVE_ZSTD 1" >>confdefs.h + + +fi + +fi + + # Check whether --enable-libctf-hash-debugging was given. if test "${enable_libctf_hash_debugging+set}" =3D set; then : enableval=3D$enable_libctf_hash_debugging; @@ -12959,7 +13220,7 @@ CFLAGS=3D"-I${srcdir}/../include -I../bfd -I${srcdi= r}/../bfd $CFLAGS" ZLIBDIR=3D`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" intl=3D`echo $LIBINTL | sed 's,${top_builddir}/,,g'` -LIBS=3D"-lbfd -liberty -lz $intl $LIBS" +LIBS=3D"-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" = >&5 $as_echo_n "checking for ELF support in BFD... " >&6; } if ${ac_cv_libctf_bfd_elf+:} false; then : diff --git a/libctf/configure.ac b/libctf/configure.ac index 4996edd5b70..2e2ccf4b624 100644 --- a/libctf/configure.ac +++ b/libctf/configure.ac @@ -71,6 +71,7 @@ AC_FUNC_MMAP # Needed for BFD capability checks. AC_SEARCH_LIBS(dlsym, dl) AM_ZLIB +AC_ZSTD =20 GCC_ENABLE([libctf-hash-debugging], [no], [], [Enable expensive debugging = of CTF deduplication type hashing]) if test "${enable_libctf_hash_debugging}" =3D yes; then @@ -89,7 +90,7 @@ CFLAGS=3D"-I${srcdir}/../include -I../bfd -I${srcdir}/../= bfd $CFLAGS" ZLIBDIR=3D`echo $zlibdir | sed 's,\$(top_builddir)/,,g'` LDFLAGS=3D"-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS" intl=3D`echo $LIBINTL | sed 's,${top_builddir}/,,g'` -LIBS=3D"-lbfd -liberty -lz $intl $LIBS" +LIBS=3D"-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS" AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf, [AC_TRY_LINK([#include #include