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

doc: fix documentation regarding cross-compilation #12556

Closed
irbull opened this issue Apr 20, 2017 · 13 comments
Closed

doc: fix documentation regarding cross-compilation #12556

irbull opened this issue Apr 20, 2017 · 13 comments
Labels
build Issues and PRs related to build files or the CI. doc Issues and PRs related to the documentations. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.

Comments

@irbull
Copy link

irbull commented Apr 20, 2017

  • Version:
  • Platform:
  • Subsystem:

I'm trying to cross compile from Linux to Mac. I'm not even sure it's supposed to work, but according to the docs you can specify a dest-os and a --cross-compiling so I guess it should.

When I first tried to build on Linux for Mac, ./configure threw some errors that XCode was not installed. I understand that you need XCode if you build on a Mac, but is this a requirement when you build for a Mac? I found that if you include --ninja then the XCode dependency was removed. The configuration arguments I'm using are:
./configure --cross-compiling --without-intl --without-inspector --dest-cpu=x64 --dest-os=mac --without-snapshot --without-dtrace --ninja

However, if I then try to link the .a files on a Mac now (I'm linking against some other code I have), then I get the following:

ld: warning: ld: warning: ignoring file ../node.out/mac/x64/src/libv8_libbase.a, file was built for
 unsupported file format ( 0x21 0x3C 0x74 0x68 0x69 0x6E 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 
0x20 0x20 0x20 ) which is not the architecture being linked (x86_64): 
../node.out/mac/x64/src/libv8_libbase.aignoring file ../node.out/mac/x64/src/libv8_base.a, file was built 
for unsupported file format ( 0x21 0x3C 0x74 0x68 0x69 0x6E 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 
0x20 0x20 0x20 ) which is not the architecture being linked (x86_64): 
../node.out/mac/x64/src/libv8_base.a

Any ideas / pointers?

@mscdex
Copy link
Contributor

mscdex commented Apr 20, 2017

Are you sure you have an appropriate macos toolchain installed? It sounds like you may not or at least it's not being picked up (perhaps environment variables are not set correctly).

@mscdex mscdex added build Issues and PRs related to build files or the CI. macos Issues and PRs related to the macOS platform / OSX. question Issues that look for answers. labels Apr 20, 2017
@irbull
Copy link
Author

irbull commented Apr 20, 2017

no, I likely don't. I don't have much experience with cross-compiling (especially from Linux to Mac) so if you have any pointers, that would be greatly appreciated. Thanks!

BTW, just for some context, I have node.js binding for Java, and I'm trying to improve the build process. Right now, I build node on each platform manually, and then link to J2V8, it's not fun :)

@mscdex
Copy link
Contributor

mscdex commented Apr 20, 2017

I don't have any experience with a macos cross-compiler toolchain, but a quick google search turns up this which may work.

@gibfahn
Copy link
Member

gibfahn commented Apr 21, 2017

The xcodebuild and xcrun errors are not a problem, see #12531

@irbull
Copy link
Author

irbull commented Apr 21, 2017

Thanks!

I have managed to build the cross compiler from osxcross and the node.js build started fine. However, it failed part way through with a missing header:
../deps/v8/src/base/platform/platform-linux.cc:13:23: fatal error: sys/prctl.h: No such file or directory

Out of curiosity, how is node.js built? Is it built on a single platform using the --cross-compiler option for all the platforms you support, or is it built on each individual platform?

@gibfahn
Copy link
Member

gibfahn commented Apr 21, 2017

We don't do cross-compiling when we build Node. Basically if you'd like to fix cross-compiling and submit a PR we'll happily accept, but we currently don't test in CI, so you may run into all sorts of issues.

@irbull
Copy link
Author

irbull commented Apr 21, 2017

@gibfahn Thanks. At least I know what I'm up against -- I thought I was being dense that I couldn't figure it out. I'm trying to build it in a docker container too, so if I manage to get it working, it should be portable too. I'll post any progress I make here.

Thanks again for the pointers.

@irbull
Copy link
Author

irbull commented Apr 25, 2017

I have created a GitHub project that contains a set of Dockerfiles that describe the node.js build for a variety of different platforms -- include Android arm, Android x86 and Linux x64. I have also added one for Mac. It uses the toolchain from osxcross, however it doesn't work. The Dockerfiles are here.

It seems even when using a mac toolchain, and specifying --dest-os=mac, node.js still tries to build some Linux dependent code (See my comment above for the error message). I imagine this is because the v8 build is checking the platform on which the build is running, and not using the --dest-os flag.

I'm not sure how --dest-os is supposed to be passed to the V8 build. Furthermore, v8 has changed their build system again, so I'm not sure what docs are relevant for the node.js build.

I'll leave this here in case anyone has ideas how to fix this, or pointers for where to look in the node.js / v8 build.

@refack refack added the doc Issues and PRs related to the documentations. label Apr 25, 2017
@refack
Copy link
Contributor

refack commented Apr 25, 2017

@irbull Since it seems the docs have become irrelevant I'm going to change the title.

@refack refack changed the title Cross compiling from Linux to Mac not working doc: remove irrelevant references to cross-compiling Apr 25, 2017
@refack refack removed build Issues and PRs related to build files or the CI. macos Issues and PRs related to the macOS platform / OSX. question Issues that look for answers. labels Apr 25, 2017
@gibfahn
Copy link
Member

gibfahn commented Apr 27, 2017

Since it seems the docs have become irrelevant I'm going to change the title.

I don't think the docs have become irrelevant, we should still document how it would work, and if someone wants to do the work to get it working (and maybe even tested in CI) then that would be fine. We just don't have anyone who's stepped up to do that yet.

@gibfahn gibfahn added the build Issues and PRs related to build files or the CI. label Apr 27, 2017
@irbull
Copy link
Author

irbull commented Apr 27, 2017

@gibfahn It would be great if we could get this working. I've been pushing on it with the help of another J2V8 contributor. We've managed to get past the linux platform specific compile errors (by manually tweaking some gyp parameters), but now we're stuck at the linking stage. It's using the OSX toolchain, but it's passing linux specific linker arguments (which obviously don't work). I can't figure out where these are coming from.

Our progress is on eclipsesource/J2V8#232. I'm happy to keep pushing forward with this, and if we get anywhere I'd be glad to parameterize this and put together a Pull Request. However, I think I might be stuck again. If anyone with knowledge of cross platform builds knows anything about linker args, I'm all ears.

BTW, the docker approach is really nice. If this works, then we should have an isolated build system that can (in theory) build Node for several platforms from a single command on a single machine.

@refack refack changed the title doc: remove irrelevant references to cross-compiling doc: fix documentation regarding cross-compilation Apr 27, 2017
@refack
Copy link
Contributor

refack commented Apr 27, 2017

@gibfahn Ok.
Updated title to indicate there is a discrepancy between the documentation and what actually works.
IMHO documentation should not promise things the code can't deliver, or describe broken process, as that is a source for frustration...

@Trott Trott added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Aug 4, 2017
@BridgeAR
Copy link
Member

Closing due to lack of participation in the last nine month. If someone thinks differently, please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. doc Issues and PRs related to the documentations. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.
Projects
None yet
Development

No branches or pull requests

6 participants