Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build in Ubuntu with gcc-7 and gcc-8 #188

Open
arquicanedo opened this issue Jul 27, 2020 · 4 comments
Open

Cannot build in Ubuntu with gcc-7 and gcc-8 #188

arquicanedo opened this issue Jul 27, 2020 · 4 comments

Comments

@arquicanedo
Copy link

Hi, I'm trying to compile the gcc-python-plugin. I tried with both gcc-7 and gcc-8. I'm using Python 3.8 and building with

make PYTHON=python3.8 PYTHON_CONFIG=python3.8-config

The first problem is related to this error:

gcc-python-wrapper.c:188:1: error: converting to non-pointer type ‘long int’ from NULL [-Werror=conversion-null]
 };
 ^
cc1plus: all warnings being treated as errors
make: *** [Makefile:168: gcc-python-wrapper.o] Error 1

I thought a workaround is to replace -Werror with -Wno-error in the Makefile.

This generates the python.so but fails in the demo as follows

cc1: error: cannot load plugin /home/canedo/MINDSIGHT/gcc-python-plugin/python.so
   /home/canedo/gcc-python-plugin/python.so: undefined symbol: PyExc_NotImplementedError
make[1]: *** [Makefile:303: demo] Error 1

Any hints would be highly appreciated. Thanks.

@davidmalcolm
Copy link
Owner

I believe these are incompatibilities with Python 3.8, which hopefully have been fixed by cdb7020 and 4deefc8. That said, I'm still seeing:
TypeError: 'gcc.WrapperMeta' object is not iterable
(with Python 3.8 and gcc 10) which I'm investigating.

@kristerw
Copy link

kristerw commented Nov 17, 2021

I'm still seeing:
TypeError: 'gcc.WrapperMeta' object is not iterable
(with Python 3.8 and gcc 10) which I'm investigating.

I took a quick look at this, and I have a patch (see below).

The issue is that the Python MRO is freeing an object it is using. This started to happen with the change

commit 2e9954d3472a23919b96323fcd5bb6c1d6927155
Author: Jeroen Demeyer <J.Demeyer@UGent.be>
Date:   Mon Jun 17 13:53:21 2019 +0200

    bpo-36922: use Py_TPFLAGS_METHOD_DESCRIPTOR in lookup_maybe_method() (GH-13865)

(which later was cherry-picked to the Python 3.8 branch). I do not understand how the Python MRO works, but this looks unrelated to what gcc-python-plugin does, and seems to just be an optimization... So it seemed likely to me that the plugin sets some flags inconsistently...

And I found one place that looked suspicious. Changing this as in the patch

--- a/generate-gimple-c.py
+++ b/generate-gimple-c.py
@@ -231,7 +231,7 @@ PyGccGimple_get_block(struct PyGccGimple *self, void *closure)
                           tp_str = '(reprfunc)PyGccGimple_str',
                           tp_hash = '(hashfunc)PyGccGimple_hash',
                           tp_richcompare = 'PyGccGimple_richcompare',
-                          tp_flags = 'Py_TPFLAGS_BASETYPE',
+                          tp_flags = '(Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE)',
                           )
     methods = PyMethodTable('PyGccGimple_methods', [])
     methods.add_method('walk_tree',

makes the plugin work again, although I have only tested with some simple scripts (using Python 3.9 and GCC 8.5).

@jmikedupont2
Copy link

Oh nice to see this patch, I did not see that before, my solution was to strip out the entire metaclass #192
I am going to try your patch as well.

@kristerw
Copy link

kristerw commented Sep 7, 2022

The Python problem giving us gcc.WrapperMeta errors was fixed in Python 3.9.13, and all versions of 3.10 seem to work too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants