[gcc-python-plugin] 0.12-1: rebase to 0.12; large reorganization of package

dmalcolm dmalcolm at fedoraproject.org
Tue Apr 23 18:02:48 UTC 2013


commit c4563a935253946f05665142da1f74eaa7ba817b
Author: David Malcolm <dmalcolm at redhat.com>
Date:   Tue Apr 23 14:01:41 2013 -0400

    0.12-1: rebase to 0.12; large reorganization of package
    
    * Tue Apr 23 2013 David Malcolm <dmalcolm at redhat.com> - 0.12-1
    - 0.12, adding gcc-python-plugin-c-api subpackage, and 3 workarounds from
    upstream git (patch 2, patch 3, patch 4)
    - reorganize specfile to use the "make install" from upstream, and building
    each plugin from a separate srcdir
    - rename the debug plugins to use underscores rather than dashes in the
    names, since the latter appears to confuse GCC's option-parser

 .gitignore                                 |    1 +
 fix-3.3.0-iter-kwargs.patch                |   51 +++++++
 fix-graph-ordering.patch                   |   38 ++++++
 fix-test-plugin-sys-basename.patch         |   12 ++
 gcc-python-plugin-0.11-failing-tests.patch |   12 +-
 gcc-python-plugin.spec                     |  195 ++++++++++++++++++----------
 sources                                    |    2 +-
 7 files changed, 236 insertions(+), 75 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e067d0c..66f562e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
 /gcc-python-plugin-0.7.tar.gz
 /gcc-python-plugin-0.9.tar.gz
 /gcc-python-plugin-0.11.tar.gz
+/gcc-python-plugin-0.12.tar.gz
diff --git a/fix-3.3.0-iter-kwargs.patch b/fix-3.3.0-iter-kwargs.patch
new file mode 100644
index 0000000..6e5f2c0
--- /dev/null
+++ b/fix-3.3.0-iter-kwargs.patch
@@ -0,0 +1,51 @@
+commit f6ec7e2462357dfcbd1f65625ac939d4e815ce05
+Author: David Malcolm <dmalcolm at redhat.com>
+Date:   Mon Apr 15 20:14:47 2013 -0400
+
+    fix incompatibility with Python 3.3.0 (kwargs to ET.Element.iter)
+    
+    In 3.3 elementtree.Element.iter() is implemented in C, and in 3.3.0 the
+    relevant function Modules/_elementtree.c:elementtree_iter uses
+    PyArg_ParseTuple i.e. does not take keyword arguments.
+    
+    This is fixed in 3.3.1 via:
+      http://hg.python.org/cpython/rev/c1fc6b6d1cfc
+    but for now, remove keyword arguments from invocations of iter() to
+    assist compatibility.
+
+diff --git a/gcc-c-api/xmltypes.py b/gcc-c-api/xmltypes.py
+index 6b3a0b6..47fb801 100644
+--- a/gcc-c-api/xmltypes.py
++++ b/gcc-c-api/xmltypes.py
+@@ -129,11 +129,11 @@ class Type(XmlWrapper, HasDocsMixin):
+             raise NoInnerType(self)
+ 
+     def iter_attrs(self):
+-        for node in self.node.iter(tag='attribute'):
++        for node in self.node.iter('attribute'):
+             yield Attribute(self.api, node)
+ 
+     def iter_iters(self):
+-        for node in self.node.iter(tag='iterator'):
++        for node in self.node.iter('iterator'):
+             yield Iterator(self.api, node)
+ 
+ class Attribute(XmlWrapper, HasDocsMixin):
+@@ -202,7 +202,7 @@ class Function(XmlWrapper, HasDocsMixin):
+         return get_c_type(xml_kind);
+ 
+     def iter_params(self):
+-        for node in self.node.iter(tag='parameter'):
++        for node in self.node.iter('parameter'):
+             yield Parameter(self.api, node)
+ 
+ class Parameter(XmlWrapper, HasDocsMixin):
+@@ -242,7 +242,7 @@ class Api:
+             return None
+ 
+     def iter_types(self):
+-        for node in self.api.iter(tag='type'):
++        for node in self.api.iter('type'):
+             yield Type(self, node)
+ 
+     def lookup_type(self, xmlname):
diff --git a/fix-graph-ordering.patch b/fix-graph-ordering.patch
new file mode 100644
index 0000000..fd24276
--- /dev/null
+++ b/fix-graph-ordering.patch
@@ -0,0 +1,38 @@
+commit 58dca113481e9d392d599b871480765d551edd9c
+Author: David Malcolm <dmalcolm at redhat.com>
+Date:   Tue Apr 23 12:14:10 2013 -0400
+
+    Python 3 fixes to graph-handling (Node.__lt__ and Subgraph.__lt__)
+    
+    Python 3 changed how ordering works.  In particular, for instances of a
+    class to be sortable, the class needs at least a __lt__, or a
+       TypeError: unorderable types
+    will be raised.
+    
+    This led to the following tests failing with Python 3:
+      tests/examples/lto
+      tests/gccutils/graph
+    
+    Provide the missing __lt__ methods
+
+diff --git a/gccutils/graph/__init__.py b/gccutils/graph/__init__.py
+index 5361f74..b3516c3 100644
+--- a/gccutils/graph/__init__.py
++++ b/gccutils/graph/__init__.py
+@@ -279,6 +279,9 @@ class Node(object):
+         # Return a tuple of Subgraph instances
+         return ()
+ 
++    def __lt__(self, other):
++        return id(self) < id(other)
++
+ class Edge(object):
+     __slots__ = ('srcnode', 'dstnode')
+ 
+@@ -323,3 +326,6 @@ class Subgraph(object):
+ 
+     def __repr__(self):
+         return 'Subgraph(%r, %r)' % (self.id, self.label)
++
++    def __lt__(self, other):
++        return self.id < other.id
diff --git a/fix-test-plugin-sys-basename.patch b/fix-test-plugin-sys-basename.patch
new file mode 100644
index 0000000..9b90224
--- /dev/null
+++ b/fix-test-plugin-sys-basename.patch
@@ -0,0 +1,12 @@
+diff -up gcc-python-plugin-0.12/tests/plugin/sys/script.py.fix-plugin-basename gcc-python-plugin-0.12/tests/plugin/sys/script.py
+--- gcc-python-plugin-0.12/tests/plugin/sys/script.py.fix-plugin-basename	2013-04-15 20:55:57.000453673 -0400
++++ gcc-python-plugin-0.12/tests/plugin/sys/script.py	2013-04-15 20:56:23.290451877 -0400
+@@ -23,7 +23,7 @@ assert hasattr(sys, 'plugin_full_name')
+ assert os.path.exists(sys.plugin_full_name)
+ 
+ assert hasattr(sys, 'plugin_base_name')
+-assert sys.plugin_base_name == 'python' # for now
++assert sys.plugin_base_name.startswith('python') # for now
+ 
+ # Verify that the plugin's directory is in sys.path, as an absolute path:
+ plugin_dir = os.path.abspath(os.path.dirname(sys.plugin_full_name))
diff --git a/gcc-python-plugin-0.11-failing-tests.patch b/gcc-python-plugin-0.11-failing-tests.patch
index 8a2e309..8923cd6 100644
--- a/gcc-python-plugin-0.11-failing-tests.patch
+++ b/gcc-python-plugin-0.11-failing-tests.patch
@@ -1,9 +1,9 @@
-diff -up gcc-python-plugin-0.11/run-test-suite.py.failing-tests gcc-python-plugin-0.11/run-test-suite.py
---- gcc-python-plugin-0.11/run-test-suite.py.failing-tests	2012-11-29 15:45:25.996598071 -0500
-+++ gcc-python-plugin-0.11/run-test-suite.py	2012-11-29 15:47:43.018588701 -0500
-@@ -547,6 +547,24 @@ if sys.version_info[:2] == (3, 3):
-     exclude_test('tests/cpychecker/refcounts/combinatorial-explosion')
-     exclude_test('tests/cpychecker/refcounts/combinatorial-explosion-with-error')
+diff -up gcc-python-plugin-0.12/run-test-suite.py.failing-tests gcc-python-plugin-0.12/run-test-suite.py
+--- gcc-python-plugin-0.12/run-test-suite.py.failing-tests	2013-04-04 14:45:26.000000000 -0400
++++ gcc-python-plugin-0.12/run-test-suite.py	2013-04-05 17:48:13.116705549 -0400
+@@ -616,6 +616,24 @@ if GCC_VERSION >= 4008:
+     exclude_test('tests/cpychecker/refcounts/cplusplus/destructor')
+     exclude_test('tests/cpychecker/refcounts/cplusplus/empty-function')
  
 +# Tests failing with gcc-4.7.2-2.fc17.x86_64:
 +for test in ('''
diff --git a/gcc-python-plugin.spec b/gcc-python-plugin.spec
index 35f5176..a3d4bfb 100644
--- a/gcc-python-plugin.spec
+++ b/gcc-python-plugin.spec
@@ -42,8 +42,8 @@
 
 
 Name:           gcc-python-plugin
-Version:        0.11
-Release:        2%{?dist}
+Version:        0.12
+Release:        1%{?dist}
 Summary:        GCC plugin that embeds Python
 
 Group:          Development/Languages
@@ -55,6 +55,19 @@ Source0:        https://fedorahosted.org/releases/g/c/gcc-python-plugin/gcc-pyth
 #   https://fedorahosted.org/gcc-python-plugin/ticket/42
 Patch1: gcc-python-plugin-0.11-failing-tests.patch
 
+# Fix for 3.3.0 incompatibility
+# Taken from upstream commit f6ec7e2462357dfcbd1f65625ac939d4e815ce05
+Patch2: fix-3.3.0-iter-kwargs.patch
+
+# tests/plugin/sys/script.py expects the plugin basename to just be
+# "python".  Fix it up to allow the 4 builds we do
+# Taken from upstream commit a292074efee5c291d93a076af860e3ec3b10791f
+Patch3: fix-test-plugin-sys-basename.patch
+
+# Fix for a couple of testsuite failures with Python 3, taken from upstream
+# commit 58dca113481e9d392d599b871480765d551edd9c
+Patch4: fix-graph-ordering.patch
+
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  gcc-plugin-devel
@@ -88,6 +101,19 @@ BuildRequires: python3-pygments
 %description
 Plugins for embedding various versions of Python within GCC
 
+%package -n gcc-python-plugin-c-api
+Summary: Shared library to make it easier to write GCC plugins
+Group:   Development/Languages
+
+%description -n gcc-python-plugin-c-api
+Shared library to make it easier to write GCC plugins
+
+%if %{with_hard_gcc_version_requirement}
+Requires: gcc = %{gcc_vr}
+%else
+Requires: gcc
+%endif
+
 %package -n gcc-python2-plugin
 Summary: GCC plugin embedding Python 2
 Group:   Development/Languages
@@ -98,6 +124,7 @@ Requires: gcc = %{gcc_vr}
 %else
 Requires: gcc
 %endif
+Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
 
 %description  -n gcc-python2-plugin
 GCC plugin embedding Python 2
@@ -112,6 +139,7 @@ Requires: gcc = %{gcc_vr}
 %else
 Requires: gcc
 %endif
+Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
 
 %description  -n gcc-python3-plugin
 GCC plugin embedding Python 3
@@ -126,6 +154,7 @@ Requires: gcc = %{gcc_vr}
 %else
 Requires: gcc
 %endif
+Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
 
 %description  -n gcc-python2-debug-plugin
 GCC plugin embedding debug build of Python 2
@@ -140,6 +169,7 @@ Requires: gcc = %{gcc_vr}
 %else
 Requires: gcc
 %endif
+Requires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}
 
 %description  -n gcc-python3-debug-plugin
 GCC plugin embedding debug build of Python 3
@@ -156,6 +186,36 @@ This package contains API documentation for the GCC Python plugin
 %prep
 %setup -q
 %patch1 -p1 -b .failing-tests
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+
+# We will be building the plugin 4 times, each time against a different
+# Python runtime
+#
+# The plugin doesn't yet cleanly support srcdir != builddir, so for now
+# make 4 separate copies of the source, once for each build
+
+PrepPlugin() {
+    PluginName=$1
+
+    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
+
+    rm -rf $BuildDir
+    cp -a . $BuildDir
+}
+
+PrepPlugin \
+  python2
+
+PrepPlugin \
+  python2_debug
+
+PrepPlugin \
+  python3
+
+PrepPlugin \
+  python3_debug
 
 %build
 
@@ -167,15 +227,18 @@ BuildPlugin() {
     PluginDso=$3
     PluginName=$4
 
-    # "make clean" would remove the .so files from the previous build
-    rm -f *.o
+    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
+
+    pushd $BuildDir
     make \
        %{?_smp_mflags} \
+       PLUGIN_NAME=$PluginName \
+       PLUGIN_DSO=$PluginDso \
        PYTHON=$PythonExe \
        PYTHON_CONFIG=$PythonConfig \
        PLUGIN_PYTHONPATH=%{gcc_plugins_dir}/$PluginName \
-       plugin
-    mv python.so $PluginDso
+       plugin print-gcc-version
+    popd
 }
 
 BuildPlugin \
@@ -187,8 +250,8 @@ BuildPlugin \
 BuildPlugin \
   python-debug \
   python-debug-config \
-  python2-debug.so \
-  python2-debug
+  python2_debug.so \
+  python2_debug
 
 BuildPlugin \
   python3 \
@@ -199,8 +262,8 @@ BuildPlugin \
 BuildPlugin \
   python3-debug \
   %{python3_debug_config} \
-  python3-debug.so \
-  python3-debug
+  python3_debug.so \
+  python3_debug
 
 # Documentation:
 cd docs
@@ -223,44 +286,18 @@ InstallPlugin() {
     PluginDso=$3
     PluginName=$4
 
-    cp $PluginDso $RPM_BUILD_ROOT/%{gcc_plugins_dir}
-
-    # Install support files into the correct location:
-    PluginDir=$PluginName
-    mkdir $RPM_BUILD_ROOT/%{gcc_plugins_dir}/$PluginDir
-    cp -a gccutils.py $RPM_BUILD_ROOT/%{gcc_plugins_dir}/$PluginDir
-    cp -a libcpychecker $RPM_BUILD_ROOT/%{gcc_plugins_dir}/$PluginDir
-
-    # Create "gcc-with-" support script:
-    install -m 755 gcc-with-python $RPM_BUILD_ROOT/%{_bindir}/gcc-with-$PluginName
-    # Fixup the reference to the plugin in that script, from being expressed as
-    # a DSO filename with a path (for a working copy) to a name of an installed
-    # plugin within GCC's search directory:
-    sed \
-       -i \
-       -e"s|-fplugin=[^ ]*|-fplugin=$PluginName|" \
-       $RPM_BUILD_ROOT/%{_bindir}/gcc-with-$PluginName
-
-    # Fixup the plugin name within -fplugin-arg-PLUGIN_NAME-script to match the
-    # name for this specific build:
-    sed \
-       -i \
-       -e"s|-fplugin-arg-python-script|-fplugin-arg-$PluginName-script|" \
-       $RPM_BUILD_ROOT/%{_bindir}/gcc-with-$PluginName
-
-    # Fixup the generic manpage for this build:
-    cp docs/_build/man/gcc-with-python.1 gcc-with-$PluginName.1
-    sed \
-        -i \
-        -e"s|gcc-with-python|gcc-with-$PluginName|g" \
-        gcc-with-$PluginName.1
-    UpperPluginName=$(python -c"print('$PluginName'.upper())")
-    sed \
-        -i \
-        -e"s|GCC-WITH-PYTHON|GCC-WITH-$UpperPluginName|g" \
-        gcc-with-$PluginName.1
-    gzip gcc-with-$PluginName.1
-    cp gcc-with-$PluginName.1.gz  $RPM_BUILD_ROOT/%{_mandir}/man1
+    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
+
+    pushd $BuildDir
+    make install \
+        DESTDIR=$RPM_BUILD_ROOT \
+        PLUGIN_NAME=$PluginName \
+        PLUGIN_DSO=$PluginDso
+    popd
+
+    # (doing the above actually installs each build's copy of libgccapi.so,
+    # all to the same location, but they should all be identical, so that's
+    # OK)
 }
 
 InstallPlugin \
@@ -272,8 +309,8 @@ InstallPlugin \
 InstallPlugin \
   python-debug \
   python-debug-config \
-  python2-debug.so \
-  python2-debug
+  python2_debug.so \
+  python2_debug
 
 InstallPlugin \
   python3 \
@@ -284,8 +321,8 @@ InstallPlugin \
 InstallPlugin \
   python3-debug \
   %{python3_debug_config} \
-  python3-debug.so \
-  python3-debug
+  python3_debug.so \
+  python3_debug
 
 
 %clean
@@ -297,16 +334,23 @@ CheckPlugin() {
     PythonExe=$1
     PythonConfig=$2
     PluginDso=$3
-    SelftestArgs=$4
+    PluginName=$4
+    SelftestArgs=$5
+
+    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName
 
-    # Copy the specific build of the plugin back into the location where
-    # the selftests expect it:
-    cp $PluginDso python.so
+    pushd $BuildDir
 
     # Run the selftests:
-    $PythonExe run-test-suite.py $SelftestArgs
+    LD_LIBRARY_PATH=gcc-c-api \
+    PLUGIN_NAME=$PluginName \
+        $PythonExe run-test-suite.py $SelftestArgs
 
-    $PythonExe testcpychecker.py -v
+    LD_LIBRARY_PATH=gcc-c-api \
+    PLUGIN_NAME=$PluginName \
+        $PythonExe testcpychecker.py -v
+
+    popd
 }
 
 # Selftest for python2 (optimized) build
@@ -315,6 +359,7 @@ CheckPlugin \
   python \
   python-config \
   python2.so \
+  python2 \
   %{nil}
 
 # Selftest for python2-debug build:
@@ -333,7 +378,8 @@ CheckPlugin \
 CheckPlugin \
   python-debug \
   python-debug-config \
-  python2-debug.so \
+  python2_debug.so \
+  python2_debug \
   "-x tests/cpychecker"
 
 # Selftest for python3 (optimized) build:
@@ -353,6 +399,7 @@ CheckPlugin \
   python3 \
   python3-config \
   python3.so \
+  python3 \
   "-x tests/cpychecker"
 
 # Selftest for python3-debug build:
@@ -360,9 +407,13 @@ CheckPlugin \
 CheckPlugin \
   python3-debug \
   %{python3_debug_config} \
-  python3-debug.so \
+  python3_debug.so \
+  python3_debug \
   "-x tests/cpychecker"
 
+%files -n gcc-python-plugin-c-api
+%{gcc_plugins_dir}/libgcc-c-api.so
+
 %files -n gcc-python2-plugin
 %defattr(-,root,root,-)
 %doc COPYING README.rst
@@ -382,18 +433,18 @@ CheckPlugin \
 %files -n gcc-python2-debug-plugin
 %defattr(-,root,root,-)
 %doc COPYING README.rst
-%{_bindir}/gcc-with-python2-debug
-%{gcc_plugins_dir}/python2-debug.so
-%{gcc_plugins_dir}/python2-debug
-%doc %{_mandir}/man1/gcc-with-python2-debug.1.gz
+%{_bindir}/gcc-with-python2_debug
+%{gcc_plugins_dir}/python2_debug.so
+%{gcc_plugins_dir}/python2_debug
+%doc %{_mandir}/man1/gcc-with-python2_debug.1.gz
 
 %files -n gcc-python3-debug-plugin
 %defattr(-,root,root,-)
 %doc COPYING README.rst
-%{_bindir}/gcc-with-python3-debug
-%{gcc_plugins_dir}/python3-debug.so
-%{gcc_plugins_dir}/python3-debug
-%doc %{_mandir}/man1/gcc-with-python3-debug.1.gz
+%{_bindir}/gcc-with-python3_debug
+%{gcc_plugins_dir}/python3_debug.so
+%{gcc_plugins_dir}/python3_debug
+%doc %{_mandir}/man1/gcc-with-python3_debug.1.gz
 
 %files docs
 %defattr(-,root,root,-)
@@ -403,6 +454,14 @@ CheckPlugin \
 %doc examples
 
 %changelog
+* Tue Apr 23 2013 David Malcolm <dmalcolm at redhat.com> - 0.12-1
+- 0.12, adding gcc-python-plugin-c-api subpackage, and 3 workarounds from
+upstream git (patch 2, patch 3, patch 4)
+- reorganize specfile to use the "make install" from upstream, and building
+each plugin from a separate srcdir
+- rename the debug plugins to use underscores rather than dashes in the
+names, since the latter appears to confuse GCC's option-parser
+
 * Wed Feb 13 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.11-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
 
diff --git a/sources b/sources
index 24b5f28..c421f54 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-539a598316456db2f89e5ed03e56de9e  gcc-python-plugin-0.11.tar.gz
+0ecff018b65fea00ffa9075260031c44  gcc-python-plugin-0.12.tar.gz


More information about the scm-commits mailing list