Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cross-compilation bug when compiling for ARM64 on a non-ARM64 host with Linux #52512

@devraymondsh

Description

@devraymondsh

Version

v21.7.3

Platform

Linux raymond 6.8.4-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 05 Apr 2024 00:14:23 +0000 x86_64 GNU/Linux

What steps will reproduce the bug?

Cross-compiling for Linux ARM64 on a Linux x86_64 machine.

What is the expected behavior? Why is that the expected behavior?

Should compile.

What do you see instead?

Here's the log:

--snip--

  aarch64-linux-gnu-g++ -o /__w/github-node/github-node/github-node/node/out/Release/obj.target/icuucx/deps/icu-small/source/common/ucnv_set.o ../deps/icu-small/source/common/ucnv_set.cpp '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_HAS_QUIC' '-DICU_NO_USER_DATA_OVERRIDE' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DU_COMMON_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/icu-small/source/common  -pthread -Wall -Wextra -Wno-unused-parameter -fPIC -Wno-deprecated-declarations -Wno-strict-aliasing -O3 -fno-omit-frame-pointer -fno-exceptions -std=gnu++17 -frtti -MMD -MF /__w/github-node/github-node/github-node/node/out/Release/.deps//__w/github-node/github-node/github-node/node/out/Release/obj.target/icuucx/deps/icu-small/source/common/ucnv_set.o.d.raw   -c

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_libplatform.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_libplatform.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_zlib.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_zlib.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/llhttp/libllhttp.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/llhttp/libllhttp.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/llhttp/libllhttp.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/llhttp/libllhttp.a.ar-file-list

ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_libplatform.a @/__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_libplatform.a.ar-file-list

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/cares/libcares.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/cares/libcares.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/uv/libuv.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/uv/libuv.a`

ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_zlib.a @/__w/github-node/github-node/github-node/node/out/Release/obj.host/tools/v8_gypfiles/libv8_zlib.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/nghttp2/libnghttp2.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/nghttp2/libnghttp2.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/brotli/libbrotli.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/brotli/libbrotli.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/nghttp2/libnghttp2.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/nghttp2/libnghttp2.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/openssl/libopenssl.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/openssl/libopenssl.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libngtcp2.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libngtcp2.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/brotli/libbrotli.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/brotli/libbrotli.a.ar-file-list

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/uv/libuv.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/uv/libuv.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libnghttp3.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libnghttp3.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libnghttp3.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libnghttp3.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/base64/libbase64_neon64.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/base64/libbase64_neon64.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libngtcp2.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/ngtcp2/libngtcp2.a.ar-file-list

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/base64/libbase64_neon64.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/base64/libbase64_neon64.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_zlib.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_zlib.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/cares/libcares.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/cares/libcares.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_inflate_chunk_simd.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_inflate_chunk_simd.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_adler32_simd.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_adler32_simd.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_inflate_chunk_simd.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_inflate_chunk_simd.a.ar-file-list

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_adler32_simd.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_adler32_simd.a.ar-file-list

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_arm_crc32.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_arm_crc32.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest.a`

rm -f /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest_main.a ar-file-list; mkdir -p `dirname /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest_main.a`

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_arm_crc32.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/zlib/libzlib_arm_crc32.a.ar-file-list

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest_main.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest_main.a.ar-file-list

  aarch64-linux-gnu-g++ -o /__w/github-node/github-node/github-node/node/out/Release/overlapped-checker -pthread -rdynamic  -Wl,--start-group /__w/github-node/github-node/github-node/node/out/Release/obj.target/overlapped-checker/test/overlapped-checker/main_unix.o  -Wl,--end-group

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_zlib.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/tools/v8_gypfiles/libv8_zlib.a.ar-file-list

  g++ -o /__w/github-node/github-node/github-node/node/out/Release/obj.host/node_js2c/tools/js2c.o ../tools/js2c.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_HAS_QUIC' '-DICU_NO_USER_DATA_OVERRIDE' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DNODE_JS2C_USE_STRING_LITERALS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_POSIX_C_SOURCE=200112' -I../tools -I../src -I../deps/simdutf -I../deps/uv/include  -Wall -Wextra -Wno-unused-parameter -mbranch-protection=standard -pthread -Wall -Wextra -Wno-unused-parameter -fPIC -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -MMD -MF /__w/github-node/github-node/github-node/node/out/Release/.deps//__w/github-node/github-node/github-node/node/out/Release/obj.host/node_js2c/tools/js2c.o.d.raw   -c

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/googletest/libgtest.a.ar-file-list

  g++ -o /__w/github-node/github-node/github-node/node/out/Release/obj.host/node_js2c/src/embedded_data.o ../src/embedded_data.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_HAS_QUIC' '-DICU_NO_USER_DATA_OVERRIDE' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DNODE_JS2C_USE_STRING_LITERALS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_POSIX_C_SOURCE=200112' -I../tools -I../src -I../deps/simdutf -I../deps/uv/include  -Wall -Wextra -Wno-unused-parameter -mbranch-protection=standard -pthread -Wall -Wextra -Wno-unused-parameter -fPIC -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -MMD -MF /__w/github-node/github-node/github-node/node/out/Release/.deps//__w/github-node/github-node/github-node/node/out/Release/obj.host/node_js2c/src/embedded_data.o.d.raw   -c

  g++ -o /__w/github-node/github-node/github-node/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/bits.o ../deps/v8/src/base/bits.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_HAS_QUIC' '-DICU_NO_USER_DATA_OVERRIDE' '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DV8_TARGET_ARCH_ARM64' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_LINUX' '-DV8_EMBEDDER_STRING="-node.20"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_ATOMIC_OBJECT_FIELD_WRITES' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DV8_SHARED_RO_HEAP' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_USE_ZLIB' '-DV8_ENABLE_TURBOFAN' '-DV8_ENABLE_WEBASSEMBLY' '-DV8_ENABLE_JAVASCRIPT_PROMISE_HOOKS' '-DV8_ALLOCATION_FOLDING' '-DV8_ALLOCATION_SITE_TRACKING' '-DV8_ADVANCED_BIGINT_ALGORITHMS' '-DBUILDING_V8_BASE_SHARED' -I../deps/v8 -I../deps/v8/include  -pthread -Wno-unused-parameter -fPIC -Wno-return-type -flax-vector-conversions -Wno-invalid-offsetof -fno-strict-aliasing -m64 -m64 -O3 -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -std=gnu++17 -MMD -MF /__w/github-node/github-node/github-node/node/out/Release/.deps//__w/github-node/github-node/github-node/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/bits.o.d.raw   -c

  g++ -o /__w/github-node/github-node/github-node/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/bounded-page-allocator.o ../deps/v8/src/base/bounded-page-allocator.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_HAS_QUIC' '-DICU_NO_USER_DATA_OVERRIDE' '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DV8_TARGET_ARCH_ARM64' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_LINUX' '-DV8_EMBEDDER_STRING="-node.20"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_ATOMIC_OBJECT_FIELD_WRITES' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DV8_SHARED_RO_HEAP' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_USE_ZLIB' '-DV8_ENABLE_TURBOFAN' '-DV8_ENABLE_WEBASSEMBLY' '-DV8_ENABLE_JAVASCRIPT_PROMISE_HOOKS' '-DV8_ALLOCATION_FOLDING' '-DV8_ALLOCATION_SITE_TRACKING' '-DV8_ADVANCED_BIGINT_ALGORITHMS' '-DBUILDING_V8_BASE_SHARED' -I../deps/v8 -I../deps/v8/include  -pthread -Wno-unused-parameter -fPIC -Wno-return-type -flax-vector-conversions -Wno-invalid-offsetof -fno-strict-aliasing -m64 -m64 -O3 -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -std=gnu++17 -MMD -MF /__w/github-node/github-node/github-node/node/out/Release/.deps//__w/github-node/github-node/github-node/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/bounded-page-allocator.o.d.raw   -c

  g++ -o /__w/github-node/github-node/github-node/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/cpu.o ../deps/v8/src/base/cpu.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DNODE_OPENSSL_HAS_QUIC' '-DICU_NO_USER_DATA_OVERRIDE' '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DV8_TARGET_ARCH_ARM64' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_LINUX' '-DV8_EMBEDDER_STRING="-node.20"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION' '-DOBJECT_PRINT' '-DV8_INTL_SUPPORT' '-DV8_ATOMIC_OBJECT_FIELD_WRITES' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DV8_SHARED_RO_HEAP' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_USE_ZLIB' '-DV8_ENABLE_TURBOFAN' '-DV8_ENABLE_WEBASSEMBLY' '-DV8_ENABLE_JAVASCRIPT_PROMISE_HOOKS' '-DV8_ALLOCATION_FOLDING' '-DV8_ALLOCATION_SITE_TRACKING' '-DV8_ADVANCED_BIGINT_ALGORITHMS' '-DBUILDING_V8_BASE_SHARED' -I../deps/v8 -I../deps/v8/include  -pthread -Wno-unused-parameter -fPIC -Wno-return-type -flax-vector-conversions -Wno-invalid-offsetof -fno-strict-aliasing -m64 -m64 -O3 -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -fno-exceptions -std=gnu++17 -MMD -MF /__w/github-node/github-node/github-node/node/out/Release/.deps//__w/github-node/github-node/github-node/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/cpu.o.d.raw   -c

g++: error: unrecognized command-line option '-mbranch-protection=standard'

make[1]: *** [node_js2c.host.mk:110: /__w/github-node/github-node/github-node/node/out/Release/obj.host/node_js2c/tools/js2c.o] Error 1
make[1]: *** Waiting for unfinished jobs....

g++: error: unrecognized command-line option '-mbranch-protection=standard'

make[1]: *** [node_js2c.host.mk:110: /__w/github-node/github-node/github-node/node/out/Release/obj.host/node_js2c/src/embedded_data.o] Error 1

aarch64-linux-gnu-ar crsT /__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/openssl/libopenssl.a @/__w/github-node/github-node/github-node/node/out/Release/obj.target/deps/openssl/libopenssl.a.ar-file-list

rm d8f608b69cdc2f0bb9d43b231e630e7950e25263.intermediate 34f66c0bec964870ba9e5b2230b46b04e12c9734.intermediate

make: *** [Makefile:134: node] Error 2

Additional information

The -mbranch-protection=standard compiler flag only exists on ARM64 versions of GCC/G++.
This bug happens because as declared in node.gyp the build system passes the -mbranch-protection=standard flag to the compiler when targeting an ARM64 machine which was introduced by this issue and particularly this PR. This is not a problem when the host machine is an ARM64 device and compiles for ARM64, but it is problematic when the host is not an ARM64 device but is trying to compile for an ARM64 device. The solution to this would be to not pass this compiler flag for targets that are meant to be compiled with the host toolchain which is js2c (reference) in this case considering the host not being an ARM64 device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to build files or the CI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions