Skip to content

DRAFT removing the Wrapper metaclass for python 3.9. resolves TypeError: 'gcc.WrapperMeta' object is not iterable #192

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ GENERATOR_DEPS=cpybuilder.py wrapperbuilder.py print-gcc-version
# make PYTHON=python3 PYTHON_CONFIG=python3-config all

# The python interpreter to use:
PYTHON=python
PYTHON=~/.pyenv/versions/3.9-dev/bin/python3
# The python-config executable to use:
PYTHON_CONFIG=python-config
PYTHON_CONFIG=~/.pyenv/versions/3.9-dev/bin/python3-config

#PYTHON=python3
#PYTHON_CONFIG=python3-config
Expand All @@ -106,6 +106,9 @@ PYTHON_CONFIG=python-config
PYTHON_INCLUDES=$(shell $(PYTHON_CONFIG) --includes)
PYTHON_LIBS=$(shell $(PYTHON) -c 'import sys;print("-lpython%d.%d" % sys.version_info[:2])') $(shell $(PYTHON_CONFIG) --libs)

#PYTHON_LDFLAGS=$(shell $(PYTHON_CONFIG) --ldflags)
PYTHON_LDFLAGS=-L/root/.pyenv/versions/3.9-dev/lib/python3.9/config-3.9-x86_64-linux-gnu -L/root/.pyenv/versions/3.9-dev/lib -lcrypt -lpthread -ldl -lutil -lm -lm

# Support having multiple named plugins
# e.g. "python2.7" "python3.2mu" "python 3.2dmu" etc:
PLUGIN_NAME := python
Expand All @@ -121,7 +124,8 @@ CPPFLAGS+= -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I.
# and choose debugging information level.
CFLAGS?=-O2 -Werror -g
# Force these settings
CFLAGS+= -fPIC -fno-strict-aliasing -Wall
CFLAGS+= -fPIC# after any initial comment lines

LIBS+= $(PYTHON_LIBS)
ifneq "$(PLUGIN_PYTHONPATH)" ""
CPPFLAGS+= -DPLUGIN_PYTHONPATH='"$(PLUGIN_PYTHONPATH)"'
Expand All @@ -147,7 +151,7 @@ INVOCATION_ENV_VARS := PYTHONPATH=$(srcdir)./ CC_FOR_CPYCHECKER=$(CC) LD_LIBRARY
#
$(PLUGIN_DSO): $(PLUGIN_OBJECT_FILES) $(LIBGCC_C_API_SO)
$(CC) \
$(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
$(CPPFLAGS) $(CFLAGS) $(PYTHON_LDFLAGS) $(LDFLAGS) \
-shared \
$(PLUGIN_OBJECT_FILES) \
-o $@ \
Expand Down
2 changes: 1 addition & 1 deletion docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ Debugging your script
---------------------

You can place a forced breakpoint in your script using this standard Python
one-liner::
one-lxiner::

import pdb; pdb.set_trace()

Expand Down
2 changes: 1 addition & 1 deletion gcc-python-option.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PyGccOption_init(PyGccOption * self, PyObject *args, PyObject *kwargs)
/*
We need to call _track manually as we're not using PyGccWrapper_New():
*/
PyGccWrapper_Track(&self->head);
//PyGccWrapper_Track(&self->head);

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", (char**)kwlist,
&text)) {
Expand Down
20 changes: 10 additions & 10 deletions gcc-python-pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ do_pass_init(PyObject *s, PyObject *args, PyObject *kwargs,
/*
We need to call _track manually as we're not using PyGccWrapper_New():
*/
PyGccWrapper_Track(&self->head);
//PyGccWrapper_Track(&self->head);

if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"s:gcc.Pass.__init__", (char**)keywords,
Expand Down Expand Up @@ -647,16 +647,16 @@ get_type_for_pass_type(enum opt_pass_type pt)
default: assert(0);

case GIMPLE_PASS:
return &PyGccGimplePass_TypeObj;
return &PyGccGimplePass_TypeObj;

case RTL_PASS:
return &PyGccRtlPass_TypeObj;
return &PyGccRtlPass_TypeObj;

case SIMPLE_IPA_PASS:
return &PyGccSimpleIpaPass_TypeObj;
return &PyGccSimpleIpaPass_TypeObj;

case IPA_PASS:
return &PyGccIpaPass_TypeObj;
return &PyGccIpaPass_TypeObj;
}
};

Expand All @@ -669,7 +669,7 @@ real_make_pass_wrapper(void *p)
struct PyGccPass *pass_obj = NULL;

if (NULL == pass) {
Py_RETURN_NONE;
Py_RETURN_NONE;
}

type_obj = get_type_for_pass_type(pass->type);
Expand All @@ -683,7 +683,7 @@ real_make_pass_wrapper(void *p)
/* FIXME: do we need to do something for the GCC GC? */

return (PyObject*)pass_obj;

error:
return NULL;
}
Expand All @@ -702,12 +702,12 @@ PyObject *
PyGccPass_New(struct opt_pass *pass)
{
return PyGcc_LazilyCreateWrapper(&pass_wrapper_cache,
pass,
real_make_pass_wrapper);
pass,
real_make_pass_wrapper);
}

/*
PEP-7
PEP-7
Local variables:
c-basic-offset: 4
indent-tabs-mode: nil
Expand Down
4 changes: 2 additions & 2 deletions gcc-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ plugin_init (struct plugin_name_args *plugin_info,

PyGcc_globals.module = PyImport_ImportModule("gcc");

PyEval_InitThreads();
// PyEval_InitThreads(); This is deprecated

if (!PyGcc_init_gcc_module(plugin_info)) {
return 1;
Expand All @@ -804,7 +804,7 @@ plugin_init (struct plugin_name_args *plugin_info,
return 1;
}

/* Init other modules */
/* Init otherOA modules */
PyGcc_wrapper_init();

/* FIXME: properly integrate them within the module hierarchy */
Expand Down
3 changes: 2 additions & 1 deletion gcc-python.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ extern PyTypeObject PyGccWrapperMeta_TypeObj;
ARG_fieldname:
the name of the field within the CPython struct, containing the pointer
to the GCC data

struct PyGccWrapper head;
*/
#define DECLARE_SIMPLE_WRAPPER(ARG_structname, ARG_typeobj, ARG_typename, ARG_wrappedtype, ARG_fieldname) \
struct ARG_structname { \
struct PyGccWrapper head; \
ARG_wrappedtype ARG_fieldname; \
}; \
\
Expand Down
2 changes: 1 addition & 1 deletion gcc-with-python
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.

${CC:-gcc} -fplugin=$(pwd)/python.so -fplugin-arg-python-script=$@
gdb ${CC:-gcc} -fplugin=$(pwd)/python.so -fplugin-arg-python-script=$@
4 changes: 3 additions & 1 deletion wrapperbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class PyGccWrapperTypeObject(PyTypeObject):
"""
def __init__(self, *args, **kwargs):
PyTypeObject.__init__(self, *args, **kwargs)
self.ob_type = '&PyGccWrapperMeta_TypeObj'
# TODO make more dynamic here
# self.ob_type = '&PyGccWrapperMeta_TypeObj'
self.ob_type = 'NULL'

def c_defn(self):
result = '\n'
Expand Down