From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7814) id 1BC743858C52; Tue, 27 Sep 2022 18:43:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BC743858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664304190; bh=pLMGRK0tfFDig6LinJ76Yo4V6dcso1TTh7vwZ17G9OQ=; h=From:To:Subject:Date:From; b=mEGZzvu5M6iKAfmSDBzK+gjSxQAxDZIQKDP1mRV6N7JwHYaQxttjtDNKGfPTksKs3 RPlAMvIr3ZRX8Pry4wmqVZiG4x2ASAqTQsuCzy0WpY7i/8FdrGVYWr6EJXUQ/NbLqZ S0ICYulEpPL59G08DR5BTmaRygvV4KrdyavVJA6Y= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Fangrui Song To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: Link ZSTD_LIBS X-Act-Checkin: binutils-gdb X-Git-Author: Fangrui Song X-Git-Refname: refs/heads/master X-Git-Oldrev: f7aa1a5acc5faa03ed6c640a426ef70a5f328940 X-Git-Newrev: 382fa97ce0eb1119266607e2802fd29318ed2d78 Message-Id: <20220927184310.1BC743858C52@sourceware.org> Date: Tue, 27 Sep 2022 18:43:10 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D382fa97ce0eb= 1119266607e2802fd29318ed2d78 commit 382fa97ce0eb1119266607e2802fd29318ed2d78 Author: Fangrui Song Date: Tue Sep 27 11:42:32 2022 -0700 sim: Link ZSTD_LIBS =20 This fixes linker errors in a `../../configure --enable-targets --enable-sim; make all-gdb` build. Diff: --- sim/Makefile.in | 5 +- sim/aclocal.m4 | 1 + sim/arch-subdir.mk.in | 1 + sim/common/Make-common.in | 2 +- sim/config.h.in | 3 ++ sim/configure | 134 ++++++++++++++++++++++++++++++++++++++++++= +++- sim/m4/sim_ac_platform.m4 | 1 + sim/ppc/Makefile.in | 2 +- 8 files changed, 144 insertions(+), 5 deletions(-) diff --git a/sim/Makefile.in b/sim/Makefile.in index dbbaa84224a..3278febc5e8 100644 --- a/sim/Makefile.in +++ b/sim/Makefile.in @@ -170,7 +170,8 @@ am__aclocal_m4_deps =3D $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../config/pkg.m4 \ $(top_srcdir)/../config/plugins.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)/m4/sim_ac_option_alignment.m4 \ @@ -855,6 +856,8 @@ VERSION =3D @VERSION@ WARN_CFLAGS =3D @WARN_CFLAGS@ WERROR_CFLAGS =3D @WERROR_CFLAGS@ 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/sim/aclocal.m4 b/sim/aclocal.m4 index 40806b929bf..5ecf08aa3e9 100644 --- a/sim/aclocal.m4 +++ b/sim/aclocal.m4 @@ -1175,6 +1175,7 @@ m4_include([../config/override.m4]) m4_include([../config/pkg.m4]) m4_include([../config/plugins.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/sim/arch-subdir.mk.in b/sim/arch-subdir.mk.in index c9ba0d53f35..f6d8188d1a8 100644 --- a/sim/arch-subdir.mk.in +++ b/sim/arch-subdir.mk.in @@ -46,6 +46,7 @@ DEPMODE =3D @CCDEPMODE@ DEPDIR =3D @DEPDIR@ =20 zlibdir =3D @zlibdir@ +ZSTD_LIBS =3D @ZSTD_LIBS@ @PLUGINS_TRUE@LIBDL =3D @lt_cv_dlopen_libs@ LIBINTL =3D @LIBINTL@ LIBINTL_DEP =3D @LIBINTL_DEP@ diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index 74e5dad3049..b07ec96e147 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -223,7 +223,7 @@ ZLIB =3D $(zlibdir) -lz LIBIBERTY_LIB =3D ../../libiberty/libiberty.a BFD_LIB =3D ../../bfd/libbfd.a OPCODES_LIB =3D ../../opcodes/libopcodes.a -CONFIG_LIBS =3D $(COMMON_LIBS) @LIBS@ $(ZLIB) +CONFIG_LIBS =3D $(COMMON_LIBS) @LIBS@ $(ZLIB) $(ZSTD_LIBS) LIBDEPS =3D $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL_DEP) $(LIBIBERTY_LIB) EXTRA_LIBS =3D $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \ $(CONFIG_LIBS) $(SIM_EXTRA_LIBS) $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS) diff --git a/sim/config.h.in b/sim/config.h.in index 8e84759df04..84c363c0aec 100644 --- a/sim/config.h.in +++ b/sim/config.h.in @@ -383,6 +383,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H =20 +/* Define to 1 if zstd is enabled. */ +#undef HAVE_ZSTD + /* Define to 1 if the system has the type `__int128'. */ #undef HAVE___INT128 =20 diff --git a/sim/configure b/sim/configure index b31c2f5d8f3..75d1935df38 100755 --- a/sim/configure +++ b/sim/configure @@ -879,6 +879,8 @@ SED LIBTOOL PLUGINS_FALSE PLUGINS_TRUE +ZSTD_LIBS +ZSTD_CFLAGS zlibinc zlibdir CATOBJEXT @@ -981,6 +983,7 @@ enable_option_checking with_pkgversion with_bugurl with_system_zlib +with_zstd enable_plugins enable_shared enable_static @@ -1025,6 +1028,8 @@ CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR +ZSTD_CFLAGS +ZSTD_LIBS SDL_CFLAGS SDL_LIBS AS_FOR_TARGET_AARCH64 @@ -1807,6 +1812,8 @@ Optional Packages: --with-pkgversion=3DPKG Use PKG in the version string in place of "SIM" --with-bugurl=3DURL Direct users to URL to report a bug --with-system-zlib use installed libz + --with-zstd support zstd compressed debug sections + (default=3Dauto) --with-pic try to use only PIC/non-PIC objects [default=3Du= se both] --with-gnu-ld assume the C compiler uses GNU ld [default=3Dno] @@ -1825,6 +1832,8 @@ Some influential environment variables: 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 SDL_CFLAGS C compiler flags for SDL, overriding pkg-config SDL_LIBS linker flags for SDL, overriding pkg-config AS_FOR_TARGET_AARCH64 @@ -9065,6 +9074,127 @@ fi =20 =20 =20 +# 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 + + + maybe_plugins=3Dno for ac_header in dlfcn.h do : @@ -12641,7 +12771,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 12644 "configure" +#line 12774 "configure" #include "confdefs.h" =20 #if HAVE_DLFCN_H @@ -12747,7 +12877,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 12750 "configure" +#line 12880 "configure" #include "confdefs.h" =20 #if HAVE_DLFCN_H diff --git a/sim/m4/sim_ac_platform.m4 b/sim/m4/sim_ac_platform.m4 index aa91c42562e..a91b2334b84 100644 --- a/sim/m4/sim_ac_platform.m4 +++ b/sim/m4/sim_ac_platform.m4 @@ -150,6 +150,7 @@ ZW_GNU_GETTEXT_SISTER_DIR dnl BFD conditionally uses zlib, so we must link it in if libbfd does, by dnl using the same condition. AM_ZLIB +AC_ZSTD =20 dnl BFD uses libdl when when plugins enabled. AC_PLUGINS diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in index 33d7df953b5..b0c073b8867 100644 --- a/sim/ppc/Makefile.in +++ b/sim/ppc/Makefile.in @@ -522,7 +522,7 @@ PACKAGE_OBJ =3D @sim_pk_obj@ =20 =20 psim$(EXEEXT): $(TARGETLIB) main.o $(LIBIBERTY_LIB) $(BFD_LIB) $(LIBINTL_D= EP) - $(ECHO_CCLD) $(CC) $(CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETL= IB) $(BFD_LIB) $(ZLIB) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS) + $(ECHO_CCLD) $(CC) $(CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETL= IB) $(BFD_LIB) $(ZLIB) $(ZSTD_LIBS) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS) =20 run$(EXEEXT): psim$(EXEEXT) $(SILENCE) rm -f $@