Bug 1526

Summary: libsigrok Ruby bindings fail to build with Ruby 2.7
Product: libsigrok Reporter: Uwe Hermann <uwe>
Component: Bindings: RubyAssignee: Nobody <nobody>
Status: RESOLVED FIXED    
Severity: normal CC: anatol.pomozov, Gerhard.Sittig
Priority: Normal    
Version: unreleased development snapshot   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Fix ruby bindings

Description Uwe Hermann 2020-03-20 17:02:57 CET
Partial build log:

  CXX      bindings/ruby/classes_wrap.o
bindings/ruby/classes_wrap.cpp: In function ‘std::map<std::__cxx11::basic_string<char>, Glib::VariantBase> hash_to_map_options(VALUE, std::map<std::__cxx11::basic_string<char>, std::shared_ptr<sigrok::Option> >)’:
bindings/ruby/classes_wrap.cpp:10745:75: warning: ‘void ruby::backward::cxxanyargs::rb_hash_foreach(VALUE, int (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
10745 |     rb_hash_foreach(hash, (int (*)(ANYARGS))convert_option, (VALUE)&params);
      |                                                                           ^
In file included from /usr/include/ruby-2.7.0/ruby/ruby.h:2863,
                 from /usr/include/ruby-2.7.0/ruby.h:33,
                 from bindings/ruby/classes_wrap.cpp:880:
/usr/include/ruby-2.7.0/ruby/backward/cxxanyargs.hpp:412:1: note: declared here
  412 | rb_hash_foreach(VALUE q, int_type *w, VALUE e)
      | ^~~~~~~~~~~~~~~
bindings/ruby/classes_wrap.cpp:10745:75: warning: ‘void ruby::backward::cxxanyargs::rb_hash_foreach(VALUE, int (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
10745 |     rb_hash_foreach(hash, (int (*)(ANYARGS))convert_option, (VALUE)&params);
      |                                                                           ^
In file included from /usr/include/ruby-2.7.0/ruby/ruby.h:2863,
                 from /usr/include/ruby-2.7.0/ruby.h:33,
                 from bindings/ruby/classes_wrap.cpp:880:
/usr/include/ruby-2.7.0/ruby/backward/cxxanyargs.hpp:412:1: note: declared here
  412 | rb_hash_foreach(VALUE q, int_type *w, VALUE e)
      | ^~~~~~~~~~~~~~~
bindings/ruby/classes_wrap.cpp: In function ‘std::vector<std::shared_ptr<sigrok::HardwareDevice> > sigrok_Driver__scan__SWIG_0(sigrok::Driver*, VALUE)’:
bindings/ruby/classes_wrap.cpp:11017:89: warning: ‘void ruby::backward::cxxanyargs::rb_hash_foreach(VALUE, int (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
11017 |         rb_hash_foreach(kwargs, (int (*)(ANYARGS))convert_option_by_key, (VALUE)&options);
      |                                                                                         ^
In file included from /usr/include/ruby-2.7.0/ruby/ruby.h:2863,
                 from /usr/include/ruby-2.7.0/ruby.h:33,
                 from bindings/ruby/classes_wrap.cpp:880:
/usr/include/ruby-2.7.0/ruby/backward/cxxanyargs.hpp:412:1: note: declared here
  412 | rb_hash_foreach(VALUE q, int_type *w, VALUE e)
      | ^~~~~~~~~~~~~~~
bindings/ruby/classes_wrap.cpp:11017:89: warning: ‘void ruby::backward::cxxanyargs::rb_hash_foreach(VALUE, int (*)(...), VALUE)’ is deprecated: Use of ANYARGS in this function is deprecated [-Wdeprecated-declarations]
11017 |         rb_hash_foreach(kwargs, (int (*)(ANYARGS))convert_option_by_key, (VALUE)&options);
      |                                                                                         ^
In file included from /usr/include/ruby-2.7.0/ruby/ruby.h:2863,
                 from /usr/include/ruby-2.7.0/ruby.h:33,
                 from bindings/ruby/classes_wrap.cpp:880:
/usr/include/ruby-2.7.0/ruby/backward/cxxanyargs.hpp:412:1: note: declared here
  412 | rb_hash_foreach(VALUE q, int_type *w, VALUE e)
      | ^~~~~~~~~~~~~~~
bindings/ruby/classes_wrap.cpp: At global scope:
bindings/ruby/classes_wrap.cpp:47934:2: error: expected unqualified-id before ‘/’ token
47934 | */
      |  ^
bindings/ruby/classes_wrap.cpp:48045:2: error: expected unqualified-id before ‘/’ token
48045 | */
      |  ^

[...]

(lots more errors follow)
Comment 1 Anatol 2020-06-09 06:01:51 CEST
Created attachment 640 [details]
Fix ruby bindings
Comment 2 Anatol 2020-06-09 06:02:29 CEST
SWIG 4.0.2 adds ruby 2.7 fixes. On top of it libsigrok requires and extra patch, see it attached.
Comment 3 Uwe Hermann 2020-06-20 18:32:10 CEST
Fixed in 2e199405e53fee2fb3cad72858ebe7af6990bce0, thanks!

I've tested this on Ruby 2.5 + SWIG 4.0.1 and Ruby 2.7 + SWIG 4.0.1 as well.
Comment 4 Gerhard Sittig 2020-07-16 12:14:00 CEST
Jenkins builds were affected by the most recent change, AppImages haven't 
been buliding since 2020-06-20. Re-opening the reported issue. Does this 
depend on the ruby and swig versions (swig 3.0.8 and ruby 2.3.1 on Jenkins)?
Comment 5 Uwe Hermann 2020-07-18 17:38:05 CEST
Fixed in 339d12df978b32c5f9a10dc14d4ab3a03a0ed5c0 by bumping the minimum required Ruby version to 2.5.0, thanks!

This will automatically disable the Ruby bindings build when older versions are found.