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

how the official linux binary is built? #1039

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

how the official linux binary is built? #1039

shyhpei opened this issue Dec 25, 2017 · 14 comments

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...

@bnoordhuis
Copy link
Member

how is the official node binary for linux built?

Nothing special, there's no secret sauce. Look for the $(BINARYTAR) target in the Makefile.

We do compile it on the oldest supported system for forward compatibility. So if you want to target Fedora 6 (is that a typo?) and 27, compile on the older system and copy the binary to the newer system, not the other way around.

why my "--fully-static" binary build would still generate some binary that will reference a shared glibc library?

That's because glibc is written that way, it's not specific to node.js. You probably want --partly-static.

@shyhpei
Copy link
Author

shyhpei commented Dec 25, 2017

Many thanks for the quick reply!

I will definitely look into the $(BINARYTAR) target in Makefile.

Yes, I know it sounds "wrong" :-) but that's not a typo - I do have a Fedora 6 target. The reason I tried to build on Fedora 27 instead of 6 is because I couldn't get it to compile on Fedora 6. I think one of the reasons is gcc version is too old on Fedora 6 to compile node.

Can you please let me know what is the "oldest supported system". I think I should install the same thing and do my build there. That way, I can be sure it will work on my Fedora 6 target.

Thanks again for your help!

@bnoordhuis
Copy link
Member

For Fedora, it's what Fedora supports - not FC6. :-)

I suspect you're going to have trouble with libstdc++ being too old. As a workaround, you could try --fully-static but linking against musl instead of glibc. Google for musl-gcc.

@bnoordhuis
Copy link
Member

Oh, another thing: if your kernel is < 2.6.18, you're out of luck (but FC6 was 2.6.20, IIRC?)

@shyhpei
Copy link
Author

shyhpei commented Dec 26, 2017

@joyeecheung @bnoordhuis - many thanks for your help.

I will give it a try to see if I can build binary that will work with FC6 (2.6.22.14-72.fc6). Will report back here.

@shyhpei
Copy link
Author

shyhpei commented Jan 27, 2018

Sorry for the long delay to report back my progress. Was off to some other projects and now coming back to this since past week.

I am still not able to build a node binary that will work with FC6, even I tried build the whole thing on an FC6. Here is my "struggling" (all done on a freshly installed FC6 VM with development RPM packages):

  1. tried without any additional tools - configure failed for no Python2.7 (FC6 stocked Python is 2.4.4)
  2. download and build Python-2.7.1
  3. tried node build again - complain about needing g++ 4.8 and gcc 4.2 (not sure why two different versions?)
  4. download and build gcc-4.8.1 (it took forever to compile gcc...)
  5. warning for node configure is gone, but build failed due to invalid option T for ar command
  6. ar is in binutils package, download and build binutils-2.23.2 (because it matches gcc-4.8.1 in FC16?)
  7. node build goes much longer this time, but in the end, it failed with out/Release/mksnapshot unable to find certain GLIBCXX versions in FC6 system's /usr/lib64/libstdc++.so.6 file.

At this point, I don't know how to move forward, as I am not sure why mksnapshot was built (I assume it was built during building node binary build) with reference to a newer libstdc++ but when it is executed trying to load older libstdc++.

Reading dtopham75's #1073, I think I might need to explore devtools, but predict to get devtools on FC6 might also be challenging. scrape that - seems like devtools is RedHat commercial product?

@dtopham75
Copy link

Devtoolset for CentOS is part of Software Collections (https://www.softwarecollections.org/en/), specifically at https://www.softwarecollections.org/en/scls/?search=devtoolset for the various available versions.

I'm using CentOS as the build environment rather than RHEL, so I'm followed the instructions to get the Devtoolset from there. I'm not sure how this relates to the Devtoolset available from RedHat (https://developers.redhat.com/products/developertoolset/overview/), which requires a RedHat Enterprise subscription, but it appears to offer the same features.

The instructions on Software Collections describe how to deploy on both CentOS and RHEL. However, I don't know whether it's going to work on Fedora Core 6.

@kasicka
Copy link

kasicka commented Jan 29, 2018

@shyhpei why are you using Fedora Core 6?

Software Collections and Devtoolset are not built for Fedora, only for RHEL and CentOS. You could try building node on CentOS 6 and then running it on your FC6 host, but I am not sure it will work.

@shyhpei
Copy link
Author

shyhpei commented Jan 29, 2018

@dtopham75 - thanks for pointing that out. Will definitely take a look of the Software Collections and see if I can generate a binary for earlier version of CentOS will work for FC6.

@kasicka - we have an embedded system which is running on FC6 and we need node, with FIPS (that's why we need to build it instead of just using official binary)

@gireeshpunathil
Copy link
Member

@shyhpei - is this still outstanding?

@shyhpei
Copy link
Author

shyhpei commented Apr 5, 2018

@gireeshpunathil - sorry I should close this.

No, I am still not able to make a shared-library binary for FC6 on any build environment that has gcc version at or above 4.8.x (requirement). I can only build with --fully-static then it'll run on FC6. And that's what I currently am using but I am not sure about the stability on that build as glibc won't be "fully-static" as @bnoordhuis pointed out earlier.

Also, I was having problem install Software Collections on CentOS as it refused to install for some dependency problem. I gave up on that also.

@shyhpei shyhpei closed this as completed Apr 5, 2018
@gireeshpunathil
Copy link
Member

sorry to hear that your problem is not fully resolved. Do you believe any additional information / workarounds / configuration from Node build setup will help resolve your issues, if so we can re-open it and progress, but if the problem is deeply rooted in the underlying system / incompatible build toolchain / runtime systems etc. I guess there is nothing we can do about that! Let me know what do you think.

@kasicka
Copy link

kasicka commented Apr 5, 2018

Also, I was having problem install Software Collections on CentOS as it refused to install for some dependency problem. I gave up on that also.

@shyhpei Please file a bug, but devtoolset should be functional

@shyhpei
Copy link
Author

shyhpei commented Apr 5, 2018

Appreciate all the helps I got here. But I think I am fine with my current fully-static on glibc build unless it crashes on me later on. :-)

The only thing that I don't understand is how the official nodejs build machine, I assume it's using a gcc version > 4.8.x, can make a shared glibc nodejs binary that can run on FC6 without any problem. The glibc on FC6 is completely incompatible with the glibc for 4.8.x...

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

5 participants