ksss / kqueue

kqueue binding in Ruby
MIT License
3 stars 1 forks source link

FreeBSD 12.2 installation error #1

Open hasandiwan opened 2 years ago

hasandiwan commented 2 years ago

~ $ gem install kqueue -v 0.0.1 Building native extensions. This could take a while... ERROR: Error installing kqueue: ERROR: Failed to build gem native extension.

current directory: /mnt/ec2-user/.rvm/gems/ruby-2.6.8@diaspora/gems/kqueue-0.0.1/ext/kqueue

/mnt/ec2-user/.rvm/rubies/ruby-2.6.8/bin/ruby -I /mnt/ec2-user/.rvm/rubies/ruby-2.6.8/lib/ruby/site_ruby/2.6.0 -r ./siteconf20211211-39935-1wprrhc.rb extconf.rb checking for sys/types.h... yes checking for sys/event.h... yes checking for sys/time.h... yes creating Makefile

current directory: /mnt/ec2-user/.rvm/gems/ruby-2.6.8@diaspora/gems/kqueue-0.0.1/ext/kqueue make "DESTDIR=" clean

current directory: /mnt/ec2-user/.rvm/gems/ruby-2.6.8@diaspora/gems/kqueue-0.0.1/ext/kqueue make "DESTDIR=" compiling core.c core.c:8:10: fatal error: 'alloca.h' file not found

include

     ^~~~~~~~~~

1 error generated. *** Error code 1

Stop. make: stopped in /mnt/ec2-user/.rvm/gems/ruby-2.6.8@diaspora/gems/kqueue-0.0.1/ext/kqueue

make failed, exit code 1

Gem files will remain installed in /mnt/ec2-user/.rvm/gems/ruby-2.6.8@diaspora/gems/kqueue-0.0.1 for inspection. Results logged to /mnt/ec2-user/.rvm/gems/ruby-2.6.8@diaspora/extensions/x86_64-freebsd-12/2.6.0/kqueue-0.0.1/gem_make.out ~ $

hasandiwan commented 2 years ago

Fix appears to be commenting out that include line, replacing it with #include <sys/event.h>

ksss commented 2 years ago

Thank you for using this library.

Sorry, I don't have FreeBSD environment. alloca seems function from libc in FreeBSD. https://www.freebsd.org/cgi/man.cgi?query=alloca&apropos=0&sektion=0&manpath=FreeBSD+13.0-RELEASE+and+Ports&arch=default&format=html

Can you please try the following modification? Please let me know if this works for you. Or PR is welcome.


diff --git a/ext/kqueue/core.c b/ext/kqueue/core.c
index ded0a94..ad64c32 100644
--- a/ext/kqueue/core.c
+++ b/ext/kqueue/core.c
@@ -5,7 +5,9 @@
 #if defined(HAVE_SYS_TYPES_H) && defined(HAVE_SYS_EVENT_H) && defined(HAVE_SYS_TIME_H)

 #include <fcntl.h>
+#if defined(HAVE_ALLOCA_H)
 #include <alloca.h>
+#endif
 #include <sys/types.h>
 #include <sys/event.h>
 #include <sys/time.h>

diff --git a/ext/kqueue/extconf.rb b/ext/kqueue/extconf.rb
index acfe2f4..7f8a569 100644
--- a/ext/kqueue/extconf.rb
+++ b/ext/kqueue/extconf.rb
@@ -7,4 +7,6 @@ unless headers.all?{|h| have_header(h)}
   puts "*** you can require 'kqueue'. But, you can not use Kqueue APIs. ***"
 end

+have_header('alloca.h')
+
 create_makefile('kqueue')
hasandiwan commented 2 years ago

I tried your fix and it gives me another error:

$ gem install kqueue.gemspec ERROR: Could not find a valid gem 'kqueue.gemspec' (>= 0) in any repository ERROR: Possible alternatives: hoe-gemspec, parse_gemspec

$ ls kqueue.gemspec kqueue.gemspec

ksss commented 2 years ago

Could you try $ bundle exec rake install ?

hasandiwan commented 2 years ago

Sure...

$ gem install /mnt/ec2-user/kqueue/pkg/kqueue-0.0.1.gem Building native extensions. This could take a while... ERROR: Error installing /mnt/ec2-user/kqueue/pkg/kqueue-0.0.1.gem: ERROR: Failed to build gem native extension.

current directory: /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue

/mnt/ec2-user/.rvm/rubies/ruby-3.0.1/bin/ruby -I /mnt/ec2-user/.rvm/rubies/ruby-3.0.1/lib/ruby/3.0.0 -r ./siteconf20220107-13115-rdju6u.rb extconf.rb checking for sys/types.h... yes checking for sys/event.h... yes checking for sys/time.h... yes checking for alloca.h... yes creating Makefile

current directory: /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue make DESTDIR\= clean

current directory: /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue make DESTDIR\= compiling core.c core.c:218:78: error: use of undeclared identifier 'EVFILT_MACHPORT' rb_define_const(mKqueue_Event_Constants, "EVFILT_MACHPORT", INT2FIX((short)EVFILT_MACHPORT)); ^ core.c:231:78: error: use of undeclared identifier 'NOTE_EXITSTATUS' rb_define_const(mKqueue_Event_Constants, "NOTE_EXITSTATUS", INT2FIX((u_int)NOTE_EXITSTATUS)); ^ core.c:234:74: error: use of undeclared identifier 'NOTE_SIGNAL' rb_define_const(mKqueue_Event_Constants, "NOTE_SIGNAL", INT2FIX((u_int)NOTE_SIGNAL)); ^ core.c:235:72: error: use of undeclared identifier 'NOTE_REAP' rb_define_const(mKqueue_Event_Constants, "NOTE_REAP", INT2FIX((u_int)NOTE_REAP)); ^ 4 errors generated. *** Error code 1

Stop. make: stopped in /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue

make failed, exit code 1

Gem files will remain installed in /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1 for inspection.

$ cat /mnt/ec2-user/.rvm/gems/ruby-3.0.1/extensions/x86_64-freebsd-12/3.0.0/kqueue-0.0.1/gem_make.out current directory: /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue /mnt/ec2-user/.rvm/rubies/ruby-3.0.1/bin/ruby -I /mnt/ec2-user/.rvm/rubies/ruby-3.0.1/lib/ruby/3.0.0 -r ./siteconf20220107-13115-rdju6u.rb extconf.rb checking for sys/types.h... yes checking for sys/event.h... yes checking for sys/time.h... yes checking for alloca.h... yes creating Makefile

current directory: /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue make DESTDIR\= clean

current directory: /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue make DESTDIR\= compiling core.c core.c:218:78: error: use of undeclared identifier 'EVFILT_MACHPORT' rb_define_const(mKqueue_Event_Constants, "EVFILT_MACHPORT", INT2FIX((short)EVFILT_MACHPORT)); ^ core.c:231:78: error: use of undeclared identifier 'NOTE_EXITSTATUS' rb_define_const(mKqueue_Event_Constants, "NOTE_EXITSTATUS", INT2FIX((u_int)NOTE_EXITSTATUS)); ^ core.c:234:74: error: use of undeclared identifier 'NOTE_SIGNAL' rb_define_const(mKqueue_Event_Constants, "NOTE_SIGNAL", INT2FIX((u_int)NOTE_SIGNAL)); ^ core.c:235:72: error: use of undeclared identifier 'NOTE_REAP' rb_define_const(mKqueue_Event_Constants, "NOTE_REAP", INT2FIX((u_int)NOTE_REAP)); ^ 4 errors generated. *** Error code 1

Stop. make: stopped in /mnt/ec2-user/.rvm/gems/ruby-3.0.1/gems/kqueue-0.0.1/ext/kqueue

make failed, exit code 1

ksss commented 2 years ago

Hmm..., some constants seem to be undefined. I am not familiar with FreeBSD and do not have the time to work on it. Feel free to open a PR.

hasandiwan commented 2 years ago

core.c:218:78: error: use of undeclared identifier 'EVFILT_MACHPORT' rb_define_const(mKqueue_Event_Constants, "EVFILT_MACHPORT", INT2FIX((short)EVFILT_MACHPORT)); ^ core.c:231:78: error: use of undeclared identifier 'NOTE_EXITSTATUS' rb_define_const(mKqueue_Event_Constants, "NOTE_EXITSTATUS", INT2FIX((u_int)NOTE_EXITSTATUS)); ^ core.c:234:74: error: use of undeclared identifier 'NOTE_SIGNAL' rb_define_const(mKqueue_Event_Constants, "NOTE_SIGNAL", INT2FIX((u_int)NOTE_SIGNAL)); ^ core.c:235:72: error: use of undeclared identifier 'NOTE_REAP' rb_define_const(mKqueue_Event_Constants, "NOTE_REAP", INT2FIX((u_int)NOTE_REAP));

I'm now getting these undeclared identifiers -- help?