digital-fabric / polyphony

Fine-grained concurrency for Ruby
https://www.rubydoc.info/gems/polyphony
MIT License
661 stars 17 forks source link

Native extension build fails with "implicit declaration of function 'rb_fiber_transfer' is invalid in C99" #79

Closed svoop closed 2 years ago

svoop commented 2 years ago

Installing Polyphony with gem install on Ruby 2.7.5 fails with:

ERROR:  Error installing polyphony:
    ERROR: Failed to build gem native extension.

    current directory: /Users/###/.gem/ruby/2.7.0/gems/polyphony-0.79/ext/polyphony
/Users/###/.rubies/ruby-2.7.5/bin/ruby -I /Users/###/.rubies/ruby-2.7.5/lib/ruby/site_ruby/2.7.0 -r ./siteconf20220228-81924-1gthvbt.rb extconf.rb
Building Polyphony... ({:linux=>false})
checking for linux/aio_abi.h... no
checking for sys/select.h... yes
checking for port_event_t in poll.h... no
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port_event_t in port.h... no
checking for sys/resource.h... yes
checking for rb_fiber_transfer() in ruby.h... yes
creating Makefile

current directory: /Users/###/.gem/ruby/2.7.0/gems/polyphony-0.79/ext/polyphony
make DESTDIR\= clean

current directory: /Users/###/.gem/ruby/2.7.0/gems/polyphony-0.79/ext/polyphony
make DESTDIR\=
compiling backend_common.c
backend_common.c:103:18: error: implicit declaration of function 'rb_fiber_transfer' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    next.value : FIBER_TRANSFER(next.fiber, next.value);
                 ^
./polyphony.h:31:40: note: expanded from macro 'FIBER_TRANSFER'
  #define FIBER_TRANSFER(fiber, value) rb_fiber_transfer(fiber, 1, &value)
                                       ^
1 error generated.
make: *** [backend_common.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/###/.gem/ruby/2.7.0/gems/polyphony-0.79 for inspection.
Results logged to /Users/###/.gem/ruby/2.7.0/extensions/arm64-darwin-21/2.7.0-static/polyphony-0.79/gem_make.out

However, it installs just fine on Ruby 3.1.1.

noteflakes commented 2 years ago

That's strange.

checking for rb_fiber_transfer() in ruby.h... yes

The rb_fiber_transfer API has been added to ruby.h only in Ruby 3.1 if I'm not mistaken. On my machine with Ruby 2.7.5, Polyphony installs successfully, and the check behaves normally:

Building Polyphony... ({:linux=>true, :pidfd_open=>true, :io_uring=>true})
checking for rb_fiber_transfer() in ruby.h... no

Polyphony also installs correctly on Ruby 2.7.5 in the CI: https://github.com/digital-fabric/polyphony/runs/5261101899?check_suite_focus=true#step:5:19

How did you install Ruby 2.7.5?

svoop commented 2 years ago

I've installed Ruby 2.7.5 with ruby-install:

ruby-install -s ~/.rubies_src ruby 2.7.5 -- --with-jemalloc CPPFLAGS="$CPPFLAGS -I $HOMEBREW_PREFIX/include" LDFLAGS="$LDFLAGS -L $HOMEBREW_PREFIX/lib"
noteflakes commented 2 years ago

Hey @svoop I just pushed version 0.90 which should take care of your problem. Please let me know if you encounter any more issues.

svoop commented 2 years ago

Works like a charm now, thanks a lot, @ciconia !