diff --git a/0001-Fix-Ruby-tracking-code-to-use-C-hash.patch b/0001-Fix-Ruby-tracking-code-to-use-C-hash.patch new file mode 100644 index 0000000..06e3d44 --- /dev/null +++ b/0001-Fix-Ruby-tracking-code-to-use-C-hash.patch @@ -0,0 +1,204 @@ +From 84d26240922e5f5b4c0365b0348e856c3c6aaf84 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= +Date: Thu, 3 Jan 2013 11:56:25 +0100 +Subject: [PATCH] Fix Ruby tracking code to use C hash + +Patch id #330 + This is a patch to resolve bug #2034216. + The bug is that the tracking code uses a ruby hash and thus may + allocate objects (Bignum) while running the GC. This was tolerated in + 1.8 but is invalid (raises an exception) in 1.9. + The patch uses a C hash (also used by ruby) instead. +--- + Lib/ruby/rubytracking.swg | 129 ++++++++++++++++++--------------------------- + 1 file changed, 50 insertions(+), 79 deletions(-) + +diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg +index 0a36f4a..02e92ad 100644 +--- a/Lib/ruby/rubytracking.swg ++++ b/Lib/ruby/rubytracking.swg +@@ -22,19 +22,19 @@ extern "C" { + # error sizeof(void*) is not the same as long or long long + #endif + +- +-/* Global Ruby hash table to store Trackings from C/C++ ++/* Global hash table to store Trackings from C/C++ + structs to Ruby Objects. + */ +-static VALUE swig_ruby_trackings = Qnil; ++static st_table* swig_ruby_trackings = NULL; ++ ++VALUE get_swig_trackings_count(ANYARGS) { ++ return SWIG2NUM(swig_ruby_trackings->num_entries); ++} + +-/* Global variable that stores a reference to the ruby +- hash table delete function. */ +-static ID swig_ruby_hash_delete; + +-/* Setup a Ruby hash table to store Trackings */ ++/* Setup a hash table to store Trackings */ + SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { +- /* Create a ruby hash table to store Trackings from C++ ++ /* Create a hash table to store Trackings from C++ + objects to Ruby objects. */ + + /* Try to see if some other .so has already created a +@@ -43,87 +43,47 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { + This is done to allow multiple DSOs to share the same + tracking table. + */ +- ID trackings_id = rb_intern( "@__trackings__" ); ++ VALUE trackings_value = Qnil; ++ /* change the variable name so that we can mix modules ++ compiled with older SWIG's */ ++ ID trackings_id = rb_intern( "@__safetrackings__" ); + VALUE verbose = rb_gv_get("VERBOSE"); + rb_gv_set("VERBOSE", Qfalse); +- swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); ++ trackings_value = rb_ivar_get( _mSWIG, trackings_id ); + rb_gv_set("VERBOSE", verbose); + +- /* No, it hasn't. Create one ourselves */ +- if ( swig_ruby_trackings == Qnil ) +- { +- swig_ruby_trackings = rb_hash_new(); +- rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); +- } +- +- /* Now store a reference to the hash table delete function +- so that we only have to look it up once.*/ +- swig_ruby_hash_delete = rb_intern("delete"); +-} +- +-/* Get a Ruby number to reference a pointer */ +-SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { +- /* We cast the pointer to an unsigned long +- and then store a reference to it using +- a Ruby number object. */ +- +- /* Convert the pointer to a Ruby number */ +- return SWIG2NUM(ptr); +-} +- +-/* Get a Ruby number to reference an object */ +-SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { +- /* We cast the object to an unsigned long +- and then store a reference to it using +- a Ruby number object. */ +- +- /* Convert the Object to a Ruby number */ +- return SWIG2NUM(object); +-} +- +-/* Get a Ruby object from a previously stored reference */ +-SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { +- /* The provided Ruby number object is a reference +- to the Ruby object we want.*/ +- +- /* Convert the Ruby number to a Ruby object */ +- return NUM2SWIG(reference); ++ /* The trick here is that we have to store the hash table ++ pointer in a Ruby variable. We do not want Ruby's GC to ++ treat this pointer as a Ruby object, so we convert it to ++ a Ruby numeric value. */ ++ if (trackings_value == Qnil) { ++ /* No, it hasn't. Create one ourselves */ ++ swig_ruby_trackings = st_init_numtable(); ++ rb_ivar_set( _mSWIG, trackings_id, SWIG2NUM(swig_ruby_trackings) ); ++ } ++ else { ++ swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); ++ } ++ ++ rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", get_swig_trackings_count, NULL); + } + + /* Add a Tracking from a C/C++ struct to a Ruby object */ + SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { +- /* In a Ruby hash table we store the pointer and +- the associated Ruby object. The trick here is +- that we cannot store the Ruby object directly - if +- we do then it cannot be garbage collected. So +- instead we typecast it as a unsigned long and +- convert it to a Ruby number object.*/ +- +- /* Get a reference to the pointer as a Ruby number */ +- VALUE key = SWIG_RubyPtrToReference(ptr); +- +- /* Get a reference to the Ruby object as a Ruby number */ +- VALUE value = SWIG_RubyObjectToReference(object); +- + /* Store the mapping to the global hash table. */ +- rb_hash_aset(swig_ruby_trackings, key, value); ++ st_insert(swig_ruby_trackings, (st_data_t)ptr, object); + } + + /* Get the Ruby object that owns the specified C/C++ struct */ + SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { +- /* Get a reference to the pointer as a Ruby number */ +- VALUE key = SWIG_RubyPtrToReference(ptr); +- + /* Now lookup the value stored in the global hash table */ +- VALUE value = rb_hash_aref(swig_ruby_trackings, key); +- +- if (value == Qnil) { +- /* No object exists - return nil. */ +- return Qnil; ++ VALUE value; ++ ++ if (st_lookup(swig_ruby_trackings, (st_data_t)ptr, &value)) { ++ return value; + } + else { +- /* Convert this value to Ruby object */ +- return SWIG_RubyReferenceToObject(value); ++ return Qnil; + } + } + +@@ -132,12 +92,8 @@ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { + since the same memory address may be reused later to create + a new object. */ + SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { +- /* Get a reference to the pointer as a Ruby number */ +- VALUE key = SWIG_RubyPtrToReference(ptr); +- +- /* Delete the object from the hash table by calling Ruby's +- do this we need to call the Hash.delete method.*/ +- rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); ++ /* Delete the object from the hash table */ ++ st_delete(swig_ruby_trackings, (st_data_t *)&ptr, NULL); + } + + /* This is a helper method that unlinks a Ruby object from its +@@ -147,10 +103,25 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { + VALUE object = SWIG_RubyInstanceFor(ptr); + + if (object != Qnil) { ++ if (TYPE(object) != T_DATA) ++ abort(); + DATA_PTR(object) = 0; + } + } + ++/* This is a helper method that iterates over all the trackings ++ passing the C++ object pointer and its related Ruby object ++ to the passed callback function. */ ++ ++/* Proxy method to abstract the internal trackings datatype */ ++static int _ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) { ++ (*meth)(ptr, obj); ++ return ST_CONTINUE; ++} ++ ++SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { ++ st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&_ruby_internal_iterate_callback, (st_data_t)meth); ++} + + #ifdef __cplusplus + } +-- +1.7.10.4 + diff --git a/0008-Ruby-Disable-broken-tests.patch b/0008-Ruby-Disable-broken-tests.patch deleted file mode 100644 index c5f671c..0000000 --- a/0008-Ruby-Disable-broken-tests.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs -x Makefile ../orig-swig-2.0.9_svn13971/Examples/test-suite/ruby/Makefile.in ./Examples/test-suite/ruby/Makefile.in ---- ../orig-swig-2.0.9_svn13971/Examples/test-suite/ruby/Makefile.in 2012-12-14 15:07:32.956499000 +0100 -+++ ./Examples/test-suite/ruby/Makefile.in 2012-12-16 14:13:30.024200036 +0100 -@@ -14,18 +14,18 @@ - li_cdata \ - li_cstring \ - li_factory \ -- li_std_functors \ - li_std_multimap \ - li_std_pair_lang_object \ - li_std_queue \ -- li_std_set \ - li_std_stack \ - primitive_types \ - ruby_keywords \ - ruby_naming \ - ruby_track_objects \ -- ruby_track_objects_directors \ -- std_containers -+ ruby_track_objects_directors -+# std_containers -+# li_std_functors -+# li_std_set - # ruby_li_std_speed - # stl_new - diff --git a/0012-Python-Disable-broken-test-in-threads_exception.patch b/0012-Python-Disable-broken-test-in-threads_exception.patch deleted file mode 100644 index bddb0d0..0000000 --- a/0012-Python-Disable-broken-test-in-threads_exception.patch +++ /dev/null @@ -1,27 +0,0 @@ -From a413c263f0a84a19ff1090db9c74928fe3835214 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= -Date: Sat, 26 May 2012 22:39:40 +0200 -Subject: [PATCH 12/12] Python: Disable broken test in threads_exception - ---- - .../test-suite/python/threads_exception_runme.py | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py -index 12202e3..f8fb46e 100644 ---- a/Examples/test-suite/python/threads_exception_runme.py -+++ b/Examples/test-suite/python/threads_exception_runme.py -@@ -25,8 +25,8 @@ try: - except threads_exception.Exc,e: - if e.code != 42: - raise RuntimeError -- if e.msg != "Hosed": -- raise RuntimeError, "bad... msg: %s" % e.msg -+# if e.msg != "Hosed": -+# raise RuntimeError, "bad... msg: %s" % e.msg - - for i in range(1,4): - try: --- -1.7.9.2 - diff --git a/python-2.4.patch b/python-2.4.patch deleted file mode 100644 index dada08b..0000000 --- a/python-2.4.patch +++ /dev/null @@ -1,60 +0,0 @@ -diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs -x Makefile -x Makefile.in ../orig-swig-2.0.8/Examples/test-suite/python/autodoc_runme.py ./Examples/test-suite/python/autodoc_runme.py ---- ../orig-swig-2.0.8/Examples/test-suite/python/autodoc_runme.py 2012-04-15 23:56:38.000000000 +0200 -+++ ./Examples/test-suite/python/autodoc_runme.py 2012-12-12 14:04:02.873907051 +0100 -@@ -121,23 +121,6 @@ - " " - ) - --check(A.variable_a.__doc__, "A_variable_a_get(self) -> int") --check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int") --check(A.variable_c.__doc__, "\n" --"A_variable_c_get(self) -> int\n" --"\n" --"Parameters:\n" --" self: A *\n" --"\n" --) --check(A.variable_d.__doc__, "\n" --"A_variable_d_get(A self) -> int\n" --"\n" --"Parameters:\n" --" self: A *\n" --"\n" --) -- - check(B.__doc__, "Proxy of C++ B class") - check(C.__init__.__doc__, "__init__(self, a, b, h) -> C") - check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D") -diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs -x Makefile -x Makefile.in ../orig-swig-2.0.8/Lib/python/pyhead.swg ./Lib/python/pyhead.swg ---- ../orig-swig-2.0.8/Lib/python/pyhead.swg 2012-08-15 09:48:57.000000000 +0200 -+++ ./Lib/python/pyhead.swg 2012-12-11 13:21:24.686950170 +0100 -@@ -18,6 +18,10 @@ - - #endif - -+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 4 -+#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) -+#endif -+ - #ifndef Py_TYPE - # define Py_TYPE(op) ((op)->ob_type) - #endif -diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs -x Makefile ../orig-swig-2.0.9/Examples/test-suite/python/Makefile.in ./Examples/test-suite/python/Makefile.in ---- ../orig-swig-2.0.9/Examples/test-suite/python/Makefile.in 2012-04-14 23:11:19.000000000 +0200 -+++ ./Examples/test-suite/python/Makefile.in 2012-12-18 16:23:46.138238704 +0100 -@@ -46,7 +46,6 @@ - li_cwstring \ - li_factory \ - li_implicit \ -- li_std_containers_int \ - li_std_map_member \ - li_std_multimap \ - li_std_pair_extra \ -@@ -69,6 +68,7 @@ - swigobject \ - template_matrix - -+# li_std_containers_int - # li_std_carray - # director_profile - # python_pybuf diff --git a/ruby-1.8.6-newobject.patch b/ruby-1.8.6-newobject.patch new file mode 100644 index 0000000..2e90626 --- /dev/null +++ b/ruby-1.8.6-newobject.patch @@ -0,0 +1,10 @@ +diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs -x Makefile -x Makefile ../orig-swig-2.0.10/Examples/test-suite/ruby/newobject1_runme.rb ./Examples/test-suite/ruby/newobject1_runme.rb +--- ../orig-swig-2.0.10/Examples/test-suite/ruby/newobject1_runme.rb 2013-05-27 20:24:04.000000000 +0200 ++++ ./Examples/test-suite/ruby/newobject1_runme.rb 2013-05-29 09:55:57.922485272 +0200 +@@ -29,5 +29,5 @@ + GC.stats if $VERBOSE + swig_assert( 'Foo.fooCount == 200', binding, "but is #{Foo.fooCount}" ) + GC.start +-swig_assert( 'Foo.fooCount <= 2', binding, "but is #{Foo.fooCount}" ) ++swig_assert( 'Foo.fooCount <= 3', binding, "but is #{Foo.fooCount}" ) + diff --git a/ruby-2.0-encoding-utf8.patch b/ruby-2.0-encoding-utf8.patch new file mode 100644 index 0000000..78ea5d5 --- /dev/null +++ b/ruby-2.0-encoding-utf8.patch @@ -0,0 +1,12 @@ +diff -wruN -x '*~' -x '*.o' -x '*.a' -x '*.so' -x '*.so.[0-9]' -x autom4te.cache -x .deps -x .libs -x Makefile -x Makefile ../orig-swig-2.0.10/Examples/test-suite/ruby/char_constant_runme.rb ./Examples/test-suite/ruby/char_constant_runme.rb +--- ../orig-swig-2.0.10/Examples/test-suite/ruby/char_constant_runme.rb 2013-05-27 20:24:04.000000000 +0200 ++++ ./Examples/test-suite/ruby/char_constant_runme.rb 2013-05-28 14:48:44.924421929 +0200 +@@ -28,7 +28,7 @@ + raise RuntimeError, "Invalid value for NULL_CONST." + end + +-if Char_constant::SPECIALCHAR != "\341" #'á' ++if Char_constant::SPECIALCHAR.ord != 225 # "\341" #'á' + raise RuntimeError, "Invalid value for SPECIALCHAR." + end + diff --git a/skip-python-li_std_containers_int.patch b/skip-python-li_std_containers_int.patch deleted file mode 100644 index 50272af..0000000 --- a/skip-python-li_std_containers_int.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -wruN -x '*~' ../orig-swig-2.0.9/Examples/test-suite/python/Makefile.in ./Examples/test-suite/python/Makefile.in ---- ../orig-swig-2.0.9/Examples/test-suite/python/Makefile.in 2012-04-14 23:11:19.000000000 +0200 -+++ ./Examples/test-suite/python/Makefile.in 2012-12-19 15:12:29.072322715 +0100 -@@ -46,7 +46,6 @@ - li_cwstring \ - li_factory \ - li_implicit \ -- li_std_containers_int \ - li_std_map_member \ - li_std_multimap \ - li_std_pair_extra \ -@@ -69,6 +68,7 @@ - swigobject \ - template_matrix - -+# li_std_containers_int - # li_std_carray - # director_profile - # python_pybuf diff --git a/swig-2.0.10.tar.gz b/swig-2.0.10.tar.gz new file mode 100644 index 0000000..000d82a --- /dev/null +++ b/swig-2.0.10.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1eef329e867124ce60838b5ad07c763146b6c8f250dd22a861ead7406f78e63 +size 5302787 diff --git a/swig-2.0.9.tar.gz b/swig-2.0.9.tar.gz deleted file mode 100644 index c3b19d2..0000000 --- a/swig-2.0.9.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:586954000d297fafd7e91d1ad31089cc7e249f658889d11a44605d3662569539 -size 5307341 diff --git a/swig.changes b/swig.changes index 673bf0b..7f5f6c9 100644 --- a/swig.changes +++ b/swig.changes @@ -1,3 +1,44 @@ +------------------------------------------------------------------- +Wed May 29 08:10:19 UTC 2013 - kkaempf@suse.com + +- Ruby 1.8.6 (SLE10) tracks objects differently + Add ruby-1.8.6-newobject.patch + +- Remove skip-python-li_std_containers_int.patch, fixed upstream +- Remove python-2.4.patch, fixed upstream + +- Fix Fedora/RHEL builds (BuildRequires: perl-Test-Simple) + +------------------------------------------------------------------- +Tue May 28 14:37:51 UTC 2013 - kkaempf@suse.com + +- Change Ruby 1.9+ object tracking to use C hashes, fixes all + failed Ruby tests. + Patch added: 0001-Fix-Ruby-tracking-code-to-use-C-hash.patch + Patch removed: 0008-Ruby-Disable-broken-tests.patch + +------------------------------------------------------------------- +Tue May 28 13:04:21 UTC 2013 - kkaempf@suse.com + +- Ruby 2.0 strictly enforces encoding + Add ruby-2.0-encoding-utf8.patch + +------------------------------------------------------------------- +Tue May 28 06:43:48 UTC 2013 - kkaempf@suse.com + +- Update to SWIG 2.0.10 + - Ruby 1.9 support is now complete. + - Add support for Guile 2.0 and Guile 1.6 support (GH interface) has + been dropped. + - Various small language neutral improvements and fixes. + - Various bug fixes and minor improvements specific to C#, CFFI, D, + Java, Octave, PHP, Python, + - Minor bug fix in ccache-swig. + - Development has moved to Github with Travis continuous integration + testing - patches using https://github.com/swig/swig are welcome. + +- drop 0012-Python-Disable-broken-test-in-threads_exception.patch + ------------------------------------------------------------------- Thu Mar 28 11:56:54 CET 2013 - pth@suse.de diff --git a/swig.spec b/swig.spec index d149a55..10dc04f 100644 --- a/swig.spec +++ b/swig.spec @@ -17,7 +17,7 @@ Name: swig -Version: 2.0.9 +Version: 2.0.10 Release: 0 Summary: Simplified Wrapper and Interface Generator License: GPL-3.0+ and BSD-3-Clause @@ -25,16 +25,14 @@ Group: Development/Languages/C and C++ Url: http://www.swig.org/ Source: http://sourceforge.net/projects/swig/files/swig/%{name}-%{version}/%{name}-%{version}.tar.gz Source1: %{name}.rpmlintrc -# Disable test failing on Python 2.4 -Patch5: python-2.4.patch -# Disable tests failing on Ruby 1.9 -Patch6: 0008-Ruby-Disable-broken-tests.patch -# Disable test failing in Python -Patch7: 0012-Python-Disable-broken-test-in-threads_exception.patch -# Test fails in openSUSE 12.1 only -Patch8: skip-python-li_std_containers_int.patch # Fix the return type in declaration of caml_array_length Patch9: swig-fix_ocaml_type.patch +# Ruby 2.0 encodes to UTF-8, SWIG to US-ASCII-8BIT, kkaempf@suse.de +Patch10: ruby-2.0-encoding-utf8.patch +# Fix SWIG object tracking to use C hash, not Ruby Hash, kkaempf@suse.de +Patch11: 0001-Fix-Ruby-tracking-code-to-use-C-hash.patch +# Ruby 1.8.6 (SLE 10) differs in object tracking, kkaempf@suse.de +Patch12: ruby-1.8.6-newobject.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: boost-devel @@ -55,6 +53,7 @@ BuildRequires: ruby BuildRequires: ruby-devel %endif %if 0%{?fedora} > 0 || 0%{?rhel_version} >= 600 ||0%{?centos_version} >= 600 +BuildRequires: perl-Test-Simple BuildRequires: perl-devel %endif %endif @@ -127,15 +126,17 @@ understandig SWIG usage. %prep %setup -q -# Ruby 1.9 from 12.1 %if 0%{?suse_version} == 1010 -%patch5 -p1 +%patch12 -p1 +%endif +# Ruby 1.9 for openSUSE 12.x +%if 0%{?suse_version} >= 1220 +%patch11 -p1 +# Ruby 2.0 for openSUSE 13.1 +%if 0%{?suse_version} > 1230 +%patch10 -p1 %endif -%if 0%{?suse_version} >= 1210 -%patch6 -p1 -%patch8 -p1 %endif -%patch7 -p1 %patch9 %build