davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
199 stars 58 forks source link

gcc.Block.vars no longer contains unused globals in gcc 4.7 #61

Closed davidmalcolm closed 7 years ago

davidmalcolm commented 7 years ago

Am testing with gcc 4.7; specifically with Fedora's: gcc-4.7.0-0.2.fc17.x86_64

cpychecker fails with numerous errors where it tries to look up global exception objects, where {{{ exc_decl = gccutils.get_global_vardecl_by_name(exc_name) }}} is returning None

For example, it doesn't find the: {{{ PyAPI_DATA(PyObject *) PyExc_MemoryError; }}} as a gcc.VarDecl within the block's "vars" attribute.

Upon debugging, this appears to be due to this changed line in gcc/c-decl.c: in 4.7.0: {{{ else if (VAR_OR_FUNCTION_DECL_P (p) && scope != file_scope) }}} in 4.6.1: {{{ else if (VAR_OR_FUNCTION_DECL_P (p)) }}}

which seems to have been GCC's PR debug/51410:

davidmalcolm commented 7 years ago

Imported from trac issue 21. Created by dmalcolm on 2012-01-05T07:47:35, last modified: 2012-03-06T11:36:06

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2012-01-05 07:53:35:

GCC's PR debug/51410 is http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51410

This appears to have been backported to 4.6 in SVN, so is likely to eventually start affecting us in 4.6 also: http://gcc.gnu.org/viewcvs?view=revision&revision=182114

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2012-01-05 11:20:56:

I've emailed the gcc mailing list about this: http://gcc.gnu.org/ml/gcc/2012-01/msg00045.html

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2012-02-03 12:14:09:

Fixed in e076c096ce9888bc38192c42676505ec712599d8 by using PLUGIN_FINISH_DECL under 4.7, and the old implementation under 4.6

[This will still break under versions of 4.6 that have the backport of the change, but hopefully this fix is enough for now]

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2012-03-06 11:36:06:

Fedora 16 recently bumped its gcc 4.6.* to 4.6.3, and this brought in PR debug/51410, and led to the rebuild of the plugin package failing: http://koji.fedoraproject.org/koji/getfile?taskID=3858275&name=build.log