From 7294489d924dbe6c01ba5c66e83793757677465f Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 20 Jun 2019 10:08:17 +0200 Subject: [PATCH 1/2] Configure detection for zstd. --- gcc/Makefile.in | 4 +- gcc/config.in | 6 +++ gcc/configure | 101 ++++++++++++++++++++++++++++++++++++++++++++++- gcc/configure.ac | 21 ++++++++++ 4 files changed, 129 insertions(+), 3 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index d9e0885b96b..597dc01328b 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1065,7 +1065,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY) LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \ $(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS) BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \ - $(ZLIB) + $(ZLIB) $(ZSTD_LIB) # Any system libraries needed just for GNAT. SYSLIBS = @GNAT_LIBEXC@ @@ -1076,6 +1076,8 @@ GNATMAKE = @GNATMAKE@ # Libs needed (at present) just for jcf-dump. LDEXP_LIB = @LDEXP_LIB@ +ZSTD_LIB = @ZSTD_LIB@ + # Likewise, for use in the tools that must run on this machine # even if we are cross-building GCC. BUILD_LIBS = $(BUILD_LIBIBERTY) diff --git a/gcc/config.in b/gcc/config.in index a718ceaf3da..13fd7959dd7 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1926,6 +1926,12 @@ #endif +/* Define if you have a working header file. */ +#ifndef USED_FOR_TARGET +#undef HAVE_ZSTD_H +#endif + + /* Define if isl is in use. */ #ifndef USED_FOR_TARGET #undef HAVE_isl diff --git a/gcc/configure b/gcc/configure index 955e9ccc09b..9c3439c156b 100755 --- a/gcc/configure +++ b/gcc/configure @@ -782,6 +782,7 @@ manext LIBICONV_DEP LTLIBICONV LIBICONV +ZSTD_LIB DL_LIB LDEXP_LIB EXTRA_GCC_LIBS @@ -9798,6 +9799,70 @@ DL_LIB="$LIBS" LIBS="$save_LIBS" +# LTO can use zstd compression algorithm +save_LIBS="$LIBS" +LIBS= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ZSTD_compress" >&5 +$as_echo_n "checking for library containing ZSTD_compress... " >&6; } +if ${ac_cv_search_ZSTD_compress+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ZSTD_compress (); +int +main () +{ +return ZSTD_compress (); + ; + return 0; +} +_ACEOF +for ac_lib in '' zstd; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_search_ZSTD_compress=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_ZSTD_compress+:} false; then : + break +fi +done +if ${ac_cv_search_ZSTD_compress+:} false; then : + +else + ac_cv_search_ZSTD_compress=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ZSTD_compress" >&5 +$as_echo "$ac_cv_search_ZSTD_compress" >&6; } +ac_res=$ac_cv_search_ZSTD_compress +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +ZSTD_LIB="$LIBS" +LIBS="$save_LIBS" + + + # Use only if it exists, # doesn't clash with , declares intmax_t and defines # PRId64 @@ -9838,6 +9903,38 @@ $as_echo "#define HAVE_INTTYPES_H 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zstd.h" >&5 +$as_echo_n "checking for zstd.h... " >&6; } +if ${gcc_cv_header_zstd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + gcc_cv_header_zstd_h=yes +else + gcc_cv_header_zstd_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_header_zstd_h" >&5 +$as_echo "$gcc_cv_header_zstd_h" >&6; } +if test $gcc_cv_header_zstd_h = yes; then + +$as_echo "#define HAVE_ZSTD_H 1" >>confdefs.h + +fi + for ac_func in times clock kill getrlimit setrlimit atoq \ @@ -18655,7 +18752,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18658 "configure" +#line 18755 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18761,7 +18858,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18764 "configure" +#line 18861 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index 066a6f4c958..3ee4fd2e2ee 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1237,6 +1237,15 @@ DL_LIB="$LIBS" LIBS="$save_LIBS" AC_SUBST(DL_LIB) +# LTO can use zstd compression algorithm +save_LIBS="$LIBS" +LIBS= +AC_SEARCH_LIBS(ZSTD_compress, zstd) +ZSTD_LIB="$LIBS" +LIBS="$save_LIBS" +AC_SUBST(ZSTD_LIB) + + # Use only if it exists, # doesn't clash with , declares intmax_t and defines # PRId64 @@ -1258,6 +1267,18 @@ if test $gcc_cv_header_inttypes_h = yes; then [Define if you have a working header file.]) fi +AC_MSG_CHECKING(for zstd.h) +AC_CACHE_VAL(gcc_cv_header_zstd_h, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[#include ]])], + [gcc_cv_header_zstd_h=yes], + [gcc_cv_header_zstd_h=no])]) +AC_MSG_RESULT($gcc_cv_header_zstd_h) +if test $gcc_cv_header_zstd_h = yes; then + AC_DEFINE(HAVE_ZSTD_H, 1, + [Define if you have a working header file.]) +fi + dnl Disabled until we have a complete test for buggy enum bitfields. dnl gcc_AC_C_ENUM_BF_UNSIGNED -- 2.21.0