Features/GccPythonPlugin

From FedoraProject

< Features(Difference between revisions)
Jump to: navigation, search
(User Experience: add gcc-with-python script)
(Contingency Plan)
Line 103: Line 103:
 
== Contingency Plan ==
 
== Contingency Plan ==
 
<!-- If you cannot complete your feature by the final development freeze, what is the backup plan?  This might be as simple as "None necessary, revert to previous release behaviour."  Or it might not.  If you feature is not completed in time we want to assure others that other parts of Fedora will not be in jeopardy.  -->
 
<!-- If you cannot complete your feature by the final development freeze, what is the backup plan?  This might be as simple as "None necessary, revert to previous release behaviour."  Or it might not.  If you feature is not completed in time we want to assure others that other parts of Fedora will not be in jeopardy.  -->
*
+
* We can simply remove the plugin.  This would impact [[Features/StaticAnalysisOfCPythonExtensions]]; see the contingency plan for that feature.
  
 
== Documentation ==
 
== Documentation ==

Revision as of 18:18, 11 July 2011


Contents

GCC Python Plugins

Summary

I have created a GCC plugin that embeds Python within GCC. Interested developers should be able to use this to easily extend GCC by writing Python scripts, such as adding new warnings for a library that they work on, without needing to use C.

Owner

  • Email: dmalcolm@redhat.com

Current status

  • Targeted release: Fedora 16
  • Last updated: 2011-07-11
  • Percentage of completion: 55%


Detailed Description

The plugins will allow interested developers to extend GCC in Python 2 and Python 3, without needing to deal with the C internals of GCC.

Example of potential uses include adding new compiler warnings based on:

  • GTK's reference-counting semantics
  • locking in the Linux kernel
  • signal-safety in APIs.
  • malloc/free usage (e.g. use-after-free bugs)
  • array boundary checks

I aim to use the feature to add compile-time checking of the source code to all CPython extension modules in Fedora, as described in Features/StaticAnalysisOfCPythonExtensions

Other ideas include:

  • visualizations of code structure
  • semantic grepping of source code (e.g. "find all invocations of C++ methods named 'draw' that use the default params")

There will be four GCC plugins:

  • a plugin embedding Python 2 (actually dynamically linked against libpython2.7.so)
  • a plugin embedding python 3 (actually dynamically linked against libpython3.2.so)
  • as above, but for the debug builds of Python 2 and Python 3, rather than the optimized builds.

The "upstream" for the plugins will be in this location: https://fedorahosted.org/gcc-python-plugin/

Benefit to Fedora

Fedora is already a very attractive platform for software development. By making it very easy to extend GCC, the plugin makes Fedora even more compelling to developers. The plugin code was written by a Fedora developer, and is a "Fedora Hosted" project.

Scope

This involves:

  • writing the plugin
  • packaging it
  • documenting it
  • keeping it in sync with gcc

How To Test

User Experience

Non-technical end-users of Fedora should see no difference.

Developers will be able to invoke Python scripts whilst running GCC by using a script that invokes gcc with the plugin:

gcc-with-python PATH_TO_SCRIPT.py rest of regular gcc args

for a Python 2 script and:

gcc-with-python3 PATH_TO_SCRIPT.py rest of regular gcc args

Alternatively, this is equivalent:

 gcc-with-python -fplugin=python2 -fplugin-arg-python2-script=PATH_TO_SCRIPT.py

for a Python 2 script and:

 gcc -fplugin=python3 -fplugin-arg-python3-script=PATH_TO_SCRIPT.py 

for a Python 3 script.

Dependencies

This will require working closely with the gcc maintainer. I anticipate needing to rebuild the plugin each time that gcc is rebuilt.

Contingency Plan

Documentation

API documentation for the plugin can be seen at http://readthedocs.org/docs/gcc-python-plugin/en/latest/index.html

Release Notes

  • GCC plugins that embed Python are now available. These were written by Fedora contributor David Malcolm and

Comments and Discussion