Repository navigation
Incorrect selection of x64 push_registers_asm.cc for host build when target is arm (Android) #58975
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Problem
While cross-compiling Node.js (with V8) for Android (target CPU: arm, target OS: android), the build fails during host-side tool compilation because the wrong architecture-specific source file is selected.
Specifically, the file deps/v8/src/heap/base/asm/x64/push_registers_asm.cc is incorrectly selected for the host-side build, but it's compiled with -m32, resulting in the following error:
2025-07-06T04:00:48.2384529Z clang++ -o /home/runner/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/heap/base/asm/x64/push_registers_asm.o ../deps/v8/src/heap/base/asm/x64/push_registers_asm.cc '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_FILE_OFFSET_BITS=64' '-DNODE_OPENSSL_CONF_NAME=nodejs_conf' '-DICU_NO_USER_DATA_OVERRIDE' '-DV8_GYP_BUILD' '-DV8_TYPED_ARRAY_MAX_SIZE_IN_HEAP=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-DV8_TARGET_ARCH_ARM' '-DCAN_USE_ARMV7_INSTRUCTIONS' '-DCAN_USE_VFP3_INSTRUCTIONS' '-DCAN_USE_VFP32DREGS' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_ANDROID' '-DV8_EMBEDDER_STRING="-node.26"' '-DENABLE_DISASSEMBLER' '-DV8_PROMISE_INTERNAL_FIELD_COUNT=1' '-DOBJECT_PRINT' '-DV8_ATOMIC_OBJECT_FIELD_WRITES' '-DV8_ENABLE_LAZY_SOURCE_POSITIONS' '-DV8_USE_SIPHASH' '-DV8_SHARED_RO_HEAP' '-DNDEBUG' '-DV8_WIN64_UNWINDING_INFO' '-DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH' '-DV8_USE_ZLIB' '-DV8_ENABLE_SPARKPLUG' '-DV8_ENABLE_TURBOFAN' '-DV8_ENABLE_WEBASSEMBLY' '-DV8_ENABLE_JAVASCRIPT_PROMISE_HOOKS' '-DV8_ENABLE_CONTINUATION_PRESERVED_EMBEDDER_DATA' '-DV8_ALLOCATION_FOLDING' '-DV8_ALLOCATION_SITE_TRACKING' '-DV8_ADVANCED_BIGINT_ALGORITHMS' '-DUSE_EABI_HARDFLOAT=0' -I../deps/v8 -I../deps/v8/include -I/home/runner/node/out/Release/obj/gen/inspector-generated-output-root -I../deps/v8/third_party/inspector_protocol -I/home/runner/node/out/Release/obj/gen -I/home/runner/node/out/Release/obj/gen/inspector-generated-output-root/include -I/home/runner/node/out/Release/obj/gen/generate-bytecode-output-root -I../deps/v8/third_party/zlib -I../deps/v8/third_party/zlib/google -I../deps/v8/third_party/fp16/src/include -I../deps/v8/third_party/abseil-cpp -Wno-unused-parameter -fPIC -m64 -pthread -m32 -fno-omit-frame-pointer -fPIC -I/home/runner/android-ndk-r27c/sources/android/cpufeatures -fdata-sections -ffunction-sections -O2 -fno-rtti -fno-exceptions -fno-strict-aliasing -std=gnu++20 -Wno-invalid-offsetof -MMD -MF /home/runner/node/out/Release/.deps//home/runner/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/heap/base/asm/x64/push_registers_asm.o.d.raw -c
2025-07-06T04:00:48.4991368Z <inline asm>:5:8: error: register %rbp is only available in 64-bit mode
2025-07-06T04:00:48.5110513Z 5 | push %rbp
2025-07-06T04:00:48.5260675Z | ^
2025-07-06T04:00:48.5270914Z <inline asm>:6:7: error: register %rsp is only available in 64-bit mode
2025-07-06T04:00:48.5271608Z 6 | mov %rsp, %rbp
2025-07-06T04:00:48.5620832Z | ^
2025-07-06T04:00:48.5680614Z <inline asm>:8:8: error: register %rbx is only available in 64-bit mode
2025-07-06T04:00:48.5953695Z 8 | push %rbx
2025-07-06T04:00:48.5954143Z | ^
2025-07-06T04:00:48.5956474Z <inline asm>:9:8: error: register %r12 is only available in 64-bit mode
2025-07-06T04:00:48.6030583Z 9 | push %r12
2025-07-06T04:00:48.6031022Z | ^
2025-07-06T04:00:48.6031468Z <inline asm>:10:8: error: register %r13 is only available in 64-bit mode
2025-07-06T04:00:48.6032093Z 10 | push %r13
2025-07-06T04:00:48.6032754Z | ^
2025-07-06T04:00:48.6033192Z <inline asm>:11:8: error: register %r14 is only available in 64-bit mode
2025-07-06T04:00:48.6033767Z 11 | push %r14
2025-07-06T04:00:48.6034206Z | ^
2025-07-06T04:00:48.6034657Z <inline asm>:12:8: error: register %r15 is only available in 64-bit mode
2025-07-06T04:00:48.6035276Z 12 | push %r15
2025-07-06T04:00:48.6035710Z | ^
2025-07-06T04:00:48.6036158Z <inline asm>:13:7: error: register %rdx is only available in 64-bit mode
2025-07-06T04:00:48.6036748Z 13 | mov %rdx, %r8
2025-07-06T04:00:48.6037168Z | ^
2025-07-06T04:00:48.6037624Z <inline asm>:14:7: error: register %rsp is only available in 64-bit mode
2025-07-06T04:00:48.6038406Z 14 | mov %rsp, %rdx
2025-07-06T04:00:48.6038866Z | ^
2025-07-06T04:00:48.6039328Z <inline asm>:15:9: error: register %r8 is only available in 64-bit mode
2025-07-06T04:00:48.6040168Z 15 | call *%r8
2025-07-06T04:00:48.6040608Z | ^
2025-07-06T04:00:48.6041079Z <inline asm>:16:12: error: register %rsp is only available in 64-bit mode
2025-07-06T04:00:48.6041716Z 16 | add $48, %rsp
2025-07-06T04:00:48.6042148Z | ^
2025-07-06T04:00:48.6042623Z <inline asm>:17:7: error: register %rbp is only available in 64-bit mode
2025-07-06T04:00:48.6043250Z 17 | pop %rbp
2025-07-06T04:00:48.6043688Z | ^
2025-07-06T04:00:48.6044009Z 12 errors generated.
2025-07-06T04:00:48.6045421Z make[1]: *** [tools/v8_gypfiles/v8_base_without_compiler.host.mk:1031: /home/runner/node/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/heap/base/asm/x64/push_registers_asm.o] Error 1
2025-07-06T04:00:48.6046818Z make[1]: *** Waiting for unfinished jobs....
2025-07-06T04:01:32.1166874Z rm 0771b9c84932384d067db46f8c6bf74701e1920a.intermediate 1f1206d9a5609d053b5bfe8d816f99705b11c301.intermediate ed1beb6a745bbc19ddf2f2424646cfbc9813407a.intermediate 5a363a65ac6ae65c9df5c0b3dfbecf1b5dbd42fb.intermediate
2025-07-06T04:01:32.1290208Z make: *** [Makefile:135: node] Error 2
I don't know how to go about fixing it at the moment, so I've opened up issue to ask
Compilation Environment Information
NodeJs Code Version : 22.17.0 lts
Ubuntu 24.04 for GitHub Actions
- OS Version: 24.04.2 LTS
- Kernel Version: 6.11.0-1015-azure
- Image Version: 20250622.1.0
- Systemd version: 255.4-1ubuntu8.8
Android NDK is r27c
Configure the compiled code as
export CXX_host="clang++"
export CC_host="clang"
./android-configure ~/android-ndk-r27c 29 arm
make -j32 LDFLAGS="-Wl,-z,max-page-size=16384 -L/home/ghhc/android-ndk-r27c/obj/local/arm64-v8a -lcpufeatures -Wl,--gc-sections" CFLAGS="-Os -fdata-sections -ffunction-sections"
There's another patch.
diff --git a/android_configure.py b/android_configure.py
index 5cea0393..0aa3c63a 100644
--- a/android_configure.py
+++ b/android_configure.py
@@ -71,7 +71,8 @@ GYP_DEFINES += " v8_target_arch=" + arch
GYP_DEFINES += " android_target_arch=" + arch
GYP_DEFINES += " host_os=" + host_os + " OS=android"
GYP_DEFINES += " android_ndk_path=" + android_ndk_path
+
os.environ['GYP_DEFINES'] = GYP_DEFINES
if os.path.exists("./configure"):
- os.system("./configure --dest-cpu=" + DEST_CPU + " --dest-os=android --openssl-no-asm --cross-compiling")
+ os.system("./configure --dest-cpu=" + DEST_CPU + " --dest-os=android --cross-compiling --openssl-no-asm --partly-static --with-intl=none --shared")
diff --git a/deps/v8/src/base/debug/stack_trace_posix.cc b/deps/v8/src/base/debug/stack_trace_posix.cc
index 0a22cc8a..2ebc0077 100644
--- a/deps/v8/src/base/debug/stack_trace_posix.cc
+++ b/deps/v8/src/base/debug/stack_trace_posix.cc
@@ -37,6 +37,17 @@
#include <AvailabilityMacros.h>
#endif
+#if defined(__ANDROID__)
+extern "C" int backtrace(void**, int) {
+ return 0;
+}
+
+extern "C" char** backtrace_symbols(void* const*, int) {
+ return nullptr;
+}
+#endif
+
+
#include "src/base/build_config.h"
#include "src/base/free_deleter.h"
#include "src/base/logging.h"
diff --git a/deps/v8/src/base/small-vector.h b/deps/v8/src/base/small-vector.h
index edaab3a7..16d6c616 100644
--- a/deps/v8/src/base/small-vector.h
+++ b/deps/v8/src/base/small-vector.h
@@ -22,7 +22,7 @@ template <typename T, size_t kSize, typename Allocator = std::allocator<T>>
class SmallVector {
// Currently only support trivially copyable and trivially destructible data
// types, as it uses memcpy to copy elements and never calls destructors.
- ASSERT_TRIVIALLY_COPYABLE(T);
+ // ASSERT_TRIVIALLY_COPYABLE(T);
static_assert(std::is_trivially_destructible<T>::value);
public:
diff --git a/deps/v8/src/trap-handler/trap-handler.h b/deps/v8/src/trap-handler/trap-handler.h
index 4bf95b8c..be28d784 100644
--- a/deps/v8/src/trap-handler/trap-handler.h
+++ b/deps/v8/src/trap-handler/trap-handler.h
@@ -17,52 +17,7 @@ namespace v8 {
namespace internal {
namespace trap_handler {
-// X64 on Linux, Windows, MacOS, FreeBSD.
-#if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \
- ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_DARWIN || \
- V8_OS_FREEBSD)
-#define V8_TRAP_HANDLER_SUPPORTED true
-// Arm64 (non-simulator) on Mac and Linux.
-#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_ARM64 && \
- (V8_OS_DARWIN || (V8_OS_LINUX && !V8_OS_ANDROID))
-#define V8_TRAP_HANDLER_SUPPORTED true
-// Arm64 simulator on x64 on Linux, Mac, or Windows.
-//
-// The simulator case uses some inline assembly code, which cannot be
-// compiled with MSVC, so don't enable the trap handler in that case.
-// (MSVC #defines _MSC_VER, but so does Clang when targeting Windows, hence
-// the check for __clang__.)
-#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && \
- (V8_OS_LINUX || V8_OS_DARWIN || V8_OS_WIN) && \
- (!defined(_MSC_VER) || defined(__clang__))
-#define V8_TRAP_HANDLER_VIA_SIMULATOR
-#define V8_TRAP_HANDLER_SUPPORTED true
-// Loong64 (non-simulator) on Linux.
-#elif V8_TARGET_ARCH_LOONG64 && V8_HOST_ARCH_LOONG64 && V8_OS_LINUX
-#define V8_TRAP_HANDLER_SUPPORTED true
-// Loong64 simulator on x64 on Linux
-#elif V8_TARGET_ARCH_LOONG64 && V8_HOST_ARCH_X64 && V8_OS_LINUX
-#define V8_TRAP_HANDLER_VIA_SIMULATOR
-#define V8_TRAP_HANDLER_SUPPORTED true
-// RISCV64 (non-simulator) on Linux.
-#elif V8_TARGET_ARCH_RISCV64 && V8_HOST_ARCH_RISCV64 && V8_OS_LINUX
-#define V8_TRAP_HANDLER_SUPPORTED true
-// RISCV64 simulator on x64 on Linux
-#elif V8_TARGET_ARCH_RISCV64 && V8_HOST_ARCH_X64 && V8_OS_LINUX
-#define V8_TRAP_HANDLER_VIA_SIMULATOR
-#define V8_TRAP_HANDLER_SUPPORTED true
-// Everything else is unsupported.
-#else
#define V8_TRAP_HANDLER_SUPPORTED false
-#endif
-
-#if V8_OS_ANDROID && V8_TRAP_HANDLER_SUPPORTED
-// It would require some careful security review before the trap handler
-// can be enabled on Android. Android may do unexpected things with signal
-// handling and crash reporting that could open up security holes in V8's
-// trap handling.
-#error "The V8 trap handler should not be enabled on Android"
-#endif
// Setup for shared library export.
#if defined(BUILDING_V8_SHARED_PRIVATE) && defined(V8_OS_WIN)
diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
index 66b2f73c..12f69bbc 100644
--- a/tools/v8_gypfiles/v8.gyp
+++ b/tools/v8_gypfiles/v8.gyp
@@ -1194,19 +1194,19 @@
'conditions': [
['v8_enable_webassembly==1', {
'conditions': [
- ['((_toolset=="host" and host_arch=="arm64" or _toolset=="target" and target_arch=="arm64") and (OS in "linux mac ios openharmony")) or ((_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS in "linux mac openharmony"))', {
+ ['((_toolset=="host" and host_arch=="arm64") or (_toolset=="target" and target_arch=="arm64")) and (OS=="linux" or OS=="mac" or OS=="ios" or OS=="openharmony") or ((_toolset=="host" and host_arch=="x64") or (_toolset=="target" and target_arch=="x64")) and (OS=="linux" or OS=="mac" or OS=="openharmony")', {
'sources': [
'<(V8_ROOT)/src/trap-handler/handler-inside-posix.cc',
'<(V8_ROOT)/src/trap-handler/handler-outside-posix.cc',
],
}],
- ['(_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and OS=="win"', {
+ ['((_toolset=="host" and host_arch=="x64") or (_toolset=="target" and target_arch=="x64")) and OS=="win"', {
'sources': [
'<(V8_ROOT)/src/trap-handler/handler-inside-win.cc',
'<(V8_ROOT)/src/trap-handler/handler-outside-win.cc',
],
}],
- ['(_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS in "linux mac win openharmony")', {
+ ['((_toolset=="host" and host_arch=="x64") or (_toolset=="target" and target_arch=="x64")) and (OS=="linux" or OS=="mac" or OS=="win" or OS=="openharmony")', {
'sources': [
'<(V8_ROOT)/src/trap-handler/handler-outside-simulator.cc',
],
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Activity
ghhccghk commentedon Jul 6, 2025
In short, compiling under x64 system adds -m32, and then the file selects the x64 version
ghhccghk commentedon Jul 8, 2025
When compiling the x86 version, it reported
thunder-coding commentedon Jul 8, 2025
You can just pass
-m32toCC_hostandCXX_hostas well. Don't pass them viaCFLAGS_hostandCXXFLAGS_hostas the configure.py script doesn't pass them to the compiler when checking if it's gcc or clang.Also you might be interested in checking out patches and build scripts that Termux has for Node v24.x and Node v22.x, as you seem to have duplicated a lot of effort in fixing some of the problems that had already been fixed earlier. You'll find test fixes as well as build fixes for Android over there, I've made significant efforts in fixing as well as tracking tests.
I did try to upstream a lot of those changes in #57748, but it didn't receive any reviews at all
ghhccghk commentedon Jul 9, 2025
I'll try applying these patches.
github-actions commentedon Apr 19, 2026
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
github-actions commentedon May 19, 2026
This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.