diff options
author | Yi Zhao <yi.zhao@windriver.com> | 2018-08-15 13:20:36 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-08-15 21:45:58 +0100 |
commit | 2a040ba8eda434d636eb3855cbdf9ab4003065cd (patch) | |
tree | f99cd09c752ff04583fa49b4bde7952d20b02905 | |
parent | bce531d503c1f7944671021704e39bcd13d67790 (diff) | |
download | poky-2a040ba8eda434d636eb3855cbdf9ab4003065cd.tar.gz |
swig: fix gcc8 warnings for cast between incompatible function types
We got an error when building setools in meta-selinux:
setools/policyrep/qpol_wrap.c:1819:23:
error: cast between incompatible function types from 'PyObject * (*)(PyObject *)'
{aka 'struct _object * (*)(struct _object *)'} to 'PyObject * (*)(PyObject *, PyObject *)'
{aka 'struct _object * (*)(struct _object *, struct _object *)'} [-Werror=cast-function-type]
{(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
This is a swig issue. See: https://github.com/swig/swig/issues/1259
Backport a patch from upstream to fix it.
(From OE-Core rev: f0f8ee668de34ad30ca16f5300966a3470018940)
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-devtools/swig/swig/Python-Fix-new-GCC8-warnings-in-generated-code.patch | 191 | ||||
-rw-r--r-- | meta/recipes-devtools/swig/swig_3.0.12.bb | 1 |
2 files changed, 192 insertions, 0 deletions
diff --git a/meta/recipes-devtools/swig/swig/Python-Fix-new-GCC8-warnings-in-generated-code.patch b/meta/recipes-devtools/swig/swig/Python-Fix-new-GCC8-warnings-in-generated-code.patch new file mode 100644 index 0000000000..a91385916c --- /dev/null +++ b/meta/recipes-devtools/swig/swig/Python-Fix-new-GCC8-warnings-in-generated-code.patch | |||
@@ -0,0 +1,191 @@ | |||
1 | From b6c0ef4b8f6e5c089ac7104b3aaba8f1d17b8b82 Mon Sep 17 00:00:00 2001 | ||
2 | From: Olly Betts <olly@survex.com> | ||
3 | Date: Mon, 11 Jun 2018 15:51:53 +1200 | ||
4 | Subject: [PATCH] [Python] Fix new GCC8 warnings in generated code | ||
5 | |||
6 | Avoid casts between incompatible function types where possible (when | ||
7 | keyword args are in use, it is not possible to avoid such warnings as | ||
8 | they are inherent in the design of Python's C API in that particular | ||
9 | case). Fixes #1259. | ||
10 | |||
11 | Upstream-Status: Backport | ||
12 | [https://github.com/swig/swig/commit/7f9883011029674553a2a4b623d459f02b512458] | ||
13 | |||
14 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
15 | --- | ||
16 | Lib/python/pyinit.swg | 4 ++-- | ||
17 | Lib/python/pyrun.swg | 34 ++++++++++++++++++++++++++-------- | ||
18 | Source/Modules/python.cxx | 26 +++++++++++++------------- | ||
19 | 3 files changed, 41 insertions(+), 23 deletions(-) | ||
20 | |||
21 | diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg | ||
22 | index 2cc5828..6bf68c1 100644 | ||
23 | --- a/Lib/python/pyinit.swg | ||
24 | +++ b/Lib/python/pyinit.swg | ||
25 | @@ -368,8 +368,8 @@ SWIG_init(void) { | ||
26 | (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL | ||
27 | }; | ||
28 | static SwigPyGetSet thisown_getset_closure = { | ||
29 | - (PyCFunction) SwigPyObject_own, | ||
30 | - (PyCFunction) SwigPyObject_own | ||
31 | + SwigPyObject_own, | ||
32 | + SwigPyObject_own | ||
33 | }; | ||
34 | static PyGetSetDef thisown_getset_def = { | ||
35 | (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure | ||
36 | diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg | ||
37 | index ab1237f..3d0b1b3 100644 | ||
38 | --- a/Lib/python/pyrun.swg | ||
39 | +++ b/Lib/python/pyrun.swg | ||
40 | @@ -465,6 +465,14 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args) | ||
41 | return repr; | ||
42 | } | ||
43 | |||
44 | +/* We need a version taking two PyObject* parameters so it's a valid | ||
45 | + * PyCFunction to use in swigobject_methods[]. */ | ||
46 | +SWIGRUNTIME PyObject * | ||
47 | +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) | ||
48 | +{ | ||
49 | + return SwigPyObject_repr((SwigPyObject*)v); | ||
50 | +} | ||
51 | + | ||
52 | SWIGRUNTIME int | ||
53 | SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) | ||
54 | { | ||
55 | @@ -594,11 +602,7 @@ SwigPyObject_append(PyObject* v, PyObject* next) | ||
56 | } | ||
57 | |||
58 | SWIGRUNTIME PyObject* | ||
59 | -#ifdef METH_NOARGS | ||
60 | -SwigPyObject_next(PyObject* v) | ||
61 | -#else | ||
62 | SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) | ||
63 | -#endif | ||
64 | { | ||
65 | SwigPyObject *sobj = (SwigPyObject *) v; | ||
66 | if (sobj->next) { | ||
67 | @@ -633,6 +637,20 @@ SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) | ||
68 | return SWIG_Py_Void(); | ||
69 | } | ||
70 | |||
71 | +#ifdef METH_NOARGS | ||
72 | +static PyObject* | ||
73 | +SwigPyObject_disown2(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) | ||
74 | +{ | ||
75 | + return SwigPyObject_disown(v); | ||
76 | +} | ||
77 | + | ||
78 | +static PyObject* | ||
79 | +SwigPyObject_acquire2(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) | ||
80 | +{ | ||
81 | + return SwigPyObject_acquire(v); | ||
82 | +} | ||
83 | +#endif | ||
84 | + | ||
85 | SWIGINTERN PyObject* | ||
86 | SwigPyObject_own(PyObject *v, PyObject *args) | ||
87 | { | ||
88 | @@ -673,12 +691,12 @@ SwigPyObject_own(PyObject *v, PyObject *args) | ||
89 | #ifdef METH_O | ||
90 | static PyMethodDef | ||
91 | swigobject_methods[] = { | ||
92 | - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, | ||
93 | - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, | ||
94 | + {(char *)"disown", (PyCFunction)SwigPyObject_disown2, METH_NOARGS, (char *)"releases ownership of the pointer"}, | ||
95 | + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire2,METH_NOARGS, (char *)"acquires ownership of the pointer"}, | ||
96 | {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, | ||
97 | {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, | ||
98 | {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, | ||
99 | - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, | ||
100 | + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr2, METH_NOARGS, (char *)"returns object representation"}, | ||
101 | {0, 0, 0, 0} | ||
102 | }; | ||
103 | #else | ||
104 | @@ -689,7 +707,7 @@ swigobject_methods[] = { | ||
105 | {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, | ||
106 | {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, | ||
107 | {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, | ||
108 | - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, | ||
109 | + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, | ||
110 | {0, 0, 0, 0} | ||
111 | }; | ||
112 | #endif | ||
113 | diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx | ||
114 | index a6801fc..72eaa77 100644 | ||
115 | --- a/Source/Modules/python.cxx | ||
116 | +++ b/Source/Modules/python.cxx | ||
117 | @@ -1109,7 +1109,7 @@ public: | ||
118 | * ------------------------------------------------------------ */ | ||
119 | int add_pyinstancemethod_new() { | ||
120 | String *name = NewString("SWIG_PyInstanceMethod_New"); | ||
121 | - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name); | ||
122 | + Printf(methods, "\t { \"%s\", %s, METH_O, NULL},\n", name, name); | ||
123 | Delete(name); | ||
124 | return 0; | ||
125 | } | ||
126 | @@ -2479,17 +2479,17 @@ public: | ||
127 | if (!kw) { | ||
128 | if (n && funpack) { | ||
129 | if (num_required == 0 && num_arguments == 0) { | ||
130 | - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_NOARGS, ", name, function); | ||
131 | + Printf(methods, "\t { \"%s\", %s, METH_NOARGS, ", name, function); | ||
132 | } else if (num_required == 1 && num_arguments == 1) { | ||
133 | - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, ", name, function); | ||
134 | + Printf(methods, "\t { \"%s\", %s, METH_O, ", name, function); | ||
135 | } else { | ||
136 | - Printf(methods, "\t { (char *)\"%s\", %s, METH_VARARGS, ", name, function); | ||
137 | + Printf(methods, "\t { \"%s\", %s, METH_VARARGS, ", name, function); | ||
138 | } | ||
139 | } else { | ||
140 | - Printf(methods, "\t { (char *)\"%s\", %s, METH_VARARGS, ", name, function); | ||
141 | + Printf(methods, "\t { \"%s\", %s, METH_VARARGS, ", name, function); | ||
142 | } | ||
143 | } else { | ||
144 | - Printf(methods, "\t { (char *)\"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS, ", name, function); | ||
145 | + Printf(methods, "\t { \"%s\", (PyCFunction)%s, METH_VARARGS|METH_KEYWORDS, ", name, function); | ||
146 | } | ||
147 | |||
148 | if (!n) { | ||
149 | @@ -3857,7 +3857,7 @@ public: | ||
150 | if (shadow) { | ||
151 | if (builtin) { | ||
152 | String *rname = SwigType_namestr(real_classname); | ||
153 | - Printf(builtin_methods, " { \"__disown__\", (PyCFunction) Swig::Director::swig_pyobj_disown< %s >, METH_NOARGS, \"\" },\n", rname); | ||
154 | + Printf(builtin_methods, " { \"__disown__\", Swig::Director::swig_pyobj_disown< %s >, METH_NOARGS, \"\" },\n", rname); | ||
155 | Delete(rname); | ||
156 | } else { | ||
157 | String *symname = Getattr(n, "sym:name"); | ||
158 | @@ -4694,13 +4694,13 @@ public: | ||
159 | int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2; | ||
160 | String *ds = have_docstring(n) ? cdocstring(n, AUTODOC_FUNC) : NewString(""); | ||
161 | if (check_kwargs(n)) { | ||
162 | - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS|METH_KEYWORDS, (char *) \"%s\" },\n", symname, wname, ds); | ||
163 | + Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, METH_VARARGS|METH_KEYWORDS, \"%s\" },\n", symname, wname, ds); | ||
164 | } else if (argcount == 0) { | ||
165 | - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_NOARGS, (char *) \"%s\" },\n", symname, wname, ds); | ||
166 | + Printf(builtin_methods, " { \"%s\", %s, METH_NOARGS, \"%s\" },\n", symname, wname, ds); | ||
167 | } else if (argcount == 1) { | ||
168 | - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_O, (char *) \"%s\" },\n", symname, wname, ds); | ||
169 | + Printf(builtin_methods, " { \"%s\", %s, METH_O, \"%s\" },\n", symname, wname, ds); | ||
170 | } else { | ||
171 | - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS, (char *) \"%s\" },\n", symname, wname, ds); | ||
172 | + Printf(builtin_methods, " { \"%s\", %s, METH_VARARGS, \"%s\" },\n", symname, wname, ds); | ||
173 | } | ||
174 | Delete(fullname); | ||
175 | Delete(wname); | ||
176 | @@ -4801,10 +4801,10 @@ public: | ||
177 | Append(pyflags, "METH_VARARGS"); | ||
178 | if (have_docstring(n)) { | ||
179 | String *ds = cdocstring(n, AUTODOC_STATICFUNC); | ||
180 | - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, (char *) \"%s\" },\n", symname, wname, pyflags, ds); | ||
181 | + Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, %s, \"%s\" },\n", symname, wname, pyflags, ds); | ||
182 | Delete(ds); | ||
183 | } else { | ||
184 | - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, \"\" },\n", symname, wname, pyflags); | ||
185 | + Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, %s, \"\" },\n", symname, wname, pyflags); | ||
186 | } | ||
187 | Delete(fullname); | ||
188 | Delete(wname); | ||
189 | -- | ||
190 | 2.7.4 | ||
191 | |||
diff --git a/meta/recipes-devtools/swig/swig_3.0.12.bb b/meta/recipes-devtools/swig/swig_3.0.12.bb index 429840bde1..fe9d0747f2 100644 --- a/meta/recipes-devtools/swig/swig_3.0.12.bb +++ b/meta/recipes-devtools/swig/swig_3.0.12.bb | |||
@@ -4,6 +4,7 @@ SRC_URI += "file://0001-Use-proc-self-exe-for-swig-swiglib-on-non-Win32-plat.pat | |||
4 | file://0001-configure-use-pkg-config-for-pcre-detection.patch \ | 4 | file://0001-configure-use-pkg-config-for-pcre-detection.patch \ |
5 | file://0001-Add-Node-7.x-aka-V8-5.2-support.patch \ | 5 | file://0001-Add-Node-7.x-aka-V8-5.2-support.patch \ |
6 | file://swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch \ | 6 | file://swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch \ |
7 | file://Python-Fix-new-GCC8-warnings-in-generated-code.patch \ | ||
7 | " | 8 | " |
8 | SRC_URI[md5sum] = "82133dfa7bba75ff9ad98a7046be687c" | 9 | SRC_URI[md5sum] = "82133dfa7bba75ff9ad98a7046be687c" |
9 | SRC_URI[sha256sum] = "7cf9f447ae7ed1c51722efc45e7f14418d15d7a1e143ac9f09a668999f4fc94d" | 10 | SRC_URI[sha256sum] = "7cf9f447ae7ed1c51722efc45e7f14418d15d7a1e143ac9f09a668999f4fc94d" |