sim: Link ZSTD_LIBS

This fixes linker errors in a `../../configure --enable-targets
--enable-sim; make all-gdb` build.
This commit is contained in:
Fangrui Song 2022-09-27 11:42:32 -07:00 committed by Fangrui Song
parent f7aa1a5acc
commit 382fa97ce0
8 changed files with 144 additions and 5 deletions

View file

@ -170,7 +170,8 @@ am__aclocal_m4_deps = $(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 = @VERSION@
WARN_CFLAGS = @WARN_CFLAGS@
WERROR_CFLAGS = @WERROR_CFLAGS@
XGETTEXT = @XGETTEXT@
ZSTD_CFLAGS = @ZSTD_CFLAGS@
ZSTD_LIBS = @ZSTD_LIBS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

1
sim/aclocal.m4 vendored
View file

@ -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])

View file

@ -46,6 +46,7 @@ DEPMODE = @CCDEPMODE@
DEPDIR = @DEPDIR@
zlibdir = @zlibdir@
ZSTD_LIBS = @ZSTD_LIBS@
@PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@
LIBINTL = @LIBINTL@
LIBINTL_DEP = @LIBINTL_DEP@

View file

@ -223,7 +223,7 @@ ZLIB = $(zlibdir) -lz
LIBIBERTY_LIB = ../../libiberty/libiberty.a
BFD_LIB = ../../bfd/libbfd.a
OPCODES_LIB = ../../opcodes/libopcodes.a
CONFIG_LIBS = $(COMMON_LIBS) @LIBS@ $(ZLIB)
CONFIG_LIBS = $(COMMON_LIBS) @LIBS@ $(ZLIB) $(ZSTD_LIBS)
LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL_DEP) $(LIBIBERTY_LIB)
EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \
$(CONFIG_LIBS) $(SIM_EXTRA_LIBS) $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS)

View file

@ -383,6 +383,9 @@
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define to 1 if zstd is enabled. */
#undef HAVE_ZSTD
/* Define to 1 if the system has the type `__int128'. */
#undef HAVE___INT128

134
sim/configure vendored
View file

@ -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=PKG Use PKG in the version string in place of "SIM"
--with-bugurl=URL Direct users to URL to report a bug
--with-system-zlib use installed libz
--with-zstd support zstd compressed debug sections
(default=auto)
--with-pic try to use only PIC/non-PIC objects [default=use
both]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
@ -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
# Check whether --with-zstd was given.
if test "${with_zstd+set}" = set; then :
withval=$with_zstd;
else
with_zstd=auto
fi
if test "$with_zstd" != no; then :
pkg_failed=no
{ $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="$ZSTD_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ZSTD_CFLAGS=`$PKG_CONFIG --cflags "libzstd" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$ZSTD_LIBS"; then
pkg_cv_ZSTD_LIBS="$ZSTD_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5
($PKG_CONFIG --exists --print-errors "libzstd") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_ZSTD_LIBS=`$PKG_CONFIG --libs "libzstd" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test $pkg_failed = no; then
pkg_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$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=yes
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LDFLAGS=$pkg_save_LDFLAGS
fi
if test $pkg_failed = 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=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
ZSTD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzstd" 2>&1`
else
ZSTD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzstd" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$ZSTD_PKG_ERRORS" >&5
if test "$with_zstd" = yes; then
as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
fi
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if test "$with_zstd" = yes; then
as_fn_error $? "--with-zstd was given, but pkgconfig/libzstd.pc is not found" "$LINENO" 5
fi
else
ZSTD_CFLAGS=$pkg_cv_ZSTD_CFLAGS
ZSTD_LIBS=$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=no
for ac_header in dlfcn.h
do :
@ -12641,7 +12771,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12644 "configure"
#line 12774 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -12747,7 +12877,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12750 "configure"
#line 12880 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H

View file

@ -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
dnl BFD uses libdl when when plugins enabled.
AC_PLUGINS

View file

@ -522,7 +522,7 @@ PACKAGE_OBJ = @sim_pk_obj@
psim$(EXEEXT): $(TARGETLIB) main.o $(LIBIBERTY_LIB) $(BFD_LIB) $(LIBINTL_DEP)
$(ECHO_CCLD) $(CC) $(CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETLIB) $(BFD_LIB) $(ZLIB) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS)
$(ECHO_CCLD) $(CC) $(CFLAGS) $(LDFLAGS) -o psim$(EXEEXT) main.o $(TARGETLIB) $(BFD_LIB) $(ZLIB) $(ZSTD_LIBS) $(LIBINTL) $(LIBIBERTY_LIB) $(LIBS)
run$(EXEEXT): psim$(EXEEXT)
$(SILENCE) rm -f $@