Open dounsm opened 3 months ago
@nodejs/build - is this your "thing"?
# Add ARM toolchain to the PATH
export PATH=/path/to/arm/toolchain/bin:$PATH
# Set the cross-compiler prefix
export CROSS_COMPILE=arm-linux-gnueabihf-
# Set the target architecture
export ARCH=arm
# Additional flags for ARMv7
export CFLAGS="-march=armv7-a"
export CXXFLAGS="-march=armv7-a"
export LDFLAGS=""
# Inform the system about the compiler
export CC=${CROSS_COMPILE}gcc
export CXX=${CROSS_COMPILE}g++
export LD=${CROSS_COMPILE}ld
export AR=${CROSS_COMPILE}ar
export AS=${CROSS_COMPILE}as
export NM=${CROSS_COMPILE}nm
export STRIP=${CROSS_COMPILE}strip
I guess your /etc/profile should look something like this.
I modified /etc/profile like this:
export PATH=$PATH:/usr/local/arm-linux/gccl14/bin
# Set the cross-compiler prefix
export CROSS_COMPILE=arm-linux-gnueabihf-
# Set the target architecture
export ARCH=arm
# Additional flags for ARMv7
export CFLAGS="-march=armv7-a"
export CXXFLAGS="-march=armv7-a"
export LDFLAGS=""
# Inform the system about the compiler
export CC=${CROSS_COMPILE}gcc
export CXX=${CROSS_COMPILE}g++
export LD=${CROSS_COMPILE}ld
export AR=${CROSS_COMPILE}ar
export AS=${CROSS_COMPILE}as
export NM=${CROSS_COMPILE}nm
export STRIP=${CROSS_COMPILE}strip
However it didn't work but this time the output was a little different:
When I tried to use ./configure --prefix=/files/nodeinst --dest-cpu=arm --dest-os=linux --cross-compiling --fully-static --with-arm-float-abi=hard
It said:
dso_dlfcn.c:(.text+0xa): 警告: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/arm-linux/gccl14/bin/../lib/gcc/arm-linux-gnueabihf/14.0.0/../../../../arm-linux-gnueabihf/bin/ld: /files/node-20.15.1/out/Release/obj.target/openssl/deps/openssl/openssl/crypto/bio/bio_addr.o: in function `BIO_lookup_ex':
bio_addr.c:(.text+0x7ee): 警告: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/arm-linux/gccl14/bin/../lib/gcc/arm-linux-gnueabihf/14.0.0/../../../../arm-linux-gnueabihf/bin/ld: /files/node-20.15.1/out/Release/obj.target/openssl/deps/openssl/openssl/crypto/bio/bio_sock.o: in function `BIO_gethostbyname':
bio_sock.c:(.text+0x19a): 警告: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
arm-linux-gnueabihf-c++ -o /files/node-20.15.1/out/Release/bytecode_builtins_list_generator -pthread -rdynamic -Wl,--start-group /files/node-20.15.1/out/Release/obj.host/bytecode_builtins_list_generator/deps/v8/src/builtins/generate-bytecodes-builtins-list.o /files/node-20.15.1/out/Release/obj.host/bytecode_builtins_list_generator/deps/v8/src/interpreter/bytecode-operands.o /files/node-20.15.1/out/Release/obj.host/bytecode_builtins_list_generator/deps/v8/src/interpreter/bytecodes.o /files/node-20.15.1/out/Release/obj.host/tools/v8_gypfiles/libv8_libbase.a -static -ldl -lrt -Wl,--end-group
LD_LIBRARY_PATH=/files/node-20.15.1/out/Release/lib.host:/files/node-20.15.1/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/v8_gypfiles; mkdir -p /files/node-20.15.1/out/Release/obj/gen/src/regexp; /usr/bin/python3.10 ../../deps/v8/tools/run.py "/files/node-20.15.1/out/Release/gen-regexp-special-case" "/files/node-20.15.1/out/Release/obj/gen/src/regexp/special-case.cc"
Traceback (most recent call last):
File "/files/node-20.15.1/tools/v8_gypfiles/../../deps/v8/tools/run.py", line 12, in <module>
result = subprocess.call(sys.argv[1:])
File "/usr/lib/python3.10/subprocess.py", line 345, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/files/node-20.15.1/out/Release/gen-regexp-special-case'
LD_LIBRARY_PATH=/files/node-20.15.1/out/Release/lib.host:/files/node-20.15.1/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/icu; mkdir -p /files/node-20.15.1/out/Release/obj/gen; "/files/node-20.15.1/out/Release/icupkg" -tl ../../deps/icu-tmp/icudt75l.dat "/files/node-20.15.1/out/Release/obj/gen/icudt75l.dat"
make[1]: *** [tools/v8_gypfiles/run_gen-regexp-special-case.target.mk:13:/files/node-20.15.1/out/Release/obj/gen/src/regexp/special-case.cc] 错误 1
make[1]: *** 正在等待未完成的任务....
/bin/sh: 1: /files/node-20.15.1/out/Release/icupkg: Exec format error
make[1]: *** [tools/icu/icudata.target.mk:13:/files/node-20.15.1/out/Release/obj/gen/icudt75l.dat] 错误 126
rm 1000c7ad60726045db9ca9ad6feea1577481277c.intermediate 9e6e7cab09adddb5175da5de1cd352430379deea.intermediate
make: *** [Makefile:137:node] 错误 2
Note: 警告
means warning
and 错误
means error
I think that there is a problem with --fully-static
So I use ./configure --prefix=/files/nodeinst --dest-cpu=arm --dest-os=linux --cross-compiling --with-arm-float-abi=hard
(--fully-static
removed)
LD_LIBRARY_PATH=/files/node-20.15.1/out/Release/lib.host:/files/node-20.15.1/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/v8_gypfiles; mkdir -p /files/node-20.15.1/out/Release/obj/gen/src/regexp; /usr/bin/python3.10 ../../deps/v8/tools/run.py "/files/node-20.15.1/out/Release/gen-regexp-special-case" "/files/node-20.15.1/out/Release/obj/gen/src/regexp/special-case.cc"
touch /files/node-20.15.1/out/Release/obj.target/tools/v8_gypfiles/v8_flags.stamp
arm-linux-gnueabihf-g++ -o /files/node-20.15.1/out/Release/obj.target/torque_base/deps/v8/src/torque/cc-generator.o ../deps/v8/src/torque/cc-generator.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_NO_PINSHARED' '-DOPENSSL_THREADS' '-DV8_TARGET_ARCH_ARM' '-DCAN_USE_ARMV7_INSTRUCTIONS' '-DCAN_USE_VFP3_INSTRUCTIONS' '-DCAN_USE_VFP32DREGS' '-DV8_HAVE_TARGET_OS' '-DV8_TARGET_OS_LINUX' '-DV8_EMBEDDER_STRING="-node.23"' '-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' -I../deps/v8 -I../deps/v8/include -pthread -Wno-unused-parameter -Wno-return-type -flax-vector-conversions -fno-strict-aliasing -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -marm -O3 -fno-omit-frame-pointer -fdata-sections -ffunction-sections -O3 -fno-rtti -std=gnu++17 -fexceptions -MMD -MF /files/node-20.15.1/out/Release/.deps//files/node-20.15.1/out/Release/obj.target/torque_base/deps/v8/src/torque/cc-generator.o.d.raw -march=armv7-a -c
Traceback (most recent call last):
File "/files/node-20.15.1/tools/v8_gypfiles/../../deps/v8/tools/run.py", line 12, in <module>
result = subprocess.call(sys.argv[1:])
File "/usr/lib/python3.10/subprocess.py", line 345, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/files/node-20.15.1/out/Release/gen-regexp-special-case'
make[1]: *** [tools/v8_gypfiles/run_gen-regexp-special-case.target.mk:13:/files/node-20.15.1/out/Release/obj/gen/src/regexp/special-case.cc] 错误 1
make[1]: *** 正在等待未完成的任务....
rm 1000c7ad60726045db9ca9ad6feea1577481277c.intermediate 9e6e7cab09adddb5175da5de1cd352430379deea.intermediate
make: *** [Makefile:137:node] 错误 2
It seems that the major problem is /bin/sh: 1: /files/node-20.15.1/out/Release/icupkg: Exec format error
So I checked the path and I found this :
dounsm@dounsmUbuntu:/files/node-20.15.1/out/Release$ readelf -h gen-regexp-special-case
ELF 头:
Magic: 7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00
类别: ELF32
数据: 2 补码,小端序 (little endian)
Version: 1 (current)
OS/ABI: UNIX - GNU
ABI 版本: 0
类型: EXEC (可执行文件)
系统架构: ARM
版本: 0x1
入口点地址: 0x11489
程序头起点: 52 (bytes into file)
Start of section headers: 14279196 (bytes into file)
标志: 0x5000400, Version5 EABI, hard-float ABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 7
Size of section headers: 40 (bytes)
Number of section headers: 34
Section header string table index: 33
dounsm@dounsmUbuntu:/files/node-20.15.1/out/Release$ file gen-regexp-special-case
gen-regexp-special-case: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, BuildID[sha1]=c286ff347974117e887065cc47e0cd6cb639054b, for GNU/Linux 3.2.0, with debug_info, not stripped
NOTE the format is for ARM
Why did it try to run ARM-built program on the host computer? (°ー°〃)
Node.js Version
node-20.15.1
NPM Version
8.5.1
Operating System
Linux dounsmUbuntu 6.5.0-44-generic #44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jun 18 14:36:16 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
Other
Description
Issue during compliing
Something wrong happens during building host tool
icu-tools
And I couldn't get any useful information from the Internet as nobody has the same question
It seems that the building process tries to produce i386 program on my x86-64 ubuntu system.
Environment
configure:
./configure --prefix=/media/dounsm/Program/JDXEnv/node-20.15.1_2/dist --dest-cpu=arm --dest-os=linux --cross-compiling --fully-static --with-arm-float-abi=hard
cross-complier:
gcc-linaro-14.0.0-2023.06-x86_64_arm-linux-gnueabihf
host-complier:
x86_64-linux-gnu 11.4.0
/etc/profile for cross-compling:
Why I do this
I have an arm-based device and I want to install nodejs on it.
Here is the /proc/cpuinfo
So I think I should use armv7l cross-complier
I use
gcc-linaro-14.0.0-2023.06-x86_64_arm-linux-gnueabihf
But I've spent over 5 hours and had no idea to finish it
Minimal Reproduction
Use these commands:
Here is the script I use(
/etc/profile
):Output
As the full output is too long I sorted some out
I use Chinese so there may be some Chinese characters that just mean an error occurred.
Before You Submit