taf2 / curb

Ruby bindings for libcurl
Other
1.29k stars 227 forks source link

"error: static declaration of ‘rb_io_stdio_file’ follows non-static declaration" when installing on Ubuntu 16.04 and Ruby 2.7.1 #415

Closed patbl closed 3 years ago

patbl commented 3 years ago

Version 0.9.0 of Curb installs without any problems in Ubuntu 16.04 and Ruby 2.6.3. But when I upgrade Ruby to 2.7.1, I get an error:

$ sudo gem install curb
Building native extensions. This could take a while...
ERROR:  Error installing curb:
        ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.7.0/gems/curb-0.9.10/ext
/usr/local/bin/ruby -I /usr/local/lib/ruby/site_ruby/2.7.0 -r ./siteconf20200929-2271-1adng53.rb extconf.rb
checking for curl-config... yes

[snip]

current directory: /usr/local/lib/ruby/gems/2.7.0/gems/curb-0.9.10/ext
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.7.0/gems/curb-0.9.10/ext
make "DESTDIR="
compiling curb.c
compiling curb_easy.c
curb_easy.c:30:15: error: static declaration of ‘rb_io_stdio_file’ follows non-static declaration
 static FILE * rb_io_stdio_file(rb_io_t *fptr) {
               ^
In file included from curb.h:14:0,
                 from curb_easy.h:10,
                 from curb_easy.c:7:
/usr/local/include/ruby-2.7.0/ruby/io.h:135:7: note: previous declaration of ‘rb_io_stdio_file’ was here
 FILE *rb_io_stdio_file(rb_io_t *fptr);
       ^
curb_easy.c: In function ‘rb_io_stdio_file’:
curb_easy.c:31:14: error: ‘rb_io_t {aka struct rb_io_t}’ has no member named ‘f’
   return fptr->f;
              ^
curb_easy.c: In function ‘proc_progress_handler’:
curb_easy.c:194:56: warning: passing argument 3 of ‘rb_rescue’ from incompatible pointer type [-Wincompatible-pointer-types]
   procret = rb_rescue(call_progress_handler, callargs, callback_exception, Qnil);
                                                        ^
In file included from /usr/local/include/ruby-2.7.0/ruby.h:33:0,
                 from curb.h:11,
                 from curb_easy.h:10,
                 from curb_easy.c:7:
/usr/local/include/ruby-2.7.0/ruby/ruby.h:1987:7: note: expected ‘VALUE (*)(VALUE,  VALUE) {aka long unsigned int (*)(long unsigned int,  long unsigned int)}’ but argument is of type ‘VALUE (*)(VALUE) {aka long unsigned int (*)(long unsigned int)}’
 VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
       ^
curb_easy.c: In function ‘proc_debug_handler’:
curb_easy.c:213:43: warning: passing argument 3 of ‘rb_rescue’ from incompatible pointer type [-Wincompatible-pointer-types]
   rb_rescue(call_debug_handler, callargs, callback_exception, Qnil);
                                           ^
In file included from /usr/local/include/ruby-2.7.0/ruby.h:33:0,
                 from curb.h:11,
                 from curb_easy.h:10,
                 from curb_easy.c:7:
/usr/local/include/ruby-2.7.0/ruby/ruby.h:1987:7: note: expected ‘VALUE (*)(VALUE,  VALUE) {aka long unsigned int (*)(long unsigned int,  long unsigned int)}’ but argument is of type ‘VALUE (*)(VALUE) {aka long unsigned int (*)(long unsigned int)}’
 VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
       ^
curb_easy.c: In function ‘ruby_curl_easy_setup’:
curb_easy.c:2491:51: warning: passing argument 3 of ‘rb_iterate’ from incompatible pointer type [-Wincompatible-pointer-types]
       rb_iterate(rb_each, rb_easy_get("headers"), cb_each_http_header, wrap);
                                                   ^
In file included from /usr/local/include/ruby-2.7.0/ruby.h:33:0,
                 from curb.h:11,
                 from curb_easy.h:10,
                 from curb_easy.c:7:
/usr/local/include/ruby-2.7.0/ruby/ruby.h:1984:7: note: expected ‘rb_block_call_func_t {aka long unsigned int (*)(long unsigned int,  long unsigned int,  int,  const long unsigned int *, long unsigned int)}’ but argument is of type ‘VALUE (*)(VALUE,  VALUE) {aka long unsigned int (*)(long unsigned int,  long unsigned int)}’
 VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
       ^
curb_easy.c:2509:57: warning: passing argument 3 of ‘rb_iterate’ from incompatible pointer type [-Wincompatible-pointer-types]
       rb_iterate(rb_each, rb_easy_get("proxy_headers"), cb_each_http_proxy_header, wrap);
                                                         ^
In file included from /usr/local/include/ruby-2.7.0/ruby.h:33:0,
                 from curb.h:11,
                 from curb_easy.h:10,
                 from curb_easy.c:7:
/usr/local/include/ruby-2.7.0/ruby/ruby.h:1984:7: note: expected ‘rb_block_call_func_t {aka long unsigned int (*)(long unsigned int,  long unsigned int,  int,  const long unsigned int *, long unsigned int)}’ but argument is of type ‘VALUE (*)(VALUE,  VALUE) {aka long unsigned int (*)(long unsigned int,  long unsigned int)}’
 VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
       ^
curb_easy.c:2525:56: warning: passing argument 3 of ‘rb_iterate’ from incompatible pointer type [-Wincompatible-pointer-types]
       rb_iterate(rb_each, rb_easy_get("ftp_commands"), cb_each_ftp_command, wrap);
                                                        ^
In file included from /usr/local/include/ruby-2.7.0/ruby.h:33:0,
                 from curb.h:11,
                 from curb_easy.h:10,
                 from curb_easy.c:7:
/usr/local/include/ruby-2.7.0/ruby/ruby.h:1984:7: note: expected ‘rb_block_call_func_t {aka long unsigned int (*)(long unsigned int,  long unsigned int,  int,  const long unsigned int *, long unsigned int)}’ but argument is of type ‘VALUE (*)(VALUE,  VALUE) {aka long unsigned int (*)(long unsigned int,  long unsigned int)}’
 VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
       ^
curb_easy.c:2538:51: warning: passing argument 3 of ‘rb_iterate’ from incompatible pointer type [-Wincompatible-pointer-types]
       rb_iterate(rb_each, rb_easy_get("resolve"), cb_each_resolve, wrap);
                                                   ^
In file included from /usr/local/include/ruby-2.7.0/ruby.h:33:0,
                 from curb.h:11,
                 from curb_easy.h:10,
                 from curb_easy.c:7:
/usr/local/include/ruby-2.7.0/ruby/ruby.h:1984:7: note: expected ‘rb_block_call_func_t {aka long unsigned int (*)(long unsigned int,  long unsigned int,  int,  const long unsigned int *, long unsigned int)}’ but argument is of type ‘VALUE (*)(VALUE,  VALUE) {aka long unsigned int (*)(long unsigned int,  long unsigned int)}’
 VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
       ^
curb_easy.c: In function ‘rb_io_stdio_file’:
curb_easy.c:32:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
curb_easy.c: At top level:
cc1: warning: unrecognized command line option ‘-Wno-tautological-compare’
cc1: warning: unrecognized command line option ‘-Wno-self-assign’
cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
cc1: warning: unrecognized command line option ‘-Wno-cast-function-type’
Makefile:244: recipe for target 'curb_easy.o' failed
make: *** [curb_easy.o] Error 1

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.7.0/gems/curb-0.9.10 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0-static/curb-0.9.10/gem_make.out

The same error was reported in TruffleRuby, but I'm using CRuby.

Upgrading binutils from 2.26 (the version available in the Ubuntu 16.04 repositories) to 2.35 fixes the error, but this would be a difficult change to make in the environment I'm working in.

I realize this may not be a bug in Curb, but I don't know enough to determine that.

patbl commented 3 years ago

This problem is gone on Ruby 2.7.2, so I think it was a Ruby bug.