socketry / io-event

MIT License
66 stars 15 forks source link

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. (use of undeclared identifier 'EV_UDATA_SPECIFIC') #39

Closed joyboy67 closed 1 year ago

joyboy67 commented 2 years ago

Hello, I'm trying to build io-event (1.0.9) for a Solidus project (https://github.com/solidusio/solidus/discussions/4583) but I get this output

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/3.1/gems/io-event-1.0.9/ext
/usr/local/bin/ruby31 -I /usr/local/lib/ruby/site_ruby/3.1 -r
./siteconf20220907-35220-ny28ez.rb extconf.rb
checking for rb_ext_ractor_safe()... yes
checking for &rb_fiber_transfer()... yes
checking for -luring... no
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/eventfd.h... no
checking for rb_io_descriptor()... yes
checking for &rb_process_status_wait()... no
checking for rb_fiber_current()... yes
checking for &rb_fiber_raise()... yes
checking for ruby/io/buffer.h... yes
creating extconf.h
creating Makefile

current directory: /usr/local/lib/ruby/gems/3.1/gems/io-event-1.0.9/ext
make DESTDIR\= clean

current directory: /usr/local/lib/ruby/gems/3.1/gems/io-event-1.0.9/ext
make DESTDIR\=
compiling ./io/event/event.c
compiling ./io/event/selector/selector.c
compiling ./io/event/selector/kqueue.c
./io/event/selector/kqueue.c:193:50: error: use of undeclared identifier 'EV_UDATA_SPECIFIC'
        event.flags = EV_ADD | EV_ENABLE | EV_ONESHOT | EV_UDATA_SPECIFIC;
                                                        ^
./io/event/selector/kqueue.c:217:28: error: use of undeclared identifier 'EV_UDATA_SPECIFIC'
        event.flags = EV_DELETE | EV_UDATA_SPECIFIC;
                                  ^
./io/event/selector/kqueue.c:276:60: error: use of undeclared identifier 'EV_UDATA_SPECIFIC'
                kevents[count].flags = EV_ADD | EV_ENABLE | EV_ONESHOT | EV_UDATA_SPECIFIC;
                                                                         ^
./io/event/selector/kqueue.c:291:60: error: use of undeclared identifier 'EV_UDATA_SPECIFIC'
                kevents[count].flags = EV_ADD | EV_ENABLE | EV_ONESHOT | EV_UDATA_SPECIFIC;
                                                                         ^
./io/event/selector/kqueue.c:313:38: error: use of undeclared identifier 'EV_UDATA_SPECIFIC'
                kevents[count].flags = EV_DELETE | EV_UDATA_SPECIFIC;
                                                   ^
./io/event/selector/kqueue.c:321:38: error: use of undeclared identifier 'EV_UDATA_SPECIFIC'
                kevents[count].flags = EV_DELETE | EV_UDATA_SPECIFIC;
                                                   ^
./io/event/selector/kqueue.c:697:20: error: use of undeclared identifier 'EVFILT_USER'
                trigger.filter = EVFILT_USER;
                                 ^
./io/event/selector/kqueue.c:698:39: error: use of undeclared identifier 'EV_UDATA_SPECIFIC'
                trigger.flags = EV_ADD | EV_CLEAR | EV_UDATA_SPECIFIC;
                                                    ^
./io/event/selector/kqueue.c:699:20: error: use of undeclared identifier 'NOTE_TRIGGER'
                trigger.fflags = NOTE_TRIGGER;
                                 ^
9 errors generated.
*** Error 1 in /usr/local/lib/ruby/gems/3.1/gems/io-event-1.0.9/ext (Makefile:246 'kqueue.o':
@ cc -I. -I/usr/local/include/ruby-3.1/x86_64-...)

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/3.1/gems/io-event-1.0.9 for
inspection.
Results logged to
/usr/local/lib/ruby/gems/3.1/extensions/x86_64-openbsd/3.1/io-event-1.0.9/gem_make.out

My OS is OpenBSD 7.1 x64 and my ruby version is 3.1.2

ioquatix commented 1 year ago

Does your kqueue implementation support EV_UDATA_SPECIFIC?

If not, is there an alternative?

ioquatix commented 1 year ago

So, this appears to be an issue with OpenBSD not fully supporting the required kqueue features.

@jeremyevans do you have any thoughts or suggestions?

We could disable the kqueue if this header define is not found. You'd end up falling back to Ruby's select backend which is not ideal but at least should work.

jeremyevans commented 1 year ago

Assuming io-event needs EV_UDATA_SPECIFIC for kqueue support, since OpenBSD doesn't provide it, falling back to select sounds best (assuming io-event does not support poll).

ioquatix commented 1 year ago

@joyboy67 can you please test the above fix (#49) and confirm that kqueue is skipped on your system.