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

document cross compile arm on linux #35252

Open
gengjiawen opened this issue Sep 18, 2020 · 11 comments
Open

document cross compile arm on linux #35252

gengjiawen opened this issue Sep 18, 2020 · 11 comments
Labels
arm Issues and PRs related to the ARM platform. doc Issues and PRs related to the documentations.

Comments

@gengjiawen
Copy link
Member

I didn't find it in BUILDING.md, but it looks like this in our Jenkins CI.

cc @bnoordhuis @targos @nodejs/platform-arm

@rvagg
Copy link
Member

rvagg commented Sep 21, 2020

This is for armv6 (ancient, tho used by unofficial-builds still) and armv7, primarily aimed at Raspberry Pi as a baseline:

https://github.com/nodejs/build/blob/364b8a9d0efe473b22cc04e6b4fa63a4b5e1d67a/ansible/roles/docker/files/cc-selector.sh is the script that figures out what it needs to compile and sets up the environment for compiling using environment variables which configure & Makefile use.

Cross compile tools used are here https://github.com/rvagg/rpi-newer-crosstools

@watilde watilde added the doc Issues and PRs related to the documentations. label Sep 22, 2020
@gengjiawen
Copy link
Member Author

@rvagg Just to make sure, can this be done to in a docker image ?

@gengjiawen

This comment has been minimized.

@gengjiawen
Copy link
Member Author

gengjiawen commented Sep 23, 2020

Below failed with new error.

apt install gcc-multilib g++-multilib -y
apt install lib32z1-dev gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
ln -s /usr/include/asm-generic /usr/include/asm
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ CC_host="gcc -m32" CXX_host="g++ -m32" ./configure --dest-cpu=arm --cross-compiling --dest-os=linux
make -j8

Failed with:

  g++ -m32 -o /root/node/out/Release/mksnapshot -pthread -rdynamic -m32  -Wl,--start-group /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/embedded-empty.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/embedded-file-writer.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-aix.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-base.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-mac.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-win.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/mksnapshot.o /root/node/out/Release/obj.host/mksnapshot/deps/v8/src/snapshot/snapshot-empty.o /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_base_without_compiler.a /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_init.a /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_libbase.a /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_libplatform.a /root/node/out/Release/obj.host/tools/icu/libicutools.a /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_libsampler.a /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_zlib.a /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_compiler.a /root/node/out/Release/obj.host/tools/v8_gypfiles/libv8_initializers.a -latomic -ldl -lrt -Wl,--end-group
  touch 754ac2b9be6dad0d787f347675b94fc76885c25e.intermediate
  LD_LIBRARY_PATH=/root/node/out/Release/lib.host:/root/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/v8_gypfiles; mkdir -p /root/node/out/Release/obj.target/v8_snapshot/geni; "/root/node/out/Release/mksnapshot" --turbo_instruction_scheduling "--target_os=linux" "--target_arch=arm" --startup_src "/root/node/out/Release/obj.target/v8_snapshot/geni/snapshot.cc" --embedded_variant Default --embedded_src "/root/node/out/Release/obj.target/v8_snapshot/geni/embedded.S" --no-native-code-counters


#
# Fatal error in , line 0
# unreachable code
#
#
#
#FailureMessage Object: 0xf7243fd4Aborted (core dumped)
make[1]: *** [tools/v8_gypfiles/v8_snapshot.target.mk:17: 754ac2b9be6dad0d787f347675b94fc76885c25e.intermediate] Error 134
make[1]: *** Waiting for unfinished jobs....
rm c6fc3b144c2c2c043e31af246edb4dbfb14c7156.intermediate b526cacdb009d9043833bcd06f98ac686fca6a10.intermediate 754ac2b9be6dad0d787f347675b94fc76885c25e.intermediate c96bbeb3f85793f3eac5a4ed576b0ecaa045b4fe.intermediate 90a906610746ab46c26081c72bb287fcde287c13.intermediate ecff0af5c31084ad57edfbfe7a9fc8e888d67a52.intermediate
make: *** [Makefile:104: node] Error 2

@gengjiawen gengjiawen added the arm Issues and PRs related to the ARM platform. label Sep 23, 2020
@rvagg
Copy link
Member

rvagg commented Sep 23, 2020

Yep, here's the Dockerfile we use for all the cases https://github.com/nodejs/build/blob/master/ansible/roles/docker/templates/ubuntu1604_arm_cross.Dockerfile.j2

I don't think we touch the generic arm-linux-gnueabihf toolchain anywhere in our CI lineup because it doesn't quite cover the cases we want; or at least it hasn't in the past. It could be you're hitting a genuine bug because it's missing in our coverage, my guess would be something else about the configuration steps involved here though.

@gengjiawen
Copy link
Member Author

@rvagg Thanks. That's great help. With the help of nodejs/TSC#931 (comment) by @mmarchini , I successfully build arm version. Though not running due to kernel.

My previous build failure reason stays unknown though. Maybe related to gcc (I am on ubuntu 20.04 with gcc 9.3) ?

@gengjiawen
Copy link
Member Author

gengjiawen commented Sep 26, 2020

Update: it's actually in ./out/tools/v8_gypfiles/v8_base_without_compiler.host.mk. The reported url in console is not accurate.

Looks build failure will cause mk file auto delete. like I can't `tools/v8_gypfiles/v8_base_without_compiler.host.mk` in following build failure:
/tmp/cc2FUjAY.s: Assembler messages:
/tmp/cc2FUjAY.s:7: Error: invalid char '{' beginning operand 1 `{r3-r11'
/tmp/cc2FUjAY.s:8: Error: too many memory references for `mov'
/tmp/cc2FUjAY.s:9: Error: too many memory references for `mov'
/tmp/cc2FUjAY.s:10: Error: no such instruction: `blx r3'
/tmp/cc2FUjAY.s:11: Error: too many memory references for `add'
/tmp/cc2FUjAY.s:12: Error: invalid char '{' beginning operand 1 `{pc}'
tools/v8_gypfiles/v8_base_without_compiler.host.mk:710: recipe for target '/root/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/heap/base/asm/arm/push_registers_asm.o' failed

How do I prevent this ?

@gengjiawen
Copy link
Member Author

gengjiawen commented Sep 28, 2020

@rvagg Is there a plan for cc-selector.sh support ubuntu 20.04 and gcc-9 ?

@rvagg
Copy link
Member

rvagg commented Sep 28, 2020

@gengjiawen we haven't directly discussed potential updates to this yet. It's designed to match https://github.com/nodejs/node/blob/master/BUILDING.md#official-binary-platforms-and-toolchains and needs to ensure maximum binary compatibility.

We've just locked down 15.x @ nodejs/build#2423 and it's not changing for that.

16.x planning has opened up @ nodejs/build#2445 but the only thing that's been agreed is that we need to get to at least GCC 7.

The problem with the cross compiler is that we don't have the nice backward compatibility afforded by devtoolsets on CentOS like on our other Linux release builders. Vanilla GCC is pretty sad for binary compatibility in that it's tied directly to libc and libstdc++ versions. So your binaries become tied to the computer you build on; so the GCC version and base operating system version matters. We'll have to look at the 18.04 support window and see if it aligns OK with the 16.x window (I haven't checked yet). But there's even risks with that and pulling in a libstdc++ (or just a libc) that is too new and then our binaries won't work on older platforms.

@JMLX42
Copy link

JMLX42 commented Nov 27, 2022

My previous #35252 (comment) reason stays unknown though. Maybe related to gcc (I am on ubuntu 20.04 with gcc 9.3) ?

@gengjiawen did you ever find out?

I'm running into the same issue with this build script. I'm using the same Docker image in both cases, but:

  • It works in Docker 20.10.21 / Ubuntu 22.04
  • It does not work in Docker 18.06.1-ce / Ubuntu 18.04

I'll try to upgrade Docker.

@JMLX42
Copy link

JMLX42 commented Nov 27, 2022

I'll try to upgrade Docker.

Upgrading Docker (Ubuntu 18.04 / Docker 20.10) apparently worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm Issues and PRs related to the ARM platform. doc Issues and PRs related to the documentations.
Projects
None yet
Development

No branches or pull requests

4 participants