Search code examples
rubysolaris

Unable to compile Ruby 2.5.1 on Solaris 10 SPARC


Am trying to compile Ruby 2.5.1 on Solaris 10 SPARC where am ended with the below error. Not sure why am getting Undefined symbol for socket.

generating a glommed object with DTrace probes for static library
linking static-library libruby-static.a
generating enc.mk
compiling enc/encinit.c
linking ruby
Undefined                       first referenced
 symbol                             in file
parse_numeric_port                  ext/socket/socket.a(raddrinfo.o)
ld: fatal: Symbol referencing errors. No output written to ruby
collect2: ld returned 1 exit status
*** Error code 1
The following command caused the error:
gcc -std=c99  -L. -L/usr/local/lib -L.  -L/var/tools/openssl/lib main.o ext/extinit.o ext/socket/socket.a ext/cgi/escape/escape.a  ext/continuation/continuation.a ext/racc/cparse/cparse.a  ext/openssl/openssl.a ext/ripper/ripper.a  ext/objspace/objspace.a ext/pty/pty.a ext/zlib/zlib.a  ext/etc/etc.a ext/fcntl/fcntl.a ext/dbm/dbm.a  ext/strscan/strscan.a ext/fiber/fiber.a  ext/readline/readline.a ext/digest/digest.a  ext/digest/bubblebabble/bubblebabble.a ext/digest/md5/md5.a  ext/digest/rmd160/rmd160.a ext/digest/sha1/sha1.a  ext/digest/sha2/sha2.a ext/fiddle/fiddle.a  ext/syslog/syslog.a ext/date/date_core.a  ext/coverage/coverage.a ext/nkf/nkf.a ext/gdbm/gdbm.a  ext/io/console/console.a ext/io/nonblock/nonblock.a  ext/io/wait/wait.a ext/rbconfig/sizeof/sizeof.a  ext/psych/psych.a ext/json/generator/generator.a  ext/json/parser/parser.a ext/stringio/stringio.a  ext/pathname/pathname.a ext/sdbm/sdbm.a  ext/bigdecimal/bigdecimal.a enc/encinit.o enc/libenc.a enc/libtrans.a -lruby-static  -lpthread -lrt -lgmp -lsocket -ldl -lcrypt -lm  -lsocket -lnsl -lssl -lcrypto -lz -lreadline -lncurses -ldl  -lffi -lgdbm -lyaml -lsocket -lnsl -lssl -lcrypto -lz -lreadline -lncurses -ldl  -lffi -lgdbm -lyaml -o ruby
make: Fatal error: Command failed for target `ruby'
Current working directory /usr/share/src/ruby-2.5.1
*** Error code 1
The following command caused the error:
make  EXTOBJS="ext/extinit.o ext/socket/socket.a ext/cgi/escape/escape.a  ext/continuation/continuation.a ext/racc/cparse/cparse.a  ext/openssl/openssl.a ext/ripper/ripper.a  ext/objspace/objspace.a ext/pty/pty.a ext/zlib/zlib.a  ext/etc/etc.a ext/fcntl/fcntl.a ext/dbm/dbm.a  ext/strscan/strscan.a ext/fiber/fiber.a  ext/readline/readline.a ext/digest/digest.a  ext/digest/bubblebabble/bubblebabble.a ext/digest/md5/md5.a  ext/digest/rmd160/rmd160.a ext/digest/sha1/sha1.a  ext/digest/sha2/sha2.a ext/fiddle/fiddle.a  ext/syslog/syslog.a ext/date/date_core.a  ext/coverage/coverage.a ext/nkf/nkf.a ext/gdbm/gdbm.a  ext/io/console/console.a ext/io/nonblock/nonblock.a  ext/io/wait/wait.a ext/rbconfig/sizeof/sizeof.a  ext/psych/psych.a ext/json/generator/generator.a  ext/json/parser/parser.a ext/stringio/stringio.a  ext/pathname/pathname.a ext/sdbm/sdbm.a  ext/bigdecimal/bigdecimal.a enc/encinit.o enc/libenc.a enc/libtrans.a" EXTLIBS="-lsocket -lnsl -lssl -lcrypto -lz -lreadline -lncurses -ldl  -lffi -lgdbm -lyaml"  EXTLDFLAGS="-L/usr/local/lib -L.  -L/var/tools/openssl/lib" EXTINITS="socket cgi/escape continuation racc/cparse openssl ripper  objspace pty zlib etc fcntl dbm strscan fiber readline  digest digest/bubblebabble digest/md5 digest/rmd160  digest/sha1 digest/sha2 fiddle syslog date_core coverage  nkf gdbm io/console io/nonblock io/wait rbconfig/sizeof  psych json/ext/generator json/ext/parser stringio pathname  sdbm bigdecimal"  UPDATE_LIBRARIES="no" SHOWFLAGS= ruby
make: Fatal error: Command failed for target `ruby'
Current working directory /usr/share/src/ruby-2.5.1
*** Error code 1
The following command caused the error:
make -f exts.mk  libdir="/var/tools/ruby251/lib" LIBRUBY_EXTS=./.libruby-with-ext.time \
    EXTENCS="enc/encinit.o enc/libenc.a enc/libtrans.a" UPDATE_LIBRARIES=no static
make: Fatal error: Command failed for target `build-ext'

Can anyone help on this please?


Solution

  • Looks like a bug in the source code. parse_numeric_port() is only defined if GETADDRINFO_EMU isn't defined, but the code uses parse_numeric_port() if GETADDRINFO_EMU is defined or not (note my comments added to the code):

    #ifndef GETADDRINFO_EMU
    struct getaddrinfo_arg
    {
        const char *node;
        const char *service;
        const struct addrinfo *hints;
        struct addrinfo **res;
    };
    
    #ifdef HAVE_INET_PTON
    static int
    parse_numeric_port(const char *service, int *portp)
    {
        unsigned long u;
    
        if (!service) {
            *portp = 0;
            return 1;
        }
    
        if (strspn(service, "0123456789") != strlen(service))
            return 0;
    
        errno = 0;
        u = STRTOUL(service, NULL, 10);
        if (errno)
            return 0;
    
        if (0x10000 <= u)
            return 0;
    
        *portp = (int)u;
    
        return 1;
    }
    #endif
    
    static void *
    nogvl_getaddrinfo(void *arg)
    {
        int ret;
        struct getaddrinfo_arg *ptr = arg;
        ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
    #ifdef __linux__
        /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
         * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
         */
        if (ret == EAI_SYSTEM && errno == ENOENT)
        ret = EAI_NONAME;
    #endif
        return (void *)(VALUE)ret;
    }
    #endif  // *** This closes #ifndef GETADDRINFO_EMU ***
    
    static int
    numeric_getaddrinfo(const char *node, const char *service,
            const struct addrinfo *hints,
            struct addrinfo **res)
    {
    #ifdef HAVE_INET_PTON
    # if defined __MINGW64__
    #   define inet_pton(f,s,d)        rb_w32_inet_pton(f,s,d)
    # endif
    
        int port;
    
        // *** But this uses parse_numeric_port() even if it wasn't defined ***
        if (node && parse_numeric_port(service, &port)) {
        static const struct {
            int socktype;
    

    You can either find a way to NOT have GETADDRINFO_EMU defined when you build, or you can file a bug report and wait for a fix.