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

Building native gem extension nio4r fails on mac OS High Sierra due to integer precision / division by zero #178

Closed
msc01 opened this issue Dec 26, 2017 · 2 comments

Comments

@msc01
Copy link

msc01 commented Dec 26, 2017

I'm trying to install the current Rails version on my Mac running High Sierra v10.13.2 but whatever I try, it always fails while building the native gem extensions nio4r.

I'm sure there's something wrong with my system / environment but I can't get my head around the error messages as I'm not really a C developer.

I'm on Ruby 2.4.3 but tried several other versions like 2.5.0, 2.4.0., 2.3.0 via RVM as well. I've found a lot on StackOverflow, etc. around this like missing developer tools and so on, but nothing seems to apply to my situation. Depending on the Ruby version it either fails with integer precision with Ruby 2.4.x or with a division by zero with Ruby 2.5.0.

Here's the error message for Ruby 2.4.3:

ERROR:  Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /Users/ms1/.rvm/gems/ruby-2.4.3/gems/nio4r-2.1.0/ext/nio4r
/Users/ms1/.rvm/rubies/ruby-2.4.3/bin/ruby -r ./siteconf20171226-53648-xef6gq.rb extconf.rb
checking for unistd.h... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... yes
checking for sys/resource.h... yes
creating Makefile

current directory: /Users/ms1/.rvm/gems/ruby-2.4.3/gems/nio4r-2.1.0/ext/nio4r
make "DESTDIR=" clean

current directory: /Users/ms1/.rvm/gems/ruby-2.4.3/gems/nio4r-2.1.0/ext/nio4r
make "DESTDIR="
compiling bytebuffer.c
compiling monitor.c
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:488:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1068:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
  return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
         ~~~~~~~~~~~~~~~~^~
./../libev/ev.c:930:49: note: expanded from macro 'ecb_popcount32'
  #define ecb_popcount32(x) __builtin_popcount (x)
                            ~~~~~~~~~~~~~~~~~~  ^
./../libev/ev.c:1274:13: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
      if (e < (14 - 24)) /* might not be sharp, but is good enough */
          ~ ^  ~~~~~~~
./../libev/ev.c:1836:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
./../libev/ev.c:1923:7: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
      EV_TV_SET (tv, delay);
      ^~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:493:64: note: expanded from macro 'EV_TV_SET'
#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
                                                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:1945:19: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
  if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4)
      ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:2294:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
      k = minpos - heap;
        ~ ~~~~~~~^~~~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:32:8: error: unknown type name 'bool'
extern bool pg_set_noblock(pgsocket sock);
       ^
/usr/local/include/port.h:33:8: error: unknown type name 'bool'
extern bool pg_set_block(pgsocket sock);
       ^
/usr/local/include/port.h:37:8: error: unknown type name 'bool'
extern bool has_drive_prefix(const char *filename);
       ^
/usr/local/include/port.h:46:8: error: unknown type name 'bool'
extern bool path_contains_parent_reference(const char *path);
       ^
/usr/local/include/port.h:47:8: error: unknown type name 'bool'
extern bool path_is_relative_and_below_cwd(const char *path);
       ^
/usr/local/include/port.h:48:8: error: unknown type name 'bool'
extern bool path_is_prefix_of_path(const char *path1, const char *path2);
       ^
/usr/local/include/port.h:62:8: error: unknown type name 'bool'
extern bool get_home_path(char *ret_path);
       ^
/usr/local/include/port.h:210:6: error: unknown type name 'bool'
                          bool echo);
                          ^
/usr/local/include/port.h:263:8: error: unknown type name 'bool'
extern bool rmtree(const char *path, bool rmtopdir);
       ^
/usr/local/include/port.h:263:38: error: unknown type name 'bool'
extern bool rmtree(const char *path, bool rmtopdir);
                                     ^
/usr/local/include/port.h:402:15: error: expected parameter declarator
extern size_t strlcat(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:115:47: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:402:15: error: expected ')'
/usr/include/secure/_string.h:115:47: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
/usr/local/include/port.h:402:15: note: to match this '('
/usr/include/secure/_string.h:115:47: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:53: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                    ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:402:15: error: conflicting types for '__builtin___strlcat_chk'
extern size_t strlcat(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:115:3: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
/usr/local/include/port.h:402:15: note: '__builtin___strlcat_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:115:3: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:406:15: error: expected parameter declarator
extern size_t strlcpy(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:108:47: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:406:15: error: expected ')'
/usr/include/secure/_string.h:108:47: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
/usr/local/include/port.h:406:15: note: to match this '('
/usr/include/secure/_string.h:108:47: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:53: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                    ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:406:15: error: conflicting types for '__builtin___strlcpy_chk'
extern size_t strlcpy(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:108:3: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
/usr/local/include/port.h:406:15: note: '__builtin___strlcpy_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:108:3: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:451:59: error: unknown type name 'bool'
extern int      pg_get_encoding_from_locale(const char *ctype, bool write_message);
                                                               ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
./../libev/ev_port.c:63:7: warning: implicit declaration of function 'port_associate' is invalid in C99 [-Wimplicit-function-declaration]
      port_associate (
      ^
./../libev/ev_port.c:64:22: error: use of undeclared identifier 'PORT_SOURCE_FD'
         backend_fd, PORT_SOURCE_FD, fd,
                     ^
./../libev/ev_port.c:71:20: error: use of undeclared identifier 'EBADFD'
      if (errno == EBADFD)
                   ^
./../libev/ev_port.c:87:9: warning: implicit declaration of function 'port_dissociate' is invalid in C99 [-Wimplicit-function-declaration]
        port_dissociate (backend_fd, PORT_SOURCE_FD, fd);
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
9 warnings and 20 errors generated.
make: *** [nio4r_ext.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ms1/.rvm/gems/ruby-2.4.3/gems/nio4r-2.1.0 for inspection.
Results logged to /Users/ms1/.rvm/gems/ruby-2.4.3/extensions/x86_64-darwin-17/2.4.0/nio4r-2.1.0/gem_make.out

And here is the error message for Ruby 2.5.0:

Building native extensions. This could take a while...
ERROR:  Error installing rails:
	ERROR: Failed to build gem native extension.

    current directory: /Users/ms1/.rvm/gems/ruby-2.5.0/gems/nio4r-2.1.0/ext/nio4r
/Users/ms1/.rvm/rubies/ruby-2.5.0/bin/ruby -r ./siteconf20171226-54876-vvrf2n.rb extconf.rb
checking for unistd.h... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... yes
checking for sys/resource.h... yes
creating Makefile

current directory: /Users/ms1/.rvm/gems/ruby-2.5.0/gems/nio4r-2.1.0/ext/nio4r
make "DESTDIR=" clean

current directory: /Users/ms1/.rvm/gems/ruby-2.5.0/gems/nio4r-2.1.0/ext/nio4r
make "DESTDIR="
compiling bytebuffer.c
compiling monitor.c
monitor.c:95:25: warning: division by zero is undefined [-Wdivision-by-zero]
            RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0, 0)));
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:2470:6: note: expanded from macro 'rb_funcall'
            rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
            ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1775:3: note: expanded from macro 'rb_varargs_argc_check'
         rb_varargs_bad_length(argc, vargc)), \
         ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1770:56: note: expanded from macro 'rb_varargs_bad_length'
#     define rb_varargs_bad_length(argc, vargc) ((argc)/((argc) == (vargc)))
                                                       ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:978:15: note: expanded from macro 'RSTRING_PTR'
    (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
       ~~~~~~~^~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1199:38: note: expanded from macro 'RBASIC'
#define RBASIC(obj)  (R_CAST(RBasic)(obj))
                                     ^~~
monitor.c:95:25: warning: division by zero is undefined [-Wdivision-by-zero]
            RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0, 0)));
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:2470:6: note: expanded from macro 'rb_funcall'
            rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
            ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1775:3: note: expanded from macro 'rb_varargs_argc_check'
         rb_varargs_bad_length(argc, vargc)), \
         ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1770:56: note: expanded from macro 'rb_varargs_bad_length'
#     define rb_varargs_bad_length(argc, vargc) ((argc)/((argc) == (vargc)))
                                                       ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:979:14: note: expanded from macro 'RSTRING_PTR'
     RSTRING(str)->as.ary : \
     ~~~~~~~~^~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1203:39: note: expanded from macro 'RSTRING'
#define RSTRING(obj) (R_CAST(RString)(obj))
                                      ^~~
monitor.c:95:25: warning: division by zero is undefined [-Wdivision-by-zero]
            RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0, 0)));
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:2470:6: note: expanded from macro 'rb_funcall'
            rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
            ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1775:3: note: expanded from macro 'rb_varargs_argc_check'
         rb_varargs_bad_length(argc, vargc)), \
         ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1770:56: note: expanded from macro 'rb_varargs_bad_length'
#     define rb_varargs_bad_length(argc, vargc) ((argc)/((argc) == (vargc)))
                                                       ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:980:14: note: expanded from macro 'RSTRING_PTR'
     RSTRING(str)->as.heap.ptr)
     ~~~~~~~~^~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1203:39: note: expanded from macro 'RSTRING'
#define RSTRING(obj) (R_CAST(RString)(obj))
                                      ^~~
monitor.c:261:25: warning: division by zero is undefined [-Wdivision-by-zero]
            RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0, 0)));
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:2470:6: note: expanded from macro 'rb_funcall'
            rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
            ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1775:3: note: expanded from macro 'rb_varargs_argc_check'
         rb_varargs_bad_length(argc, vargc)), \
         ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1770:56: note: expanded from macro 'rb_varargs_bad_length'
#     define rb_varargs_bad_length(argc, vargc) ((argc)/((argc) == (vargc)))
                                                       ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:978:15: note: expanded from macro 'RSTRING_PTR'
    (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
       ~~~~~~~^~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1199:38: note: expanded from macro 'RBASIC'
#define RBASIC(obj)  (R_CAST(RBasic)(obj))
                                     ^~~
monitor.c:261:25: warning: division by zero is undefined [-Wdivision-by-zero]
            RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0, 0)));
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:2470:6: note: expanded from macro 'rb_funcall'
            rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
            ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1775:3: note: expanded from macro 'rb_varargs_argc_check'
         rb_varargs_bad_length(argc, vargc)), \
         ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1770:56: note: expanded from macro 'rb_varargs_bad_length'
#     define rb_varargs_bad_length(argc, vargc) ((argc)/((argc) == (vargc)))
                                                       ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:979:14: note: expanded from macro 'RSTRING_PTR'
     RSTRING(str)->as.ary : \
     ~~~~~~~~^~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1203:39: note: expanded from macro 'RSTRING'
#define RSTRING(obj) (R_CAST(RString)(obj))
                                      ^~~
monitor.c:261:25: warning: division by zero is undefined [-Wdivision-by-zero]
            RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0, 0)));
            ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:2470:6: note: expanded from macro 'rb_funcall'
            rb_varargs_argc_check(rb_funcall_argc, rb_funcall_nargs), \
            ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1775:3: note: expanded from macro 'rb_varargs_argc_check'
         rb_varargs_bad_length(argc, vargc)), \
         ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1770:56: note: expanded from macro 'rb_varargs_bad_length'
#     define rb_varargs_bad_length(argc, vargc) ((argc)/((argc) == (vargc)))
                                                       ^
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:980:14: note: expanded from macro 'RSTRING_PTR'
     RSTRING(str)->as.heap.ptr)
     ~~~~~~~~^~~~
/Users/ms1/.rvm/rubies/ruby-2.5.0/include/ruby-2.5.0/ruby/ruby.h:1203:39: note: expanded from macro 'RSTRING'
#define RSTRING(obj) (R_CAST(RString)(obj))
                                      ^~~
6 warnings generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:488:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1068:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
  return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
         ~~~~~~~~~~~~~~~~^~
./../libev/ev.c:930:49: note: expanded from macro 'ecb_popcount32'
  #define ecb_popcount32(x) __builtin_popcount (x)
                            ~~~~~~~~~~~~~~~~~~  ^
./../libev/ev.c:1274:13: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
      if (e < (14 - 24)) /* might not be sharp, but is good enough */
          ~ ^  ~~~~~~~
./../libev/ev.c:1836:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
./../libev/ev.c:1923:7: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
      EV_TV_SET (tv, delay);
      ^~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:493:64: note: expanded from macro 'EV_TV_SET'
#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
                                                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:1945:19: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
  if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4)
      ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:2294:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
      k = minpos - heap;
        ~ ~~~~~~~^~~~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:32:8: error: unknown type name 'bool'
extern bool pg_set_noblock(pgsocket sock);
       ^
/usr/local/include/port.h:33:8: error: unknown type name 'bool'
extern bool pg_set_block(pgsocket sock);
       ^
/usr/local/include/port.h:37:8: error: unknown type name 'bool'
extern bool has_drive_prefix(const char *filename);
       ^
/usr/local/include/port.h:46:8: error: unknown type name 'bool'
extern bool path_contains_parent_reference(const char *path);
       ^
/usr/local/include/port.h:47:8: error: unknown type name 'bool'
extern bool path_is_relative_and_below_cwd(const char *path);
       ^
/usr/local/include/port.h:48:8: error: unknown type name 'bool'
extern bool path_is_prefix_of_path(const char *path1, const char *path2);
       ^
/usr/local/include/port.h:62:8: error: unknown type name 'bool'
extern bool get_home_path(char *ret_path);
       ^
/usr/local/include/port.h:210:6: error: unknown type name 'bool'
                          bool echo);
                          ^
/usr/local/include/port.h:263:8: error: unknown type name 'bool'
extern bool rmtree(const char *path, bool rmtopdir);
       ^
/usr/local/include/port.h:263:38: error: unknown type name 'bool'
extern bool rmtree(const char *path, bool rmtopdir);
                                     ^
/usr/local/include/port.h:402:15: error: expected parameter declarator
extern size_t strlcat(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:115:47: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:402:15: error: expected ')'
/usr/include/secure/_string.h:115:47: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
/usr/local/include/port.h:402:15: note: to match this '('
/usr/include/secure/_string.h:115:47: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:53: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                    ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:402:15: error: conflicting types for '__builtin___strlcat_chk'
extern size_t strlcat(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:115:3: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
/usr/local/include/port.h:402:15: note: '__builtin___strlcat_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:115:3: note: expanded from macro 'strlcat'
                __builtin___strlcat_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:406:15: error: expected parameter declarator
extern size_t strlcpy(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:108:47: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:406:15: error: expected ')'
/usr/include/secure/_string.h:108:47: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                             ^
/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'
#    define _USE_FORTIFY_LEVEL 2
                               ^
/usr/local/include/port.h:406:15: note: to match this '('
/usr/include/secure/_string.h:108:47: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                                                            ^
/usr/include/secure/_common.h:39:53: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
                                                    ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:406:15: error: conflicting types for '__builtin___strlcpy_chk'
extern size_t strlcpy(char *dst, const char *src, size_t siz);
              ^
/usr/include/secure/_string.h:108:3: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
/usr/local/include/port.h:406:15: note: '__builtin___strlcpy_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:108:3: note: expanded from macro 'strlcpy'
                __builtin___strlcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
                ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
In file included from ./../libev/ev_port.c:54:
/usr/local/include/port.h:451:59: error: unknown type name 'bool'
extern int      pg_get_encoding_from_locale(const char *ctype, bool write_message);
                                                               ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2701:
./../libev/ev_port.c:63:7: warning: implicit declaration of function 'port_associate' is invalid in C99 [-Wimplicit-function-declaration]
      port_associate (
      ^
./../libev/ev_port.c:64:22: error: use of undeclared identifier 'PORT_SOURCE_FD'
         backend_fd, PORT_SOURCE_FD, fd,
                     ^
./../libev/ev_port.c:71:20: error: use of undeclared identifier 'EBADFD'
      if (errno == EBADFD)
                   ^
./../libev/ev_port.c:87:9: warning: implicit declaration of function 'port_dissociate' is invalid in C99 [-Wimplicit-function-declaration]
        port_dissociate (backend_fd, PORT_SOURCE_FD, fd);
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
9 warnings and 20 errors generated.
make: *** [nio4r_ext.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ms1/.rvm/gems/ruby-2.5.0/gems/nio4r-2.1.0 for inspection.
Results logged to /Users/ms1/.rvm/gems/ruby-2.5.0/extensions/x86_64-darwin-17/2.5.0/nio4r-2.1.0/gem_make.out
@tarcieri
Copy link
Contributor

tarcieri commented Dec 26, 2017

Hi there,

The issues you pointed out regarding casts to different integer sizes are just warnings. They are not the actual culprit. The actual culprit is this (and a few other things):

/usr/local/include/port.h:32:8: error: unknown type name 'bool'
extern bool pg_set_noblock(pgsocket sock);

Something (certainly looks like Postgres) installed a port.h header in /usr/local/include which extconf.rb is misidentifying as the header for Solaris I/O completion ports. It also appears to be using C features (e.g. C99) which the compiler isn't configured to support.

I think (temporarily) removing the file should resolve the issue. extconf.rb could be updated to look for e.g. PORT_SOURCE_FD in port.h rather than assuming any old port.h means we're on Solaris.

@msc01
Copy link
Author

msc01 commented Dec 26, 2017

Hi Tony,

Thanks for replying so quickly to my issue on Christmas!

There was indeed an old port.h file from an abandoned Postgres installation. Removing it solved my issue and nio4r could be built successfully.

Merry Christmas!

Cheers,
Michael

@msc01 msc01 closed this as completed Dec 26, 2017
tarcieri added a commit that referenced this issue Dec 27, 2017
"port.h" is a pretty generic name, and apparently has caused nio4r to
fail to build in practice.

Before trying to use it, make sure it contains the types we expect (for
Solaris I/O completion ports)
tarcieri added a commit that referenced this issue Dec 27, 2017
ext/nio4r/extconf.rb: check for port_event_t in port.h (fixes #178)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants