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

Cross compile node-v12.* and above, compilation fails #37515

Closed
Jack-he1233 opened this issue Feb 25, 2021 · 6 comments
Closed

Cross compile node-v12.* and above, compilation fails #37515

Jack-he1233 opened this issue Feb 25, 2021 · 6 comments

Comments

@Jack-he1233
Copy link

Jack-he1233 commented Feb 25, 2021

Hello, I cross-compile the node of armV8 architecture on ubuntu20, and use the command as follows:
./configure --prefix=*/node-v12.18.3 --dest-cpu=arm64 --dest-os=linux --without-snapshot --cross-compiling --without-intl
make -j8

What steps will reproduce the bug?

(1)Use the tool chain "gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu"
(2)Import environment variables
(3)Enter the source code file of node-12.18.3 and execute:
./configure --prefix=*/node-v12.18.3 --dest-cpu=arm64 --dest-os=linux --without-snapshot --cross-compiling --without-intl
make -j8
(4)Error message appears:

LD_LIBRARY_PATH=/home/messageflow/cross_compilation_file/0000000000SeRfMgBhrc/888/888/node-v12.18.3/out/Release/lib.host:/home/messageflow/cross_compilation_file/0000000000SeRfMgBhrc/888/888/node-v12.18.3/out/Release/lib.target:$LD_LIBRARY_PATH;
export LD_LIBRARY_PATH;
cd ../tools/v8_gypfiles;
mkdir -p /home/messageflow/cross_compilation_file/0000000000SeRfMgBhrc/888/888/node-v12.18.3/out/Release/obj/gen/generate-bytecode-output-root/builtins-generated;
python ../../deps/v8/tools/run.py
"/home/messageflow/cross_compilation_file/0000000000SeRfMgBhrc/888/888/node-v12.18.3/out/Release/bytecode_builtins_list_generator"
"/home/messageflow/cross_compilation_file/0000000000SeRfMgBhrc/888/888/node-v12.18.3/out/Release/obj/gen/generate-bytecode-output-root/builtins-generated/bytecodes-builtins-list.h"
Traceback (most recent call last):
File "../../deps/v8/tools/run.py", line 12, in
sys.exit(subprocess.call(sys.argv[1:]))
File "/usr/lib/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 394, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
make[1]: *** [tools/v8_gypfiles/generate_bytecode_builtins_list.target.mk:13: /home/messageflow/cross_compilation_file/0000000000SeRfMgBhrc/888/888/node-v12.18.3/out/Release/obj/gen/generate-bytecode-output-root/builtins-generated/bytecodes-builtins-list.h] Error 1
make[1]: *** Waiting for unfinished jobs....
rm f2e0808c1d47bf6fdca65b88327ed0a19993d209.intermediate
make: *** [Makefile:104: node] Error 2

How often does it reproduce? Is there a required condition?

Inevitable event

What is the expected behavior?

The binary node is successfully generated in the "*/node-v12.18.3/out/Release" directory

What do you see instead?

The error message is as above

Additional information

@Jack-he1233
Copy link
Author

@gengjiawen
Is there a solution to this problem?

@gengjiawen
Copy link
Member

As far as I know, our current toolchain only target on armv7 ? Will armv7 an option for you ?
cc @rvagg @nodejs/platform-arm

@rvagg
Copy link
Member

rvagg commented Feb 26, 2021

hm, we don't cross with arm64 in our CI because the native hardware we use is very fast so I can't guarantee it'll work but I don't see why not.

It looks to me like a problem selecting the host compiler so you're not getting binaries that can run on your native arch. Look back through the compile output to see how bytecode_builtins_list_generator is being generated.

You have:

export CC_host="gcc"
export CXX_host="g++"

Can you check that gcc and g++ actually point to a working, native compiler and not a cross? These are the bits that should be doing the native compile portion.

@Jack-he1233
Copy link
Author

@gengjiawen Can you share the toolchain address of your cross-compiled node of armV7 architecture?

@gengjiawen
Copy link
Member

@gengjiawen Can you share the toolchain address of your cross-compiled node of armV7 architecture?

Sure. But you need to know docker.
https://github.com/mmarchini/node-arm-cross-builder

@Jack-he1233
Copy link
Author

After removing the "--with-snapshot" parameter, you can successfully cross-compile. The "--with-snapshot" parameter has certain limitations in cross-compilation

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

3 participants