Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install Iodine gem which uses a C extension on MacOS #2010

Closed
pchaganti opened this issue May 14, 2020 · 7 comments
Closed

Unable to install Iodine gem which uses a C extension on MacOS #2010

pchaganti opened this issue May 14, 2020 · 7 comments
Assignees
Milestone

Comments

@pchaganti
Copy link

Using the most recent release - truffleruby-20.0.0 on Mac OS X 10.15.4. Truffleruby was installed using rvm.

Unable to build iodine gem that uses c extension. Trying to track this down, but there is not much in terms of an error message that I can use. Anyone have any idea where to look for this issue?

thanks!

gem install iodine -v '0.7.38' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR:  Error installing iodine:
	ERROR: Failed to build gem native extension.

    current directory: /Users/hades/.rvm/gems/truffleruby-20.0.0@thor/gems/iodine-0.7.38/ext/iodine
/Users/hades/.rvm/rubies/truffleruby-20.0.0/bin/truffleruby -I /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri -r ./siteconf20200514-41343-8leuhq.rb extconf.rb
checking for clang... yes
testing clang for stdatomic support...
using clang compiler v. 11.0.3
.
/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/mkmf.rb:1299:in `find_type': wrong number of arguments (given 1, expected 2+) (ArgumentError)
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/ffi/struct.rb:272:in `find_type'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/ffi/struct.rb:266:in `find_field_type'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/ffi/struct.rb:306:in `array_layout'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/ffi/struct.rb:218:in `layout'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket/truffle.rb:63:in `config'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket/truffle/foreign/addrinfo.rb:31:in `Addrinfo'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket/truffle/foreign/addrinfo.rb:30:in `Foreign'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket/truffle/foreign/addrinfo.rb:29:in `Socket'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket/truffle/foreign/addrinfo.rb:28:in `Truffle'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket/truffle/foreign/addrinfo.rb:27:in `<top (required)>'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket.rb:38:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket.rb:38:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/truffle/socket.rb:38:in `<top (required)>'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/ipaddr.rb:19:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/ipaddr.rb:19:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/ipaddr.rb:19:in `<top (required)>'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/openssl/ssl.rb:15:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/openssl/ssl.rb:15:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/openssl/ssl.rb:15:in `<top (required)>'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/openssl.rb:21:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/openssl.rb:21:in `require'
	from /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/mri/openssl.rb:21:in `<top (required)>'
	from extconf.rb:118:in `require'
	from extconf.rb:118:in `require'
	from extconf.rb:118:in `<main>'
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/hades/.rvm/rubies/truffleruby-20.0.0/bin/truffleruby
	--with-openssl-dir
	--without-openssl-dir
	--with-openssl-include
	--without-openssl-include=${openssl-dir}/include
	--with-openssl-lib
	--without-openssl-lib=${openssl-dir}/lib

Contents of mkmf.log:
find_executable: checking for clang... -------------------- yes

--------------------

"/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/sulong/native/bin/graalvm-native-clang -o conftest -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include/ruby/backward -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include -I.    -I/usr/local/opt/openssl@1.1/include   -Wimplicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-format-invalid-specifier -Wno-format-extra-args -ferror-limit=500 conftest.c  -L. -L/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib  -L/usr/local/opt/openssl@1.1/lib -rpath /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/sulong/native/lib     -L/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext -rpath /Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext -ltruffleruby -lpolyglot-mock   "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

conftest.c:3:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined]
#define _GNU_SOURCE
        ^
/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include/truffleruby/config_darwin.h:16:9: note: previous definition is here
#define _GNU_SOURCE 1
        ^
conftest.c:9:10: fatal error: 'sys/epoll.h' file not found
#include <sys/epoll.h>
         ^~~~~~~~~~~~~
1 warning and 1 error generated.
"/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/sulong/native/bin/graalvm-native-clang -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include/ruby/backward -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include -I.    -I/usr/local/opt/openssl@1.1/include   -Wimplicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-format-invalid-specifier -Wno-format-extra-args -ferror-limit=500   -o conftest.o -c conftest.c"
Process failed: #<Process::Status: pid 41403 exit 1>
checked program was:
/* begin */
 1: #include "ruby.h"
 2:
 3: #define _GNU_SOURCE
 4: #include <stdlib.h>
 5: #include <stdio.h>
 6: #include <sys/types.h>
 7: #include <sys/stat.h>
 8: #include <fcntl.h>
 9: #include <sys/epoll.h>
10: int main(void) {
11:   int fd = epoll_create1(EPOLL_CLOEXEC);
12: }
/* end */

conftest.c:3:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined]
#define _GNU_SOURCE
        ^
/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include/truffleruby/config_darwin.h:16:9: note: previous definition is here
#define _GNU_SOURCE 1
        ^
1 warning generated.
"/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/sulong/native/bin/graalvm-native-clang -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include/ruby/backward -I/Users/hades/.rvm/rubies/truffleruby-20.0.0/lib/cext/include -I.    -I/usr/local/opt/openssl@1.1/include   -Wimplicit-function-declaration -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-format-invalid-specifier -Wno-format-extra-args -ferror-limit=500   -o conftest.o -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #define _GNU_SOURCE
4: #include <stdlib.h>
5: #include <sys/event.h>
6: int main(void) {
7:   int fd = kqueue();
8: }
/* end */

detected `kqueue`

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/hades/.rvm/gems/truffleruby-20.0.0@thor/extensions/x86_64-darwin/20.0.0/iodine-0.7.38/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/hades/.rvm/gems/truffleruby-20.0.0@thor/gems/iodine-0.7.38 for inspection.
Results logged to /Users/hades/.rvm/gems/truffleruby-20.0.0@thor/extensions/x86_64-darwin/20.0.0/iodine-0.7.38/gem_make.out
@eregon
Copy link
Member

eregon commented May 14, 2020

Does gem install iodine work for you on MRI 2.6?

@eregon
Copy link
Member

eregon commented May 14, 2020

The
mkmf.rb:1299:in 'find_type': wrong number of arguments (given 1, expected 2+) (ArgumentError) error seems similar to #1896.
Probably that's why it fails to install.

@eregon eregon added the cexts label May 14, 2020
@pchaganti
Copy link
Author

Does gem install iodine work for you on MRI 2.6?

Yes. I am currently using Ruby 2.6.5 and iodine works fine with it.

@eregon
Copy link
Member

eregon commented May 15, 2020

The find_type error is fixed by a54e85b.

After that, gem install iodine goes further but still fails for me locally.
One problem there is iodine hardcode and tries its own logic to find the compiler, instead of using the recommended RbConfig::CONFIG["CC"] in https://github.com/boazsegev/iodine/blob/4219633ab4da37f5029146ab07d07c45862af3fd/ext/iodine/extconf.rb
I think that should be fixed upstream.
I'll close this issue because I don't think we can do anything on TruffleRuby's side, it needs a fix upsteam.

@eregon
Copy link
Member

eregon commented May 15, 2020

I filed an upstream issue about that compiler selection problem: boazsegev/iodine#91

@eregon
Copy link
Member

eregon commented May 15, 2020

This is a workaround until fixed upstream:

$ export CC=$(truffleruby -e 'puts RbConfig::CONFIG["CC"]')
$ gem install iodine
Fetching iodine-0.7.38.gem
Building native extensions. This could take a while...
Thank you for installing Iodine 0.7.38.
Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations).
Successfully installed iodine-0.7.38
1 gem installed

@eregon
Copy link
Member

eregon commented May 18, 2020

iodine 0.7.39 was released and now it install out of the box on TruffleRuby:

$ gem i iodine
Fetching iodine-0.7.39.gem
Building native extensions. This could take a while...
Thank you for installing Iodine 0.7.39.
Remember: if iodine supports your business, it's only fair to give value back (code contributions / donations).
Successfully installed iodine-0.7.39
1 gem installed

Thanks for the very quick fix + release @boazsegev!

@eregon eregon added this to the 20.2.0 milestone May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants