diff mbox series

Fix GCC 10+ build failure with zstd version 1.2.0 or older.

Message ID 20200929004546.792-1-jimw@sifive.com
State New
Headers show
Series Fix GCC 10+ build failure with zstd version 1.2.0 or older. | expand

Commit Message

Jim Wilson Sept. 29, 2020, 12:45 a.m. UTC
Extends the configure check for zstd.h to also verify the zstd version,
since gcc requires features that only exist in 1.3.0 and newer.  Without
this patch we get a build error for lto-compress.c when using an old zstd
version.

Tested with builds using zstd 0.5.1, 1.2.0, 1.3.0, and 1.3.3, and checking
to see whether zstd was enabled for the build or not.

OK?

Jim

	gcc/
	PR 97183
	* configure.ac (gcc_cv_header_zstd_h): Check ZSTD_VERISON_NUMBER.
	* configure: Regenerated.
---
 gcc/configure    | 11 ++++++++---
 gcc/configure.ac |  7 ++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

Comments

Richard Biener Sept. 29, 2020, 8:20 a.m. UTC | #1
On Tue, Sep 29, 2020 at 2:46 AM Jim Wilson <jimw@sifive.com> wrote:
>
> Extends the configure check for zstd.h to also verify the zstd version,
> since gcc requires features that only exist in 1.3.0 and newer.  Without
> this patch we get a build error for lto-compress.c when using an old zstd
> version.
>
> Tested with builds using zstd 0.5.1, 1.2.0, 1.3.0, and 1.3.3, and checking
> to see whether zstd was enabled for the build or not.
>
> OK?

OK.

Richard.

> Jim
>
>         gcc/
>         PR 97183
>         * configure.ac (gcc_cv_header_zstd_h): Check ZSTD_VERISON_NUMBER.
>         * configure: Regenerated.
> ---
>  gcc/configure    | 11 ++++++++---
>  gcc/configure.ac |  7 ++++++-
>  2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/configure b/gcc/configure
> index 33a3e34029f..b05a3714fb2 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -10022,9 +10022,14 @@ $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
> +  # 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 ()
>  {
> @@ -19013,7 +19018,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 19016 "configure"
> +#line 19021 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> @@ -19119,7 +19124,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 19122 "configure"
> +#line 19127 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 975f6d97c4b..f5612161dcd 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -1376,8 +1376,13 @@ LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS"
>
>  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
> +# ZSTD_getFrameContentSize.
>  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
> -[[#include <zstd.h>]])],
> +[[#include <zstd.h>
> +#if ZSTD_VERSION_NUMBER < 10300
> +#error "need zstd 1.3.0 or better"
> +#endif]])],
>    [gcc_cv_header_zstd_h=yes],
>    [gcc_cv_header_zstd_h=no])])
>  AC_MSG_RESULT($gcc_cv_header_zstd_h)
> --
> 2.17.1
>
Jim Wilson Sept. 30, 2020, 3:54 a.m. UTC | #2
On Tue, Sep 29, 2020 at 1:20 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Tue, Sep 29, 2020 at 2:46 AM Jim Wilson <jimw@sifive.com> wrote:
> >
> > Extends the configure check for zstd.h to also verify the zstd version,
> > since gcc requires features that only exist in 1.3.0 and newer.  Without
> > this patch we get a build error for lto-compress.c when using an old zstd
> > version.
> >
> > Tested with builds using zstd 0.5.1, 1.2.0, 1.3.0, and 1.3.3, and checking
> > to see whether zstd was enabled for the build or not.
> >
> > OK?
>
> OK.

Thanks.  Committed to the mainline.  Presumably we want a back port to
the gcc-10 branch as the same problem is present there.  I will send a
patch for that.

Jim
diff mbox series

Patch

diff --git a/gcc/configure b/gcc/configure
index 33a3e34029f..b05a3714fb2 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -10022,9 +10022,14 @@  $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
+  # 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 ()
 {
@@ -19013,7 +19018,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19016 "configure"
+#line 19021 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19119,7 +19124,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19122 "configure"
+#line 19127 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 975f6d97c4b..f5612161dcd 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1376,8 +1376,13 @@  LDFLAGS="$LDFLAGS $ZSTD_LDFLAGS"
 
 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
+# ZSTD_getFrameContentSize.
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[#include <zstd.h>]])],
+[[#include <zstd.h>
+#if ZSTD_VERSION_NUMBER < 10300
+#error "need zstd 1.3.0 or better"
+#endif]])],
   [gcc_cv_header_zstd_h=yes],
   [gcc_cv_header_zstd_h=no])])
 AC_MSG_RESULT($gcc_cv_header_zstd_h)