无法在 Solaris 10 SPARC 上编译 Ruby 2.5.1

Unable to compile Ruby 2.5.1 on Solaris 10 SPARC

我正在尝试在 Solaris 10 SPARC 上编译 Ruby 2.5.1,但最终出现以下错误。不确定为什么会得到套接字的未定义符号。

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'

有人可以帮忙吗?

看起来像是 the source code 中的错误。 parse_numeric_port() 仅在以下情况下定义 GETADDRINFO_EMU 未定义,但代码使用 parse_numeric_port() 如果 GETADDRINFO_EMU 已定义或未定义(请注意我添加到代码中的注释):

#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;

您可以找到一种在构建时不定义 GETADDRINFO_EMU 的方法,或者您可以提交错误报告并等待修复。