[XEN,for-4.13] configure: Fix test for python 3.8
diff mbox series

Message ID 20191115161532.1231811-1-anthony.perard@citrix.com
State New
Headers show
Series
  • [XEN,for-4.13] configure: Fix test for python 3.8
Related show

Commit Message

Anthony PERARD Nov. 15, 2019, 4:15 p.m. UTC
https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build

> To embed Python into an application, a new --embed option must be
> passed to python3-config --libs --embed to get -lpython3.8 (link the
> application to libpython). To support both 3.8 and older, try
> python3-config --libs --embed first and fallback to python3-config
> --libs (without --embed) if the previous command fails.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    You may want to rerun ./autogen.sh on commit.

 configure          | 14 +-------------
 docs/configure     | 14 +-------------
 m4/python_devel.m4 | 11 +++++++++--
 stubdom/configure  | 14 +-------------
 tools/configure    | 33 +++++++++++++--------------------
 5 files changed, 25 insertions(+), 61 deletions(-)

Comments

Wei Liu Nov. 15, 2019, 4:22 p.m. UTC | #1
On Fri, Nov 15, 2019 at 04:15:32PM +0000, Anthony PERARD wrote:
> https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
> 
> > To embed Python into an application, a new --embed option must be
> > passed to python3-config --libs --embed to get -lpython3.8 (link the
> > application to libpython). To support both 3.8 and older, try
> > python3-config --libs --embed first and fallback to python3-config
> > --libs (without --embed) if the previous command fails.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
> 
> Notes:
>     You may want to rerun ./autogen.sh on commit.

Indeed. This patch introduces a lot of unrelated changes, presumably due
to the difference in autoconf.

> diff --git a/m4/python_devel.m4 b/m4/python_devel.m4
> index e365cd658e0e..bbf1e0354b2b 100644
> --- a/m4/python_devel.m4
> +++ b/m4/python_devel.m4
> @@ -23,8 +23,15 @@ AS_IF([test x"$pyconfig" = x"no"], [
>  ], [
>      dnl If python-config is found use it
>      CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`"
> -    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags`"
> -    LIBS="$LIBS `$PYTHON-config --libs`"
> +    dnl We need to use --embed with python 3.8 but not with earlier version so
> +    dnl check if it is recognized.
> +    python_devel_embed=""
> +    if $PYTHON-config --embed >/dev/null 2>/dev/null; then
> +      python_devel_embed="--embed"
> +    fi
> +    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags $python_devel_embed`"
> +    LIBS="$LIBS `$PYTHON-config --libs $python_devel_embed`"
> +    unset python_devel_embed
>  ])

Acked-by: Wei Liu <wl@xen.org>
Wei Liu Nov. 20, 2019, 10:30 a.m. UTC | #2
On Fri, Nov 15, 2019 at 04:22:15PM +0000, Wei Liu wrote:
> On Fri, Nov 15, 2019 at 04:15:32PM +0000, Anthony PERARD wrote:
> > https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
> > 
> > > To embed Python into an application, a new --embed option must be
> > > passed to python3-config --libs --embed to get -lpython3.8 (link the
> > > application to libpython). To support both 3.8 and older, try
> > > python3-config --libs --embed first and fallback to python3-config
> > > --libs (without --embed) if the previous command fails.
> > 
> > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> > ---
> > 
> > Notes:
> >     You may want to rerun ./autogen.sh on commit.
> 
> Indeed. This patch introduces a lot of unrelated changes, presumably due
> to the difference in autoconf.
> 
> > diff --git a/m4/python_devel.m4 b/m4/python_devel.m4
> > index e365cd658e0e..bbf1e0354b2b 100644
> > --- a/m4/python_devel.m4
> > +++ b/m4/python_devel.m4
> > @@ -23,8 +23,15 @@ AS_IF([test x"$pyconfig" = x"no"], [
> >  ], [
> >      dnl If python-config is found use it
> >      CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`"
> > -    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags`"
> > -    LIBS="$LIBS `$PYTHON-config --libs`"
> > +    dnl We need to use --embed with python 3.8 but not with earlier version so
> > +    dnl check if it is recognized.
> > +    python_devel_embed=""
> > +    if $PYTHON-config --embed >/dev/null 2>/dev/null; then
> > +      python_devel_embed="--embed"
> > +    fi
> > +    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags $python_devel_embed`"
> > +    LIBS="$LIBS `$PYTHON-config --libs $python_devel_embed`"
> > +    unset python_devel_embed
> >  ])
> 
> Acked-by: Wei Liu <wl@xen.org>

Juergen, since we're going to announce Xen to be python 3 compatible for
this release, it would be good to get this patch in.

Wei.
Jürgen Groß Nov. 20, 2019, 10:41 a.m. UTC | #3
On 15.11.19 17:15, Anthony PERARD wrote:
> https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
> 
>> To embed Python into an application, a new --embed option must be
>> passed to python3-config --libs --embed to get -lpython3.8 (link the
>> application to libpython). To support both 3.8 and older, try
>> python3-config --libs --embed first and fallback to python3-config
>> --libs (without --embed) if the previous command fails.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen
Wei Liu Nov. 20, 2019, 10:49 a.m. UTC | #4
On Wed, Nov 20, 2019 at 11:41:24AM +0100, Jürgen Groß wrote:
> On 15.11.19 17:15, Anthony PERARD wrote:
> > https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
> > 
> > > To embed Python into an application, a new --embed option must be
> > > passed to python3-config --libs --embed to get -lpython3.8 (link the
> > > application to libpython). To support both 3.8 and older, try
> > > python3-config --libs --embed first and fallback to python3-config
> > > --libs (without --embed) if the previous command fails.
> > 
> > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> 
> Release-acked-by: Juergen Gross <jgross@suse.com>
> 

Thanks.

Unfortunately I forgot to add in this tag when I pushed the patch...

Wei.

Patch
diff mbox series

diff --git a/configure b/configure
index 4d258eb61534..6ddcf52d9c1b 100755
--- a/configure
+++ b/configure
@@ -644,7 +644,6 @@  infodir
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -723,7 +722,6 @@  datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -976,15 +974,6 @@  do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1122,7 +1111,7 @@  fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1275,7 +1264,6 @@  Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
diff --git a/docs/configure b/docs/configure
index e81644752f43..ca5e28264634 100755
--- a/docs/configure
+++ b/docs/configure
@@ -634,7 +634,6 @@  infodir
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -711,7 +710,6 @@  datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -964,15 +962,6 @@  do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1110,7 +1099,7 @@  fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1263,7 +1252,6 @@  Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
diff --git a/m4/python_devel.m4 b/m4/python_devel.m4
index e365cd658e0e..bbf1e0354b2b 100644
--- a/m4/python_devel.m4
+++ b/m4/python_devel.m4
@@ -23,8 +23,15 @@  AS_IF([test x"$pyconfig" = x"no"], [
 ], [
     dnl If python-config is found use it
     CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`"
-    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags`"
-    LIBS="$LIBS `$PYTHON-config --libs`"
+    dnl We need to use --embed with python 3.8 but not with earlier version so
+    dnl check if it is recognized.
+    python_devel_embed=""
+    if $PYTHON-config --embed >/dev/null 2>/dev/null; then
+      python_devel_embed="--embed"
+    fi
+    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags $python_devel_embed`"
+    LIBS="$LIBS `$PYTHON-config --libs $python_devel_embed`"
+    unset python_devel_embed
 ])
 
 AC_CHECK_HEADER([Python.h], [],
diff --git a/stubdom/configure b/stubdom/configure
index beeb8db2e1fc..95ed9810efc9 100755
--- a/stubdom/configure
+++ b/stubdom/configure
@@ -661,7 +661,6 @@  infodir
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -751,7 +750,6 @@  datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1004,15 +1002,6 @@  do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1150,7 +1139,7 @@  fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1303,7 +1292,6 @@  Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
diff --git a/tools/configure b/tools/configure
index 82947ad30834..c43c8c21be12 100755
--- a/tools/configure
+++ b/tools/configure
@@ -770,7 +770,6 @@  infodir
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -896,7 +895,6 @@  datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1149,15 +1147,6 @@  do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1295,7 +1284,7 @@  fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1448,7 +1437,6 @@  Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -3378,7 +3366,7 @@  else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3424,7 +3412,7 @@  else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3448,7 +3436,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3493,7 +3481,7 @@  else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -3517,7 +3505,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -7460,8 +7448,13 @@  if test x"$pyconfig" = x"no"; then :
 else
 
         CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`"
-    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags`"
-    LIBS="$LIBS `$PYTHON-config --libs`"
+            python_devel_embed=""
+    if $PYTHON-config --embed >/dev/null 2>/dev/null; then
+      python_devel_embed="--embed"
+    fi
+    LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags $python_devel_embed`"
+    LIBS="$LIBS `$PYTHON-config --libs $python_devel_embed`"
+    unset python_devel_embed
 
 fi