public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6985] build: Check that -lzstd can be linked
@ 2023-04-03  8:35 Rainer Orth
  0 siblings, 0 replies; only message in thread
From: Rainer Orth @ 2023-04-03  8:35 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b0248580b68d970788bb43ac3ab8fe3e21ef71be

commit r13-6985-gb0248580b68d970788bb43ac3ab8fe3e21ef71be
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Mon Apr 3 10:34:45 2023 +0200

    build: Check that -lzstd can be linked
    
    Recent Solaris 11.4 SRUs bundle zstd, but only the 64-bit libraries (no
    idea why).  Because of this, in 32-bit builds cc1 etc. fail to link with
    undefined references to various ZSTD_* functions from lto-compress.o.
    This happens because currently only the presence of <zstd.h> is
    necessary to enable zstd support in lto-compress.cc etc.
    
    This patch checks for libzstd first and disables zstd support if
    missing.
    
    Tested on sparc-sun-solaris2.11 with the system installation of zstd
    (64-bit only) and a locally-compiled one (specified with --with-zstd).
    
    2023-03-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
    
            gcc:
            * configure.ac (ZSTD_LIB): Move before zstd.h check.
            Unset gcc_cv_header_zstd_h without libzstd.
            * configure: Regenerate.

Diff:
---
 gcc/configure    | 84 +++++++++++++++++++++++++++++---------------------------
 gcc/configure.ac | 16 +++++------
 2 files changed, 51 insertions(+), 49 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index 88213d855d5..c7b26d1927d 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -10622,45 +10622,6 @@ fi
 CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS"
 LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS"
 
-{ $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
-  # We require version 1.3.0 or later.  This is the first version that has
-# ZSTD_getFrameContentSize.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <zstd.h>
-#if ZSTD_VERSION_NUMBER < 10300
-#error "need zstd 1.3.0 or better"
-#endif
-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
-
-elif test "x$with_zstd" != x; then
-    as_fn_error $? "Unable to find zstd.h.  See config.log for details." "$LINENO" 5
-fi
-
 # LTO can use zstd compression algorithm
 save_LIBS="$LIBS"
 LIBS=
@@ -10718,11 +10679,52 @@ ac_res=$ac_cv_search_ZSTD_compress
 if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
+else
+  gcc_cv_header_zstd_h=no
 fi
 
 ZSTD_LIB="$LIBS"
 LIBS="$save_LIBS"
 
+
+{ $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
+  # We require version 1.3.0 or later.  This is the first version that has
+# ZSTD_getFrameContentSize.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10300
+#error "need zstd 1.3.0 or better"
+#endif
+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
+
+elif test "x$with_zstd" != x; then
+    as_fn_error $? "Unable to find zstd.h.  See config.log for details." "$LINENO" 5
+fi
 fi
 
 
@@ -19823,7 +19825,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19826 "configure"
+#line 19828 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19929,7 +19931,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19932 "configure"
+#line 19934 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b56036d298c..09082e8ccae 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1515,6 +1515,14 @@ fi
 CXXFLAGS="$CXXFLAGS $ZSTD_CPPFLAGS"
 LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS"
 
+# LTO can use zstd compression algorithm
+save_LIBS="$LIBS"
+LIBS=
+AC_SEARCH_LIBS(ZSTD_compress, zstd,, gcc_cv_header_zstd_h=no)
+ZSTD_LIB="$LIBS"
+LIBS="$save_LIBS"
+AC_SUBST(ZSTD_LIB)
+
 AC_MSG_CHECKING(for zstd.h)
 AC_CACHE_VAL(gcc_cv_header_zstd_h,
 # We require version 1.3.0 or later.  This is the first version that has
@@ -1533,14 +1541,6 @@ if test $gcc_cv_header_zstd_h = yes; then
 elif test "x$with_zstd" != x; then
     as_fn_error $? "Unable to find zstd.h.  See config.log for details." "$LINENO" 5
 fi
-
-# 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)
 fi
 
 dnl Disabled until we have a complete test for buggy enum bitfields.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-03  8:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03  8:35 [gcc r13-6985] build: Check that -lzstd can be linked Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).