rubyjs/libv8

V8 6.7+ cannot be compiled on ARM/ARM64

ignisf opened this issue ยท 11 comments

Is this due to the GN change? because it should build on both. An upstream issue link?

@thalyssra, have not dug down enough to find out. The build fails due to missing gn binary for ARM.

Also, when I tried to crosscompile for ARM, the CFLAGS included -march=x86-64 so I stopped it. This warrants more investigation but at this point I cannot spare the time. I would appreciate any hints โค

@thalyssra, I've linked the upstream issue above.

Let me poke someone I know who knows a bit more, I know he was looking into this a long time ago.

steev commented

@ignisf so, there were some upstream changes to gn (which is good!);

I'm not sure how easy it would be to script to replace, however, you should be able to do the following to build a working binary.

git clone https://gn.googlesource.com/gn
python build/gen.py --no-sysroot
ninja -C out
./out/gn_unittests # to run the unit tests and verify they pass

The resulting binary out/gn could then be replaced in whatever location the build scripts are looking for it.

I've only tested the build itself on arm64, I haven't tried to build libv8.

Hello @steev, thank you for the ping

Hi, I managed to build v8 version 6.7.288 on ARM64 (natively on Amazon's Graviton). Is there a way to contribute the binaries?

For the record, the patches were quite involved:

  • infra/mb/mb_config.pyl had to be patched for arm64.release not to cross compile (achieved by replacing the target_cpu of simulate_arm64);
  • gn had to be replaced/rebuilt to work on ARM64;
  • clang had to be replaced with version 7, which is not in the repos yet;
  • A clang plugin (libFindBadConstructs.so) had to be recompiled based on this code and built manually using the following line clang++ *.cpp -c -I /home/ubuntu/clang+llvm-7.0.1-aarch64-linux-gnu/include/ -fPIC -Wall -std=c++14 -fno-rtti -fno-omit-frame-pointer and clang -shared *.o -o libFindBadConstructs.so;
  • We ran into issues right and left with the build system so I ended up calling ninja and the few commands before manually.

At long last however, we finally managed to get those .a!
A script implementing this logic within the context of our project is available here, but is likely very brittle.

Hi everyone! I also managed to compile v8 for this gem for fully working rails application on AWS's Graviton c6g instance.

As said before the main problem is that binaries (clang, gn & ninja) that gonna be used to compile v8 libraries have been built for x86 architecture. i've just tried to recompile them and substitute with original ones.

I've consolidated all my work in Dockerfile in this repo: https://github.com/hypersleep/rails-on-arm That gives you fully-functional ruby on rails app with mini_racer on board.

Hope it helps everybody! I think this process should to be fixed soon on gem build level or in v8 build system due to rising popularity of ARM servers.

Hi everybody. Are there any updates on this issue? I came across this when assembling a mini_racer for M2 Pro. The solution from @hypersleep didn't help, the vanilla version is not building. Added an error message to the discussion.

Closing as this issue is completely sidestepped in libv8-node, which does have aarch64-linux and arm64-darwin builds.

Also there is no chance in freezing hell this v8 version ever supports Apple Silicon, and we're not going to update this gem's v8 version.