socketry/nio4r

Compilation error for nio4r native extensions on SmartOS

Haerezis opened this issue · 5 comments

Hi,
since the recent bump to version 2.5.0, the compilation of the native extensions fail on SmartOS (Solaris). Here is the dump I get :

Installing nio4r 2.5.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/runner/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.3/gems/nio4r-2.5.0/ext/nio4r
/home/runner/.rbenv/versions/2.4.3/bin/ruby -r
./siteconf20190828-32792-1mu7t2j.rb extconf.rb
checking for unistd.h... yes
checking for sys/select.h... yes
checking for port_event_t in poll.h... no
checking for sys/epoll.h... yes
checking for sys/event.h... no
checking for port_event_t in port.h... yes
checking for sys/resource.h... yes
creating Makefile

current directory:
/home/runner/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.3/gems/nio4r-2.5.0/ext/nio4r
make "DESTDIR=" clean

current directory:
/home/runner/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.3/gems/nio4r-2.5.0/ext/nio4r
make "DESTDIR="
compiling bytebuffer.c
compiling monitor.c
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:0:
../libev/ev.c:1875:31: warning: 'ev_default_loop_ptr' initialized and declared
'extern'
EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be
initialised to make it a definition despite extern */
                               ^~~~~~~~~~~~~~~~~~~
In file included from ../libev/ev.c:2744:0,
                 from nio4r_ext.c:7:
../libev/ev_port.c: In function 'port_associate_and_check':
../libev/ev_port.c:192:0: error: unterminated argument list invoking macro
"assert"
 
 
In file included from ../libev/ev.c:2744:0,
                 from nio4r_ext.c:7:
../libev/ev_port.c:73:11: error: 'assert' undeclared (first use in this
function); did you mean 'sqrt'?
           assert (("libev: port_associate found invalid fd", errno != EBADFD);
           ^~~~~~
           sqrt
../libev/ev_port.c:73:11: note: each undeclared identifier is reported only once
for each function it appears in
In file included from ../libev/ev_epoll.c:66:0,
                 from ../libev/ev.c:2750,
                 from nio4r_ext.c:7:
/usr/include/sys/epoll.h:26:1: error: expected ';' before 'typedef'
 typedef union epoll_data {
 ^~~~~~~
/usr/include/sys/epoll.h:39:2: error: unknown type name 'epoll_data_t'
  epoll_data_t data;  /* user-specified data */
  ^~~~~~~~~~~~
In file included from ../libev/ev.c:2750:0,
                 from nio4r_ext.c:7:
../libev/ev_epoll.c:71:1: error: invalid storage class for function
'epoll_modify'
 epoll_modify (EV_P_ int fd, int oev, int nev)
 ^~~~~~~~~~~~
../libev/ev_epoll.c: In function 'epoll_modify':
../libev/ev_epoll.c:91:10: error: request for member 'u64' in something not a
structure or union
   ev.data.u64 = (uint64_t)(uint32_t)fd
          ^
../libev/ev_epoll.c: In function 'port_associate_and_check':
../libev/ev_epoll.c:144:1: error: invalid storage class for function
'epoll_poll'
 epoll_poll (EV_P_ ev_tstamp timeout)
 ^~~~~~~~~~
In file included from ../libev/ev.c:1872:0,
                 from nio4r_ext.c:7:
../libev/ev_epoll.c: In function 'epoll_poll':
../libev/ev_wrap.h:28:22: warning: passing argument 2 of 'epoll_wait' from
incompatible pointer type [-Wincompatible-pointer-types]
 #define epoll_events ((loop)->epoll_events)
                      ^
../libev/ev_epoll.c:155:38: note: in expansion of macro 'epoll_events'
eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, timeout *
1e3);
                                      ^~~~~~~~~~~~
In file included from ../libev/ev_epoll.c:66:0,
                 from ../libev/ev.c:2750,
                 from nio4r_ext.c:7:
/usr/include/sys/epoll.h:78:12: note: expected 'struct epoll_event *' but
argument is of type 'struct epoll_event *'
 extern int epoll_wait(int epfd, struct epoll_event *events,
            ^~~~~~~~~~
In file included from ../libev/ev.c:2750:0,
                 from nio4r_ext.c:7:
../libev/ev_epoll.c:168:45: error: invalid use of undefined type 'struct
epoll_event'
       struct epoll_event *ev = epoll_events + i;
                                             ^
In file included from ../libev/ev.c:1872:0,
                 from nio4r_ext.c:7:
../libev/ev_wrap.h:28:22: warning: initialization from incompatible pointer type
[-Wincompatible-pointer-types]
 #define epoll_events ((loop)->epoll_events)
                      ^
../libev/ev_epoll.c:168:32: note: in expansion of macro 'epoll_events'
       struct epoll_event *ev = epoll_events + i;
                                ^~~~~~~~~~~~
In file included from ../libev/ev.c:2750:0,
                 from nio4r_ext.c:7:
../libev/ev_epoll.c:170:34: error: request for member 'u64' in something not a
structure or union
       int fd = (uint32_t)ev->data.u64; /* mask out the lower 32 bits */
                                  ^
In file included from nio4r_ext.c:7:0:
../libev/ev_epoll.c:181:73: error: request for member 'u64' in something not a
structure or union
if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >>
32)))
                                                                         ^
../libev/ev.c:881:61: note: in definition of macro 'ecb_expect'
   #define ecb_expect(expr,value)         __builtin_expect ((expr),(value))
                                                             ^~~~
../libev/ev.c:1564:28: note: in expansion of macro 'ecb_expect_false'
 #define expect_false(cond) ecb_expect_false (cond)
                            ^~~~~~~~~~~~~~~~
../libev/ev_epoll.c:181:11: note: in expansion of macro 'expect_false'
if (expect_false ((uint32_t)anfds [fd].egen != (uint32_t)(ev->data.u64 >>
32)))
           ^~~~~~~~~~~~
In file included from ../libev/ev.c:2750:0,
                 from nio4r_ext.c:7:
../libev/ev_epoll.c:221:20: warning: assignment from incompatible pointer type
[-Wincompatible-pointer-types]
epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct
epoll_event) * epoll_eventmax);
                    ^
../libev/ev_epoll.c: In function 'port_associate_and_check':
../libev/ev_epoll.c:241:1: error: invalid storage class for function
'epoll_epoll_create'
 epoll_epoll_create (void)
 ^~~~~~~~~~~~~~~~~~
../libev/ev_epoll.c:262:1: error: invalid storage class for function
'epoll_init'
 epoll_init (EV_P_ int flags)
 ^~~~~~~~~~
../libev/ev_epoll.c: In function 'epoll_init':
../libev/ev_epoll.c:272:16: warning: assignment from incompatible pointer type
[-Wincompatible-pointer-types]
epoll_events = (struct epoll_event *)ev_malloc (sizeof (struct epoll_event) *
epoll_eventmax);
                ^
../libev/ev_epoll.c: In function 'port_associate_and_check':
../libev/ev_epoll.c:279:1: error: invalid storage class for function
'epoll_destroy'
 epoll_destroy (EV_P)
 ^~~~~~~~~~~~~
../libev/ev_epoll.c:287:1: error: invalid storage class for function
'epoll_fork'
 epoll_fork (EV_P)
 ^~~~~~~~~~
In file included from ../libev/ev.c:2756:0,
                 from nio4r_ext.c:7:
../libev/ev_poll.c:44:1: error: invalid storage class for function
'array_needsize_pollidx'
 array_needsize_pollidx (int *base, int offset, int count)
 ^~~~~~~~~~~~~~~~~~~~~~
../libev/ev_poll.c:55:1: error: invalid storage class for function 'poll_modify'
 poll_modify (EV_P_ int fd, int oev, int nev)
 ^~~~~~~~~~~
../libev/ev_poll.c:92:1: error: invalid storage class for function 'poll_poll'
 poll_poll (EV_P_ ev_tstamp timeout)
 ^~~~~~~~~
../libev/ev_poll.c:137:1: error: invalid storage class for function 'poll_init'
 poll_init (EV_P_ int flags)
 ^~~~~~~~~
../libev/ev_poll.c:151:1: error: invalid storage class for function
'poll_destroy'
 poll_destroy (EV_P)
 ^~~~~~~~~~~~
In file included from ../libev/ev.c:2759:0,
                 from nio4r_ext.c:7:
../libev/ev_select.c:71:1: error: invalid storage class for function
'select_modify'
 select_modify (EV_P_ int fd, int oev, int nev)
 ^~~~~~~~~~~~~
../libev/ev_select.c:140:1: error: invalid storage class for function
'select_poll'
 select_poll (EV_P_ ev_tstamp timeout)
 ^~~~~~~~~~~
../libev/ev_select.c:276:1: error: invalid storage class for function
'select_init'
 select_init (EV_P_ int flags)
 ^~~~~~~~~~~
../libev/ev_select.c:306:1: error: invalid storage class for function
'select_destroy'
 select_destroy (EV_P)
 ^~~~~~~~~~~~~~
In file included from nio4r_ext.c:7:0:
../libev/ev.c:2776:1: error: invalid storage class for function 'enable_secure'
 enable_secure (void)
 ^~~~~~~~~~~~~
../libev/ev.c:2904:1: error: invalid storage class for function 'loop_init'
 loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT
 ^~~~~~~~~
../libev/ev.c: In function 'loop_init':
../libev/ev.c:2975:63: warning: implicit declaration of function 'port_init';
did you mean 'poll_init'? [-Wimplicit-function-declaration]
if (!backend && (flags & EVBACKEND_PORT    )) backend = port_init     
(EV_A_ flags);
                                                               ^~~~~~~~~
                                                               poll_init
../libev/ev.c: In function 'ev_loop_destroy':
../libev/ev.c:3058:38: warning: implicit declaration of function 'port_destroy';
did you mean 'poll_destroy'? [-Wimplicit-function-declaration]
   if (backend == EVBACKEND_PORT    ) port_destroy     (EV_A);
                                      ^~~~~~~~~~~~
                                      poll_destroy
../libev/ev.c: In function 'port_associate_and_check':
../libev/ev.c:3122:1: error: invalid storage class for function 'loop_fork'
 loop_fork (EV_P)
 ^~~~~~~~~
../libev/ev.c: In function 'loop_fork':
../libev/ev.c:3125:38: warning: implicit declaration of function 'port_fork';
did you mean 'postfork'? [-Wimplicit-function-declaration]
   if (backend == EVBACKEND_PORT    ) port_fork     (EV_A);
                                      ^~~~~~~~~
                                      postfork
../libev/ev.c: In function 'port_associate_and_check':
../libev/ev.c:3183:1: error: invalid storage class for function 'verify_watcher'
 verify_watcher (EV_P_ W w)
 ^~~~~~~~~~~~~~
../libev/ev.c:3193:1: error: invalid storage class for function 'verify_heap'
 verify_heap (EV_P_ ANHE *heap, int N)
 ^~~~~~~~~~~
../libev/ev.c:3209:1: error: invalid storage class for function 'array_verify'
 array_verify (EV_P_ W *ws, int cnt)
 ^~~~~~~~~~~~
../libev/ev.c:3393:1: error: invalid storage class for function 'idle_reify'
 idle_reify (EV_P)
 ^~~~~~~~~~
../libev/ev.c:3416:1: error: invalid storage class for function 'timers_reify'
 timers_reify (EV_P)
 ^~~~~~~~~~~~
../libev/ev.c:3456:1: error: invalid storage class for function
'periodic_recalc'
 periodic_recalc (EV_P_ ev_periodic *w)
 ^~~~~~~~~~~~~~~
../libev/ev.c:3481:1: error: invalid storage class for function
'periodics_reify'
 periodics_reify (EV_P)
 ^~~~~~~~~~~~~~~
../libev/ev.c:3525:1: error: invalid storage class for function
'periodics_reschedule'
 periodics_reschedule (EV_P)
 ^~~~~~~~~~~~~~~~~~~~
../libev/ev.c:3549:1: error: invalid storage class for function
'timers_reschedule'
 timers_reschedule (EV_P_ ev_tstamp adjust)
 ^~~~~~~~~~~~~~~~~
../libev/ev.c:3564:1: error: invalid storage class for function 'time_update'
 time_update (EV_P_ ev_tstamp max_block)
 ^~~~~~~~~~~
../libev/ev.c:3639:7: error: invalid storage class for function
'ev_backend_poll'
 VALUE ev_backend_poll(void *ptr)
       ^~~~~~~~~~~~~~~
../libev/ev.c: In function 'ev_run':
../libev/ev.c:3814:36: warning: passing argument 1 of
'rb_thread_call_without_gvl' from incompatible pointer type
[-Wincompatible-pointer-types]
rb_thread_call_without_gvl(ev_backend_poll, (void *)&poll_args,
RUBY_UBF_IO, 0);
                                    ^~~~~~~~~~~~~~~
In file included from ../libev/ev.c:42:0,
                 from nio4r_ext.c:7:
/home/runner/.rbenv/versions/2.4.3/include/ruby-2.4.3/ruby/thread.h:28:7: note:
expected 'void * (*)(void *)' but argument is of type 'VALUE (*)(void *) {aka
long unsigned int (*)(void *)}'
 void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
       ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from nio4r_ext.c:7:0:
../libev/ev.c: In function 'port_associate_and_check':
../libev/ev.c:3917:1: error: invalid storage class for function 'wlist_add'
 wlist_add (WL *head, WL elem)
 ^~~~~~~~~
../libev/ev.c:3924:1: error: invalid storage class for function 'wlist_del'
 wlist_del (WL *head, WL elem)
 ^~~~~~~~~
../libev/ev.c:3940:1: error: invalid storage class for function 'clear_pending'
 clear_pending (EV_P_ W w)
 ^~~~~~~~~~~~~
../libev/ev.c:3967:1: error: invalid storage class for function 'pri_adjust'
 pri_adjust (EV_P_ W w)
 ^~~~~~~~~~
../libev/ev.c:3976:1: error: invalid storage class for function 'ev_start'
 ev_start (EV_P_ W w, int active)
 ^~~~~~~~
../libev/ev.c:3984:1: error: invalid storage class for function 'ev_stop'
 ev_stop (EV_P_ W w)
 ^~~~~~~
../libev/ev.c:4382:22: error: invalid storage class for function 'stat_timer_cb'
 noinline static void stat_timer_cb (EV_P_ ev_timer *w_, int revents);
                      ^~~~~~~~~~~~~
../libev/ev.c:4640:1: error: invalid storage class for function 'stat_timer_cb'
 stat_timer_cb (EV_P_ ev_timer *w_, int revents)
 ^~~~~~~~~~~~~
../libev/ev.c:4867:1: error: invalid storage class for function 'embed_io_cb'
 embed_io_cb (EV_P_ ev_io *io, int revents)
 ^~~~~~~~~~~
../libev/ev.c:4878:1: error: invalid storage class for function
'embed_prepare_cb'
 embed_prepare_cb (EV_P_ ev_prepare *prepare, int revents)
 ^~~~~~~~~~~~~~~~
../libev/ev.c:4894:1: error: invalid storage class for function 'embed_fork_cb'
 embed_fork_cb (EV_P_ ev_fork *fork_w, int revents)
 ^~~~~~~~~~~~~
../libev/ev.c:5107:1: error: invalid storage class for function 'once_cb'
 once_cb (EV_P_ struct ev_once *once, int revents)
 ^~~~~~~
../libev/ev.c:5120:1: error: invalid storage class for function 'once_cb_io'
 once_cb_io (EV_P_ ev_io *w, int revents)
 ^~~~~~~~~~
../libev/ev.c:5128:1: error: invalid storage class for function 'once_cb_to'
 once_cb_to (EV_P_ ev_timer *w, int revents)
 ^~~~~~~~~~
In file included from
/home/runner/.rbenv/versions/2.4.3/include/ruby-2.4.3/ruby/ruby.h:36:0,
from
/home/runner/.rbenv/versions/2.4.3/include/ruby-2.4.3/ruby.h:33,
                 from nio4r.h:9,
                 from nio4r_ext.c:6:
nio4r_ext.c: In function 'Init_nio4r_ext':
/home/runner/.rbenv/versions/2.4.3/include/ruby-2.4.3/ruby/defines.h:186:18:
warning: passing argument 1 of 'ev_set_allocator' from incompatible pointer type
[-Wincompatible-pointer-types]
 #define xrealloc ruby_xrealloc
                  ^
nio4r_ext.c:15:22: note: in expansion of macro 'xrealloc'
     ev_set_allocator(xrealloc);
                      ^~~~~~~~
In file included from nio4r_ext.c:7:0:
../libev/ev.c:1777:1: note: expected 'void * (*)(void *, long int)' but argument
is of type 'void * (*)(void *, size_t) {aka void * (*)(void *, long unsigned
int)}'
 ev_set_allocator (void *(*cb)(void *ptr, long size) EV_NOEXCEPT) EV_NOEXCEPT
 ^~~~~~~~~~~~~~~~
nio4r_ext.c: In function 'port_associate_and_check':
nio4r_ext.c:20:1: error: expected declaration or statement at end of input
 }
 ^
nio4r_ext.c:20:1: error: expected declaration or statement at end of input
nio4r_ext.c:20:1: error: expected declaration or statement at end of input
Makefile:241: recipe for target 'nio4r_ext.o' failed
make: *** [nio4r_ext.o] Error 1

make failed, exit code 2

On my laptop with linux, I don't have any problem, which is weird. I'll try to investigate a little bit, but maybe you already have a idea why?

Ok so it seems like it's just a missing closing ')' in ev_port.c for an assert. I'll do a PR.

Do you plan on releasing a new gem version with the fix? It would be really helpful.

Yes

Released in v2.5.1

Thanks for the PR.

Happy to receive a PR to fix other issues.