proper fix for python3 dynamic linking

This commit is contained in:
Zdenek Dohnal 2020-07-16 13:54:10 +02:00
parent 2294d55934
commit 93c00dba0c
2 changed files with 57 additions and 58 deletions

View File

@ -1,23 +1,22 @@
From 4fb89067dca5cee1611461badcbb80a1a36ae963 Mon Sep 17 00:00:00 2001 From 39049f0fc3562330e75ccdcca230a5bb8de2babf Mon Sep 17 00:00:00 2001
From: Zdenek Dohnal <zdohnal@redhat.com> From: Zdenek Dohnal <zdohnal@redhat.com>
Date: Wed, 15 Jul 2020 10:45:26 +0200 Date: Thu, 16 Jul 2020 13:37:18 +0200
Subject: [PATCH] if_python3.c: Fixing linker errors in dynamically linked Subject: [PATCH] src/if_python3.c: fix build with python 3.9
python3 interpreter
--- ---
src/if_python3.c | 31 +++++++++++++++++++++++-------- src/if_python3.c | 40 +++++++++++++++++++++++++++++++++++++---
1 file changed, 23 insertions(+), 8 deletions(-) 1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/src/if_python3.c b/src/if_python3.c diff --git a/src/if_python3.c b/src/if_python3.c
index d540226b3..8c85708da 100644 index d540226b3..843fa079f 100644
--- a/src/if_python3.c --- a/src/if_python3.c
+++ b/src/if_python3.c +++ b/src/if_python3.c
@@ -203,6 +203,9 @@ typedef PySliceObject PySliceObject_T; @@ -203,6 +203,9 @@ typedef PySliceObject PySliceObject_T;
# define PySys_GetObject py3_PySys_GetObject # define PySys_GetObject py3_PySys_GetObject
# define PySys_SetArgv py3_PySys_SetArgv # define PySys_SetArgv py3_PySys_SetArgv
# define PyType_Ready py3_PyType_Ready # define PyType_Ready py3_PyType_Ready
+# if PY_VERSION_HEX >= 0x030800f0 +# if PY_VERSION_HEX >= 0x030900b0
+# define PyType_HasFeature py3_PyType_HasFeature +# define PyType_GetFlags py3_PyType_GetFlags
+# endif +# endif
#undef Py_BuildValue #undef Py_BuildValue
# define Py_BuildValue py3_Py_BuildValue # define Py_BuildValue py3_Py_BuildValue
@ -26,13 +25,13 @@ index d540226b3..8c85708da 100644
# define PyBytes_FromString py3_PyBytes_FromString # define PyBytes_FromString py3_PyBytes_FromString
# undef PyBytes_FromStringAndSize # undef PyBytes_FromStringAndSize
# define PyBytes_FromStringAndSize py3_PyBytes_FromStringAndSize # define PyBytes_FromStringAndSize py3_PyBytes_FromStringAndSize
+# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0 +# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
+# define _Py_Dealloc py3__Py_Dealloc +# define _Py_Dealloc py3__Py_Dealloc
+# endif +# endif
# define PyFloat_FromDouble py3_PyFloat_FromDouble # define PyFloat_FromDouble py3_PyFloat_FromDouble
# define PyFloat_AsDouble py3_PyFloat_AsDouble # define PyFloat_AsDouble py3_PyFloat_AsDouble
# define PyObject_GenericGetAttr py3_PyObject_GenericGetAttr # define PyObject_GenericGetAttr py3_PyObject_GenericGetAttr
@@ -247,12 +253,11 @@ typedef PySliceObject PySliceObject_T; @@ -247,7 +253,6 @@ typedef PySliceObject PySliceObject_T;
# ifdef Py_DEBUG # ifdef Py_DEBUG
# define _Py_NegativeRefcount py3__Py_NegativeRefcount # define _Py_NegativeRefcount py3__Py_NegativeRefcount
# define _Py_RefTotal (*py3__Py_RefTotal) # define _Py_RefTotal (*py3__Py_RefTotal)
@ -40,42 +39,41 @@ index d540226b3..8c85708da 100644
# define PyModule_Create2TraceRefs py3_PyModule_Create2TraceRefs # define PyModule_Create2TraceRefs py3_PyModule_Create2TraceRefs
# else # else
# define PyModule_Create2 py3_PyModule_Create2 # define PyModule_Create2 py3_PyModule_Create2
# endif @@ -287,6 +292,10 @@ typedef PySliceObject PySliceObject_T;
-# if defined(Py_DEBUG) && !defined(Py_DEBUG_NO_PYMALLOC)
+# if (defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0) && !defined(Py_DEBUG_NO_PYMALLOC)
# define _PyObject_DebugMalloc py3__PyObject_DebugMalloc
# define _PyObject_DebugFree py3__PyObject_DebugFree
# else
@@ -282,7 +287,7 @@ typedef PySliceObject PySliceObject_T;
# define PyCapsule_New py3_PyCapsule_New
# define PyCapsule_GetPointer py3_PyCapsule_GetPointer
-# if defined(Py_DEBUG) && !defined(Py_DEBUG_NO_PYMALLOC)
+# if (defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0) && !defined(Py_DEBUG_NO_PYMALLOC)
# undef PyObject_NEW
# define PyObject_NEW(type, typeobj) \ # define PyObject_NEW(type, typeobj) \
( (type *) PyObject_Init( \ ( (type *) PyObject_Init( \
@@ -352,6 +357,9 @@ static PyObject* (*py3_PyObject_Repr)(PyObject *); (PyObject *) _PyObject_DebugMalloc( _PyObject_SIZE(typeobj) ), (typeobj)) )
+# elif PY_VERSION_HEX >= 0x030900b0
+# undef PyObject_NEW
+# define PyObject_NEW(type, typeobj) \
+ ((type *)py3__PyObject_New(typeobj))
# endif
/*
@@ -352,6 +361,9 @@ static PyObject* (*py3_PyObject_Repr)(PyObject *);
static PyObject* (*py3_PyObject_GetItem)(PyObject *, PyObject *); static PyObject* (*py3_PyObject_GetItem)(PyObject *, PyObject *);
static int (*py3_PyObject_IsTrue)(PyObject *); static int (*py3_PyObject_IsTrue)(PyObject *);
static PyObject* (*py3_Py_BuildValue)(char *, ...); static PyObject* (*py3_Py_BuildValue)(char *, ...);
+# if PY_VERSION_HEX >= 0x030800f0 +# if PY_VERSION_HEX >= 0x030900b0
+static int (*py3_PyType_HasFeature)(PyTypeObject *o, int feature); +static int (*py3_PyType_GetFlags)(PyTypeObject *o);
+# endif +# endif
static int (*py3_PyType_Ready)(PyTypeObject *type); static int (*py3_PyType_Ready)(PyTypeObject *type);
static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item); static int (*py3_PyDict_SetItemString)(PyObject *dp, char *key, PyObject *item);
static PyObject* (*py3_PyUnicode_FromString)(const char *u); static PyObject* (*py3_PyUnicode_FromString)(const char *u);
@@ -396,6 +404,9 @@ static char* (*py3_PyBytes_AsString)(PyObject *bytes); @@ -396,6 +408,12 @@ static char* (*py3_PyBytes_AsString)(PyObject *bytes);
static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, Py_ssize_t *length); static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, Py_ssize_t *length);
static PyObject* (*py3_PyBytes_FromString)(char *str); static PyObject* (*py3_PyBytes_FromString)(char *str);
static PyObject* (*py3_PyBytes_FromStringAndSize)(char *str, Py_ssize_t length); static PyObject* (*py3_PyBytes_FromStringAndSize)(char *str, Py_ssize_t length);
+# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0 +# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
+static void (*py3__Py_Dealloc)(PyObject *obj); +static void (*py3__Py_Dealloc)(PyObject *obj);
+# endif
+# if PY_VERSION_HEX >= 0x030900b0
+static PyObject* (*py3__PyObject_New)(PyTypeObject *);
+# endif +# endif
static PyObject* (*py3_PyFloat_FromDouble)(double num); static PyObject* (*py3_PyFloat_FromDouble)(double num);
static double (*py3_PyFloat_AsDouble)(PyObject *); static double (*py3_PyFloat_AsDouble)(PyObject *);
static PyObject* (*py3_PyObject_GenericGetAttr)(PyObject *obj, PyObject *name); static PyObject* (*py3_PyObject_GenericGetAttr)(PyObject *obj, PyObject *name);
@@ -414,12 +425,11 @@ static void* (*py3_PyCapsule_GetPointer)(PyObject *, char *); @@ -414,7 +432,6 @@ static void* (*py3_PyCapsule_GetPointer)(PyObject *, char *);
# ifdef Py_DEBUG # ifdef Py_DEBUG
static void (*py3__Py_NegativeRefcount)(const char *fname, int lineno, PyObject *op); static void (*py3__Py_NegativeRefcount)(const char *fname, int lineno, PyObject *op);
static Py_ssize_t* py3__Py_RefTotal; static Py_ssize_t* py3__Py_RefTotal;
@ -83,33 +81,30 @@ index d540226b3..8c85708da 100644
static PyObject* (*py3_PyModule_Create2TraceRefs)(struct PyModuleDef* module, int module_api_version); static PyObject* (*py3_PyModule_Create2TraceRefs)(struct PyModuleDef* module, int module_api_version);
# else # else
static PyObject* (*py3_PyModule_Create2)(struct PyModuleDef* module, int module_api_version); static PyObject* (*py3_PyModule_Create2)(struct PyModuleDef* module, int module_api_version);
# endif @@ -525,6 +542,9 @@ static struct
-# if defined(Py_DEBUG) && !defined(Py_DEBUG_NO_PYMALLOC)
+# if (defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0) && !defined(Py_DEBUG_NO_PYMALLOC)
static void (*py3__PyObject_DebugFree)(void*);
static void* (*py3__PyObject_DebugMalloc)(size_t);
# else
@@ -525,6 +535,9 @@ static struct
{"PyObject_IsTrue", (PYTHON_PROC*)&py3_PyObject_IsTrue}, {"PyObject_IsTrue", (PYTHON_PROC*)&py3_PyObject_IsTrue},
{"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong}, {"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong},
{"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New}, {"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New},
+# if PY_VERSION_HEX >= 0x030800f0 +# if PY_VERSION_HEX >= 0x030900b0
+ {"PyType_HasFeature", (PYTHON_PROC*)&py3_PyType_HasFeature}, + {"PyType_GetFlags", (PYTHON_PROC*)&py3_PyType_GetFlags},
+# endif +# endif
{"PyType_Ready", (PYTHON_PROC*)&py3_PyType_Ready}, {"PyType_Ready", (PYTHON_PROC*)&py3_PyType_Ready},
{"PyDict_SetItemString", (PYTHON_PROC*)&py3_PyDict_SetItemString}, {"PyDict_SetItemString", (PYTHON_PROC*)&py3_PyDict_SetItemString},
{"PyLong_AsLong", (PYTHON_PROC*)&py3_PyLong_AsLong}, {"PyLong_AsLong", (PYTHON_PROC*)&py3_PyLong_AsLong},
@@ -562,6 +575,9 @@ static struct @@ -562,6 +582,12 @@ static struct
{"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize}, {"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize},
{"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString}, {"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString},
{"PyBytes_FromStringAndSize", (PYTHON_PROC*)&py3_PyBytes_FromStringAndSize}, {"PyBytes_FromStringAndSize", (PYTHON_PROC*)&py3_PyBytes_FromStringAndSize},
+# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0 +# if defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030900b0
+ {"_Py_Dealloc", (PYTHON_PROC*)&py3__Py_Dealloc}, + {"_Py_Dealloc", (PYTHON_PROC*)&py3__Py_Dealloc},
+# endif
+# if PY_VERSION_HEX >= 0x030900b0
+ {"_PyObject_New", (PYTHON_PROC*)&py3__PyObject_New},
+# endif +# endif
{"PyFloat_FromDouble", (PYTHON_PROC*)&py3_PyFloat_FromDouble}, {"PyFloat_FromDouble", (PYTHON_PROC*)&py3_PyFloat_FromDouble},
{"PyFloat_AsDouble", (PYTHON_PROC*)&py3_PyFloat_AsDouble}, {"PyFloat_AsDouble", (PYTHON_PROC*)&py3_PyFloat_AsDouble},
{"PyObject_GenericGetAttr", (PYTHON_PROC*)&py3_PyObject_GenericGetAttr}, {"PyObject_GenericGetAttr", (PYTHON_PROC*)&py3_PyObject_GenericGetAttr},
@@ -578,12 +594,11 @@ static struct @@ -578,7 +604,6 @@ static struct
# ifdef Py_DEBUG # ifdef Py_DEBUG
{"_Py_NegativeRefcount", (PYTHON_PROC*)&py3__Py_NegativeRefcount}, {"_Py_NegativeRefcount", (PYTHON_PROC*)&py3__Py_NegativeRefcount},
{"_Py_RefTotal", (PYTHON_PROC*)&py3__Py_RefTotal}, {"_Py_RefTotal", (PYTHON_PROC*)&py3__Py_RefTotal},
@ -117,21 +112,22 @@ index d540226b3..8c85708da 100644
{"PyModule_Create2TraceRefs", (PYTHON_PROC*)&py3_PyModule_Create2TraceRefs}, {"PyModule_Create2TraceRefs", (PYTHON_PROC*)&py3_PyModule_Create2TraceRefs},
# else # else
{"PyModule_Create2", (PYTHON_PROC*)&py3_PyModule_Create2}, {"PyModule_Create2", (PYTHON_PROC*)&py3_PyModule_Create2},
@@ -634,6 +659,15 @@ py3__Py_XDECREF(PyObject *op)
# define Py_XDECREF(op) py3__Py_XDECREF(_PyObject_CAST(op))
# endif # endif
-# if defined(Py_DEBUG) && !defined(Py_DEBUG_NO_PYMALLOC)
+# if (defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0) && !defined(Py_DEBUG_NO_PYMALLOC) +# if PY_VERSION_HEX >= 0x030900b0
{"_PyObject_DebugFree", (PYTHON_PROC*)&py3__PyObject_DebugFree}, + static inline int
{"_PyObject_DebugMalloc", (PYTHON_PROC*)&py3__PyObject_DebugMalloc}, +py3_PyType_HasFeature(PyTypeObject *type, unsigned long feature)
# else +{
@@ -777,7 +792,7 @@ static int python_end_called = FALSE; + return ((PyType_GetFlags(type) & feature) != 0);
static void +}
call_PyObject_Free(void *p) +# define PyType_HasFeature(t,f) py3_PyType_HasFeature(t,f)
{ +# endif
-#if defined(Py_DEBUG) && !defined(Py_DEBUG_NO_PYMALLOC) +
+# if (defined(Py_DEBUG) || PY_VERSION_HEX >= 0x030800f0) && !defined(Py_DEBUG_NO_PYMALLOC) /*
_PyObject_DebugFree(p); * Load library and get all pointers.
#else * Parameter 'libname' provides name of DLL.
PyObject_Free(p);
-- --
2.25.4 2.25.4

View File

@ -21,7 +21,7 @@ Summary: The VIM editor
URL: http://www.vim.org/ URL: http://www.vim.org/
Name: vim Name: vim
Version: %{baseversion}.%{patchlevel} Version: %{baseversion}.%{patchlevel}
Release: 1%{?dist} Release: 2%{?dist}
License: Vim and MIT License: Vim and MIT
Source0: ftp://ftp.vim.org/pub/vim/unix/vim-%{baseversion}-%{patchlevel}.tar.bz2 Source0: ftp://ftp.vim.org/pub/vim/unix/vim-%{baseversion}-%{patchlevel}.tar.bz2
Source1: vim.sh Source1: vim.sh
@ -60,7 +60,7 @@ Patch3017: vim-python3-tests.patch
# fips warning # fips warning
Patch3018: vim-crypto-warning.patch Patch3018: vim-crypto-warning.patch
# fix dynamic python3 linking with python3.8 # fix dynamic python3 linking with python3.8
Patch3019: 0001-if_python3.c-Fixing-linker-errors-in-dynamically-lin.patch Patch3019: 0001-src-if_python3.c-fix-build-with-python-3.9.patch
# gcc is no longer in buildroot by default # gcc is no longer in buildroot by default
BuildRequires: gcc BuildRequires: gcc
@ -775,6 +775,9 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags
%{_datadir}/icons/locolor/*/apps/* %{_datadir}/icons/locolor/*/apps/*
%changelog %changelog
* Thu Jul 16 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1224-2
- proper fix for python3 dynamic linking
* Thu Jul 16 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1224-1 * Thu Jul 16 2020 Zdenek Dohnal <zdohnal@redhat.com> - 2:8.2.1224-1
- patchlevel 1224 - patchlevel 1224