Skip to content

how the official linux binary is built? #17855

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

Closed
shyhpei opened this issue Dec 25, 2017 · 4 comments
Closed

how the official linux binary is built? #17855

shyhpei opened this issue Dec 25, 2017 · 4 comments
Labels
question Issues that look for answers.

Comments

@shyhpei
Copy link

shyhpei commented Dec 25, 2017

Version: 6.11.5
Platform: Linux fcdev 4.13.13-300.fc27.x86_64 #1 SMP Wed Nov 15 15:47:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I am trying to build nodejs binary on a Fedora 27 host, using --fully-static, because my target host is Fedora Core 6. This is how I build:

./configure --fully-static
make -j

The compile/link would go thru and generate a node binary, with some warnings similar to the one below:

dso_dlfcn.c:(.text+0x12): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/syen/src/node-v6.11.5/out/Release/obj.target/node/src/node.o: In function `node::InitGroups(v8::FunctionCallbackInfov8::Value const&)':

But I could run this node binary just fine on the Fedora 27 build host. But when I copy node binary to my target Fedora 6 host and run it, it would segment fault immediately without even get to the ">" prompt.

The weird thing is, the official linux binary from nodejs.org site would have no problem running on my target Fedora 6 host. I can get a ">" prompt, and I can execute my javascript with this binary.

So, my questions:

  1. how is the official node binary for linux built?
  2. why my "--fully-static" binary build would still generate some binary that will reference a shared glibc library?

I've looked up and down on nodejs website and I couldn't find any documentation on how the official binary was built...

@starkwang starkwang added the question Issues that look for answers. label Dec 25, 2017
@starkwang
Copy link
Contributor

Hi! This issue tracker is for bugs and issues found within Node.js core.
For more general support questions like this one, please file an issue in our help
repo: https://github.com/nodejs/help

Thanks!

@shyhpei
Copy link
Author

shyhpei commented Dec 25, 2017

Sorry for filing this in wrong place and thanks for pointing out where to ask my question.

@joyeecheung
Copy link
Member

@starkwang @shyhpei This doesn't look too far away from Node core..

  1. The official release is built with this:

node/Makefile

Lines 918 to 940 in 81c2b59

$(BINARYTAR): release-only
$(RM) -r $(BINARYNAME)
$(RM) -r out/deps out/Release
$(PYTHON) ./configure \
--prefix=/ \
--dest-cpu=$(DESTCPU) \
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
$(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
cp README.md $(BINARYNAME)
cp LICENSE $(BINARYNAME)
cp CHANGELOG.md $(BINARYNAME)
ifeq ($(OSTYPE),darwin)
SIGN="$(CODESIGN_CERT)" PKGDIR="$(BINARYNAME)" bash tools/osx-codesign.sh
endif
tar -cf $(BINARYNAME).tar $(BINARYNAME)
$(RM) -r $(BINARYNAME)
gzip -c -f -9 $(BINARYNAME).tar > $(BINARYNAME).tar.gz
ifeq ($(XZ), 0)
xz -c -f -$(XZ_COMPRESSION) $(BINARYNAME).tar > $(BINARYNAME).tar.xz
endif
$(RM) $(BINARYNAME).tar

  1. Because of getaddrinfo IIRC. You can try linking against musl if you want a more static binary.

@bnoordhuis
Copy link
Member

FTR, also answered in nodejs/help#1039.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

4 participants