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

nodejs 14.15.2 and arm32 doesn't compile #36741

Closed
dargo600 opened this issue Jan 2, 2021 · 5 comments
Closed

nodejs 14.15.2 and arm32 doesn't compile #36741

dargo600 opened this issue Jan 2, 2021 · 5 comments
Labels
arm Issues and PRs related to the ARM platform. build Issues and PRs related to build files or the CI.

Comments

@dargo600
Copy link

dargo600 commented Jan 2, 2021

Looks like a code generation issue with v8 engine

I'm getting a compile issue with static assert on code that is generated when using an arm compile using yocto(dunfell). It appears this is typically ported using meta-openembedded but for whatever reason they didn't port nodejs 14 only nodejs12 on any of the yocto versions.

RMV7_INSTRUCTIONS' '-DCAN_USE_VFP3_INSTRUCTIONS' '-DCAN_USE_VFP32DREGS' '-DCAN_USE_NEON' '-DV8_EMBEDDER_STRING="-node.17"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DENABLE_MINOR_MC' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_CONCURRENT_MARKING' '-DV8_ARRAY_BUFFER_EXTENSION' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DDISABLE_UNTRUSTED_CODE_MITIGATIONS' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_SNAPSHOT_COMPRESSION' -I../deps/v8 -I../deps/v8/include -I/home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/torque-output-root -I/home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/generate-bytecode-output-root -pthread -Wno-unused-parameter -Wno-return-type -fno-strict-aliasing -O3 -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -std=gnu++1y -MMD -MF /home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/.deps//home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj.host/v8_initializers/gen/torque-output-root/torque-generated/../../deps/v8/src/builtins/internal-coverage-tq-csa.o.d.raw -c
In file included from ../deps/v8/src/codegen/code-stub-assembler.h:10,
from ../deps/v8/src/builtins/builtins-array-gen.h:8,
from /home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/torque-output-root/torque-generated/../../deps/v8/src/builtins/internal-coverage-tq-csa.cc:1:
../deps/v8/src/base/bit-field.h: In instantiation of 'class v8::base::BitField<bool, 34, 1, unsigned int>':
../deps/v8/src/codegen/code-stub-assembler.h:2858:62: required from 'v8::internal::TNodev8::internal::UintPtrT v8::internal::CodeStubAssembler::DecodeWord(v8::internal::SloppyTNodev8::internal::WordT) [with BitField = v8::base::BitField<bool, 34, 1, unsigned int>]'
../deps/v8/src/codegen/code-stub-assembler.h:2873:66: required from 'v8::internal::TNodev8::internal::Uint32T v8::internal::CodeStubAssembler::DecodeWord32FromWord(v8::internal::SloppyTNodev8::internal::WordT) [with BitField = v8::base::BitField<bool, 34, 1, unsigned int>]'
/home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/torque-output-root/torque-generated/../../deps/v8/src/builtins/internal-coverage-tq-csa.cc:259:195: required from here
../deps/v8/src/base/bit-field.h:26:23: error: static assertion failed: shift < 8 * sizeof(U)
26 | STATIC_ASSERT(shift < 8 * sizeof(U)); // Otherwise shifts by {shift} are UB.
| ~~~~~~^~~~~~~~~~~~~~~
../deps/v8/src/base/macros.h:200:43: note: in definition of macro 'STATIC_ASSERT'
200 | #define STATIC_ASSERT(test) static_assert(test, #test)

The other static compile issue I noticed was here:

RMV7_INSTRUCTIONS' '-DCAN_USE_VFP3_INSTRUCTIONS' '-DCAN_USE_VFP32DREGS' '-DCAN_USE_NEON' '-DV8_EMBEDDER_STRING="-node.17"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DENABLE_MINOR_MC' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_CONCURRENT_MARKING' '-DV8_ARRAY_BUFFER_EXTENSION' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DDISABLE_UNTRUSTED_CODE_MITIGATIONS' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_SNAPSHOT_COMPRESSION' -I../deps/v8 -I../deps/v8/include -I/home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/torque-output-root -I/home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/generate-bytecode-output-root -pthread -Wno-unused-parameter -Wno-return-type -fno-strict-aliasing -O3 -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -std=gnu++1y -MMD -MF /home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/.deps//home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj.host/v8_initializers/gen/torque-output-root/torque-generated/../../deps/v8/src/builtins/internal-coverage-tq-csa.o.d.raw -c
In file included from ../deps/v8/src/codegen/code-stub-assembler.h:10,
from ../deps/v8/src/builtins/builtins-array-gen.h:8,
from /home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/torque-output-root/torque-generated/../../deps/v8/src/builtins/internal-coverage-tq-csa.cc:1:
../deps/v8/src/base/bit-field.h: In instantiation of 'class v8::base::BitField<bool, 34, 1, unsigned int>':
../deps/v8/src/codegen/code-stub-assembler.h:2858:62: required from 'v8::internal::TNodev8::internal::UintPtrT v8::internal::CodeStubAssembler::DecodeWord(v8::internal::SloppyTNodev8::internal::WordT) [with BitField = v8::base::BitField<bool, 34, 1, unsigned int>]'
../deps/v8/src/codegen/code-stub-assembler.h:2873:66: required from 'v8::internal::TNodev8::internal::Uint32T v8::internal::CodeStubAssembler::DecodeWord32FromWord(v8::internal::SloppyTNodev8::internal::WordT) [with BitField = v8::base::BitField<bool, 34, 1, unsigned int>]'
/home/ird/ird-bsp/ird-bsp/build-vector/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/nodejs/14.15.2-r0/node-v14.15.2/out/Release/obj/gen/torque-output-root/torque-generated/../../deps/v8/src/builtins/internal-coverage-tq-csa.cc:259:195: required from here
../deps/v8/src/base/bit-field.h:26:23: error: static assertion failed: shift < 8 * sizeof(U)
26 | STATIC_ASSERT(shift < 8 * sizeof(U)); // Otherwise shifts by {shift} are UB.

@targos targos added arm Issues and PRs related to the ARM platform. build Issues and PRs related to build files or the CI. labels Jan 3, 2021
@Tomaschewski
Copy link

I ran into the exact same issue, just with Buildroot instead of Yocto. But I assume, that the same sequence of events is leading to this result here.

At least for Buildroot, there are two builds of Nodejs: One "host" build, compiled with the host toolchain (i.e. 64 bit architecture in this case) and one "target" build, cross-compiled for the target's architecture (arm 32 bit in this case). Additional parsers, like Torque, are taken from the compiled "host" Nodejs-variant and used to parse e.g. the affected "internal-coverage.tq" into C++ code. But since the tools themselves are compiled for 64 bit, the resulting C++ code is not suitable for the target's 32 bit architecture, see e.g.
v8::base::BitField<bool, 34, 1, unsigned int> (a 34 bit shift does not make a whole lot of sense on an 32 bit integer).

What solved the issue for me was to change the recipe to compile Nodejs as they do here in the CI (see e.g. https://ci.nodejs.org/job/node-cross-compile/nodes=cross-compiler-ubuntu1804-armv7-gcc-8/lastBuild/consoleFull):

  • Having only one cross-compiled target build
  • Providing CC_host and CXX_host as the host toolchain compilers, but with added -m32 flags

Hence, the issue was actually not with Nodejs at all, but with Buildroot's recipe for Nodejs 12 being incompatible with Node 14. Hope that helps to find the issue with Yocto as well!

@mpvader
Copy link

mpvader commented Aug 15, 2021

Hi, I fixed it for OE Dunfell by (also) backporting this patch openembedded/meta-openembedded@f52863f.

And a few more, like newer c-ares and icu.

I think this issue can be closed.

@arw1
Copy link

arw1 commented Aug 19, 2021

@Tomaschewski can you share your working Buildroot recipe for Node 14?

I also want to upgrade the Node version but it does not compile properly on my machine.

Thank you very much in advance!

@dargo600
Copy link
Author

dargo600 commented Oct 25, 2021

Looks like node 14 and node 16 are both in honister and master. I'll agree with this issue can be closed as they obviously got it working somewhere just not on dunfell.
Thanks for the help.

@zhaokai3000
Copy link

@Tomaschewski Does your cross compile toolchain supports "-m32" option?
Would you please show your buildroot makefile for nodejs here?
I did some changes to my buildroot makefile following your instructions but got an error that my cross compile toolchain doesn't support "-m32" option...

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. build Issues and PRs related to build files or the CI.
Projects
None yet
Development

No branches or pull requests

6 participants