mirror of
git://git.openembedded.org/meta-openembedded
synced 2026-10-24 22:06:34 +00:00
nodejs: support cross compile without qemu user conditionally
Due to the scope of supported BSPs by qemu-user is limited, such as a segment fault on armv9 after qemu apply commit [target/arm: Convert LDAPR/STLR (imm) to decodetree][1] ``` |tmp-glibc/work/neoversen2-crypto-wrs-linux/nodejs/20.5.1/node-v20.5.1/out/ Release/v8-qemu-wrapper.sh: line 7: 3179613 Segmentation fault (core dumped) PSEUDO_UNLOAD=1 qemu-aarch64 -r 5.15 -L tmp-glibc/work/neoversen2-crypto-wrs-linux/ nodejs/20.5.1/recipe-sysroot -E LD_LIBRARY_PATH=tmp-glibc/work/neoversen2-crypto-wrs-linux/ nodejs/20.5.1/recipe-sysroot/usr/lib64:tmp-glibc/work/neoversen2-crypto-wrs-linux/ nodejs/20.5.1/recipe-sysroot/usr/lib64 "$@" ``` Upstream nodejs have cross compile support, but it needs host and target have same bit width (e.g. a x86_64 host targeting arrch64 to produce a 64-bit binary). So: 1. If host and target have different bit width, build with QEMU user as usual; 2. If host and target have same bit width, enable notejs cross compile support: - The build tools of nodejs is GYP[2], set CC_host, CFLAGS_host, CXX_host, CXXFLAGS_host, LDFLAGS_host, AR_host for host build which is separated with target build [3] - Satisfy layer compatibility, set GYP variables in prefuncs of do_configure, do_compile and do_install other than in recipe parsing - Add missing native packages to fix library missing on host build - Rework libatomic.patch, explicitly link to libatomic for clang conditionally [1] https://github.com/qemu/qemu/commit/2521b6073b7b4b505533a941d4f9600f7585dc78 [2] https://github.com/nodejs/node-gyp [3] https://github.com/nodejs/node-gyp/blob/main/gyp/docs/UserDocumentation.md#cross-compiling Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
1 parent
ddd322323e
commit
32da6bfb0e
2 files changed
+126
-45
No files matched your search
@@ -1,21 +1,77 @@
|
||||
Link mksnapshot with libatomic on x86
|
||||
From 15e751e4b79475fb34e4b32a3ca54119b20c564a Mon Sep 17 00:00:00 2001
|
||||
From: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
Date: Sat, 17 Aug 2024 21:33:18 +0800
|
||||
Subject: [PATCH] link libatomic for clang conditionally
|
||||
|
||||
Clang-12 on x86 emits atomic builtins
|
||||
Clang emits atomic builtin, explicitly link libatomic conditionally:
|
||||
- For target build, always link -latomic for clang as usual
|
||||
- For host build, if host and target have same bit width, cross compiling
|
||||
is enabled, and host toolchain is gcc which does not link -latomic;
|
||||
if host and target have different bit width, no cross compiling,
|
||||
host build is the same with target build that requires to link
|
||||
-latomic;
|
||||
|
||||
Fixes
|
||||
| module-compiler.cc:(.text._ZN2v88internal4wasm12_GLOBAL__N_123ExecuteCompilationUnitsERKSt10shared_ptrINS2_22BackgroundCompileTokenEEPNS0_8CountersEiNS2_19CompileBaselineOnlyE+0x558): un
|
||||
defined reference to `__atomic_load'
|
||||
Fix:
|
||||
|tmp-glibc/work/core2-64-wrs-linux/nodejs/20.13.0/node-v20.13.0/out/Release/node_js2c: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
Upstream-Status: Inappropriate [OE specific]
|
||||
|
||||
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
|
||||
---
|
||||
node.gyp | 13 ++++++++++++-
|
||||
tools/v8_gypfiles/v8.gyp | 15 ++++++++++++---
|
||||
2 files changed, 24 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/node.gyp b/node.gyp
|
||||
index b425f443..f296f35c 100644
|
||||
--- a/node.gyp
|
||||
+++ b/node.gyp
|
||||
@@ -487,7 +487,18 @@
|
||||
],
|
||||
}],
|
||||
['OS == "linux" and llvm_version != "0.0"', {
|
||||
- 'libraries': ['-latomic'],
|
||||
+ 'target_conditions': [
|
||||
+ ['_toolset=="host"', {
|
||||
+ 'conditions': [
|
||||
+ ['"<!(echo $HOST_AND_TARGET_SAME_WIDTH)"=="0"', {
|
||||
+ 'libraries': ['-latomic'],
|
||||
+ }],
|
||||
+ ],
|
||||
+ }],
|
||||
+ ['_toolset=="target"', {
|
||||
+ 'libraries': ['-latomic'],
|
||||
+ }],
|
||||
+ ],
|
||||
}],
|
||||
],
|
||||
},
|
||||
diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
|
||||
index b23263cf..dcabf4ca 100644
|
||||
--- a/tools/v8_gypfiles/v8.gyp
|
||||
+++ b/tools/v8_gypfiles/v8.gyp
|
||||
@@ -1436,6 +1436,7 @@
|
||||
{
|
||||
'target_name': 'mksnapshot',
|
||||
'type': 'executable',
|
||||
+ 'libraries': [ '-latomic' ],
|
||||
'dependencies': [
|
||||
'v8_base_without_compiler',
|
||||
'v8_compiler_for_mksnapshot',
|
||||
@@ -1100,9 +1100,18 @@
|
||||
# Platforms that don't have Compare-And-Swap (CAS) support need to link atomic library
|
||||
# to implement atomic memory access
|
||||
['v8_current_cpu in ["mips64", "mips64el", "ppc", "arm", "riscv64", "loong64"]', {
|
||||
- 'link_settings': {
|
||||
- 'libraries': ['-latomic', ],
|
||||
- },
|
||||
+ 'target_conditions': [
|
||||
+ ['_toolset=="host"', {
|
||||
+ 'conditions': [
|
||||
+ ['"<!(echo $HOST_AND_TARGET_SAME_WIDTH)"=="0"', {
|
||||
+ 'libraries': ['-latomic'],
|
||||
+ }],
|
||||
+ ],
|
||||
+ }],
|
||||
+ ['_toolset=="target"', {
|
||||
+ 'libraries': ['-latomic', ],
|
||||
+ }],
|
||||
+ ],
|
||||
}],
|
||||
],
|
||||
}, # v8_base_without_compiler
|
||||
--
|
||||
2.35.5
|
||||
|
||||
Reference in new issue
Block a user