socketry / io-event

MIT License
75 stars 16 forks source link

fails to build on windows #25

Closed emiltin closed 2 years ago

emiltin commented 2 years ago

this is from a github action runnning on windows-latest, with ruby 3.1.0

C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Ruby\3.1.0\x64\bin\bundle.bat config --local path D:\a\async-hang\async-hang\vendor\bundle"
  C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Ruby\3.1.0\x64\bin\bundle.bat config --local deployment true"
  Cache key: setup-ruby-bundler-cache-v3-windows-2019-ruby-3.1.0-Gemfile.lock-c01e36ffebc073b3320fc1053a331fff213317425c24ae14464503749f8799d2
  Received 343734 of 343734 (100.0%), 5.0 MBs/sec
  Cache Size: ~0 MB (343734 B)
  C:\msys64\usr\bin\tar.exe --use-compress-program "zstd -d" -xf D:/a/_temp/a817aad9-0da0-43c2-b8c9-017ec771bdcb/cache.tzst -P -C D:/a/async-hang/async-hang --force-local
  Cache restored successfully
  Found cache for key: setup-ruby-bundler-cache-v3-windows-2019-ruby-3.1.0-Gemfile.lock-fd679d11dc75adc6a3324870f1163baf9e229e200f0dfba3638bca1fcf8a6fbe
  C:\Windows\system32\cmd.exe /D /S /C "C:\hostedtoolcache\windows\Ruby\3.1.0\x64\bin\bundle.bat install --jobs 4"
  Fetching gem metadata from https://rubygems.org/...
  Using bundler 2.3.6
  Using fiber-local 1.0.0
  Using timers 4.3.3
  Fetching io-event 1.0.2
  Using console 1.14.0
  Installing io-event 1.0.2 with native extensions
  Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

  current directory:
  D:/a/async-hang/async-hang/vendor/bundle/ruby/3.1.0/gems/io-event-1.0.2/ext
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/bin/ruby.exe -I
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0 -r
  ./siteconf20220210-4604-7h5gfw.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... no
  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:
  D:/a/async-hang/async-hang/vendor/bundle/ruby/3.1.0/gems/io-event-1.0.2/ext
  make.exe DESTDIR\= clean

  current directory:
  D:/a/async-hang/async-hang/vendor/bundle/ruby/3.1.0/gems/io-event-1.0.2/ext
  make.exe DESTDIR\=
  generating IO_Event-x64-mingw-ucrt.def
  compiling ./io/event/event.c
  compiling ./io/event/selector/selector.c
  ./io/event/selector/selector.c: In function 'IO_Event_Selector_nonblock_set':
  ./io/event/selector/selector.c:83:44: error: 'F_GETFL' undeclared (first use in
  this function); did you mean 'F_SETFL'?
     83 |         int flags = fcntl(file_descriptor, F_GETFL, 0);
        |                                            ^~~~~~~
        |                                            F_SETFL
  ./io/event/selector/selector.c:83:44: note: each undeclared identifier is
  reported only once for each function it appears in
  make: *** [Makefile:246: selector.o] Error 1

  make failed, exit code 2

  Gem files will remain installed in
  D:/a/async-hang/async-hang/vendor/bundle/ruby/3.1.0/gems/io-event-1.0.2 for
  inspection.
  Results logged to
  D:/a/async-hang/async-hang/vendor/bundle/ruby/3.1.0/extensions/x64-mingw-ucrt/3.1.0/io-event-1.0.2/gem_make.out

  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in
  `run'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:44:in
  `block in make'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in
  `each'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in
  `make'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:63:in
  `block in build'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/tempfile.rb:317:in
  `open'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in
  `build'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in
  `build_extension'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in
  `block in build_extensions'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in
  `each'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in
  `build_extensions'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/3.1.0/rubygems/installer.rb:847:in
  `build_extensions'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/rubygems_gem_installer.rb:71:in
  `build_extensions'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/rubygems_gem_installer.rb:28:in
  `install'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/source/rubygems.rb:204:in
  `install'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/installer/gem_installer.rb:54:in
  `install'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/installer/gem_installer.rb:16:in
  `install_from_spec'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/installer/parallel_installer.rb:186:in
  `do_install'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/installer/parallel_installer.rb:177:in
  `block in worker_pool'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/worker.rb:62:in
  `apply_func'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/worker.rb:57:in
  `block in process_queue'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/worker.rb:54:in
  `loop'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/worker.rb:54:in
  `process_queue'
  C:/hostedtoolcache/windows/Ruby/3.1.0/x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.6/lib/bundler/worker.rb:91:in
  `block (2 levels) in create_threads'

  An error occurred while installing io-event (1.0.2), and Bundler cannot
  continue.

  In Gemfile:
    async-io was resolved to 1.32.2, which depends on
      async was resolved to 2.0.0, which depends on
        io-event
  Took  23.43 seconds
ioquatix commented 2 years ago

I guess the native extension won't build on windows but IO.select might work in some cases. Event-driven IO on windows is supported very poorly. We probably need a dedicated implementation that uses IOCP or even better https://windows-internals.com/ioring-vs-io_uring-a-comparison-of-windows-and-linux-implementations/

emiltin commented 2 years ago

does this mean async 2.0 cannot yet be used on windows?

ioquatix commented 2 years ago

Does the gem install without the native extensions or does the build failure prevent it? If so we just need to skip the native extension on Windows and it should work somewhat.

emiltin commented 2 years ago

bundler reports: An error occurred while installing io-event (1.0.2), and Bundler cannot continue.

I would think that means the native extensions are required?

ioquatix commented 2 years ago

@MSP-Greg do are more of an expert at Windows than me, do you have any suggestions how we can bypass building the extensions on Windows, or build a different set (e.g. ones for the native windows URing).

MSP-Greg commented 2 years ago

how we can bypass building the extensions on Windows

Maybe the same way nio4r does?

build a different set (e.g. ones for the native windows URing).

That's pretty much beyond my c skills, especially Windows specific code...

ioquatix commented 2 years ago

https://github.com/socketry/nio4r/blob/master/ext/nio4r/extconf.rb#L5-L14 looks like a total hack :p

MSP-Greg commented 2 years ago

Otherwise, the only thing to do is remove spec.extensions from the gemspec, which would require a Windows specific release, just like JRuby. I.think.

ioquatix commented 2 years ago

This is now fixed, all the tests are passing, it's added to the GH Actions, and you can install v1.1.1 on 3.1 and 3.2 when it's released.