Skip to content

src: overwrite getaddrinfo for fully static link build in unix

Rodrigo Muino Tomonari requested to merge github/fork/dna2github/dev into master
  • init static link part for dns resolve (not support ipv6)
  • support static linked nodejs on small device on Linux without glibc nss
  • add getaddrinfo.h including new getaddrinfo and freeaddrinfo
  • add defines for fully static link
  • if fully static link, use customized getaddrinfo

Description

After I compiled NodeJS on CentOS 7 with fully static link, I tried npm install and got segment fault and DNS cannot resolve error; I also tried on my target machine with customized kernel without glibc and failed as well. Then I found that the problem is fully static link did not remove the dependency on libnss for resolving domain name. I would like to have NodeJS run on a target machine with minimum Linux without glibc (e.g. with busybox). Therefore I have this solution to make it work. It is for whom want a fully static binary NodeJS running like golang binary without glibc installed (reduce space occupation in some place like device disk and docker image and also avoid some dependencies).

Tested building on CentOS 7 and GCC 4.8.5 with fully static option checked. Tested running on a self compiled Linux Kernel 3.2.95 with Busybox 1.27.2; npm install works

Checklist
  • [o] make -j4 test (UNIX), or vcbuild test (Windows) passes
    • addons/openssl-binding, addons/zlib-binding fail in fully static before my commit, thus disable both)
    • InspectorSocketServerTest.ServerCannotStart: currently new getaddrinfo does not know how to deal with service=0 (bind what port)
    • InspectorSocketServerTest.BindsToIpV6: currently not support ipv6
    • test/parallel/test-http-dns-error.js (timeout)
    • test/parallel/test-net-connect-options-ipv6.js
    • test/parallel/test-net-dns-error.js (timeout)
    • test/parallel/test-npm-install.js (test has bug, the program should create test folder. npm ERR! enoent ENOENT: no such file or directory, stat '/root/tmp/node/test/.tmp.0/npm-sandbox/home')
    • test/abort/test-abort-backtrace.js (not know what it is AssertionError [ERR_ASSERTION]: Some frames should include the binary name)
    • many segfault for test addons like the result before my commit
    • in summary, make more tests passed in fully static link mode
  • tests and/or benchmarks are included (check for testing manually for example npm install express ssh2, write an express app in index.js and node index.js and test in browser; could you guide me more?)
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

dns in fully static link in unix world

Merge request reports

Loading