I try to compile to compile node.js on an embedded linux in a chroot (armel wheezy) environment. The system has all necessary versions of tools.
Python 2.7.3
GCC 4.6
GNU Make 3.81
CPUInfo:
Processor : ARMv7 Processor rev 10 (v7l)
processor : 0
BogoMIPS : 790.52
processor : 1
BogoMIPS : 790.52
processor : 2
BogoMIPS : 790.52
processor : 3
BogoMIPS : 790.52
Features : swp half thumb fastmult vfp edsp neon vfpv3
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc09
CPU revision : 10
After several tries and research on the web I could compile it, but I receive errors while linking.
I do the following:
export CFLAGS='-march=armv7-a'
export CXXFLGAS='-march=armv7-a'
./configure --dest-cpu=armv7 --without-snapshot --without-ssl --dest-os=linux
I varied the options, but that had no effect.
Using as the option --dest-cpu=arm caused an compiling error (no BLX support). Therefore I used armv7, which is the correct CPU on this system.
I receive after compiling and linking the following error:
/root/node-v0.10.36/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a(platform-posix.o):
In function v8::internal::init_fast_log_function()':
platform-posix.cc:(.text+0x598): undefined reference to
v8::internal::CreateTranscendentalFunction(v8::internal::TranscendentalCache::Type)'
/root/node-v0.10.36/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a(platform-posix.o):
In function v8::internal::init_fast_sqrt_function()':
platform-posix.cc:(.text+0x5e4): undefined reference to
v8::internal::CreateSqrtFunction()' collect2: ld returned 1 exit
status make[1]: * [/root/node-v0.10.36/out/Release/node] Error 1
make[1]: Leaving directory `/root/node-v0.10.36/out' make: * [node]
Error 2
I have no idea, what I can do to link the files. How can I finish the linking process?
I found a solution which worked.
I added the argument -mthumb-interwork and configured it without any parameters. Now it is compiled and installed.
export CFLAGS='-march=armv7-a -mthumb-interwork'
export CXXFLAGS='-march=armv7-a -mthumb-interwork'
Related
I'm trying to cross compile a Go program for the armv6l architecture, specifically to get it running on a Raspberry Pi Zero W.
$ cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 9000c1
Serial : 0000000059e0c5a9
Model : Raspberry Pi Zero W Rev 1.1
I was doing what I thought was right by running the command:
env CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARM=6 GOARCH=arm go build -o build/dht_sensor_exporter-$(VERSION)-linux-armv6 ./cmd/main.go
At first glance, after running file dht_sensor_exporter-$(VERSION)-linux-armv6 it looks good, as it outputs:
dht_sensor_exporter-$(VERSION)-linux-armv6: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=d84b6c4b0dc4b77b9c65db7bc30823e5dbe1078c, for GNU/Linux 3.2.0, with debug_info, not stripped
When I try to run it on the Pi Zero W, it then outputs Illegal instruction. After a bit of digging, it seems that the cross compile didn't actually generate the file for the right architecture.
I found this using the following command:
$ readelf -A dht_sensor_exporter
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3-D16
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_enum_size: int
Tag_ABI_VFP_args: VFP registers
Tag_CPU_unaligned_access: v6
Looking at the Tag_CPU_arch it seems that it's been compiled for ARMv7 actually.
Any help would be much appreciated. The repo in question is here and is built using github actions (workflow, makfile) on the latest ubuntu version.
I'm still new at this and had to do some "interesting," potentially incorrect things with the C/C++ compiler (arm-linux-gnueabihf-gcc)
What I Want : I want to run nodejs on ARMv7 freescale imx6q board with no internet but network connectivity.
What I did : I took pre built binary from nodejs official download. extracted them and tried to run node binary. But it throws error "No such file or directory". I have tried changing permissions also. Have a look at logs below.
mx6q:/node/node-v5.9.0-linux-armv7l/bin# ls
node npm
mx6q:/node/node-v5.9.0-linux-armv7l/bin# ./node
bash: ./node: No such file or directory
mx6q:/node/node-v5.9.0-linux-armv7l/bin# ls -l
total 22084
-rwxr-xr-x 1 root root 22612411 Jan 1 03:37 node
lrwxrwxrwx 1 root root 38 Jan 1 01:04 npm -> ../lib/node_modules/npm/bin/npm-cli.js
mx6q:/node/node-v5.9.0-linux-armv7l/bin# cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 10 (v7l)
BogoMIPS : 1988.29
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc09
CPU revision : 10
processor : 1
model name : ARMv7 Processor rev 10 (v7l)
BogoMIPS : 1988.29
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc09
CPU revision : 10
processor : 2
model name : ARMv7 Processor rev 10 (v7l)
BogoMIPS : 1988.29
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc09
CPU revision : 10
processor : 3
model name : ARMv7 Processor rev 10 (v7l)
BogoMIPS : 1988.29
Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x2
CPU part : 0xc09
CPU revision : 10
Hardware : Freescale i.MX6 Quad/DualLite (Device Tree)
Revision : 63012
Serial : d4111f0ec91719d8
mx6q:/node/node-v5.9.0-linux-armv7l/bin# file node
node: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=e7c667ffc2519bf31b963b29954863c673be6fba, not stripped
mx6q:/node/node-v5.9.0-linux-armv7l/bin#
Anybody who has worked on the same or have any lead, How to overcome this error ?
As #Notlikethat suggested, Pre-built binary was looking for /lib/ld-linux-armhf.so.3 and was not available.
Compiling source code in my own environment worked fine.
I have an issue with cross compiling node.js to Cortex A5 target please guide me
I have an Atmel SAMA5D31-ek , running linux on it. Below is the CPU information
>cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 1 (v7l)
Features : half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls vfpv4
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc05
CPU revision : 1
Hardware : Atmel SAMA5
Revision : 0000
Serial : 0000000000000000
I am trying to cross compile node.js for my target board.(https://nodejs.org/en/download/)
Corss compilation status : successful
node -v : prints version of node i am using
but node with any other inputs gives "Illegal instruction"
checked with "file node" command, below is the result I got.
npm -v results in Illegal instruction
# file node
node: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.26, BuildID[sha1]=ad3f999d0ef50a7a65ebee818c8b6b3c649e0640, not stripped
My target device does not have ld-linux-armhf.so.3 , because my root file system is not using hard float.
Confusion : what flags needs to set during cross compilation to work on my A5 target.
Below are the CC settings :
export CROSS_COMPILE="/home/abc/workspace/Linux/gcc-sourcery-arm-linux-gnueabi-2012.03/bin/arm-none-linux-gnueabi-"
export PATH=/home/abc/workspace/Linux/gcc-sourcery-arm-linux-gnueabi-2012.03/bin:$PATH
export TOOL_PREFIX="arm-none-linux-gnueabi"
export CC="/home/abc/workspace/Linux/gcc-sourcery-arm-linux-gnueabi-2012.03/bin/arm-none-linux-gnueabi-gcc"
export CXX="/home/abc/workspace/Linux/gcc-sourcery-arm-linux-gnueabi-2012.03/bin/arm-none-linux-gnueabi-g++"
export AR="/home/abc/workspace/Linux/gcc-sourcery-arm-linux-gnueabi-2012.03/bin/arm-none-linux-gnueabi-ar"
export RANLIB="/home/abc/workspace/Linux/gcc-sourcery-arm-linux-gnueabi-2012.03/bin/arm-none-linux-gnueabi-ranlib"
export LINK="${CXX}"
export CCFLAGS="-g -O3 -mfloat-abi=softfp -mfpu=vfpv4-d16 -march=armv7 -mtune=cortex-a5"
export CXXFLAGS="-g -O3 -mfloat-abi=softfp -mfpu=vfpv4-d16 -march=armv7 -mtune=cortex-a5"
./configure --without-snapshot --dest-cpu=arm --dest-os=linux
make -j 4
**I am not clear about CCFLAGS and CXXFLAGS , please let me know where i went wrong and how to find the relevant information on these flags for particular processor platform.**
I have installed all cross compile packages on my ubuntu system so far but am having a
problem and need some help.
Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 184.72
Features : swp half thumb fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part : 0x926
CPU revision : 5
Cache type : write-back
Cache clean : cp15 c7 ops
Cache lockdown : format C
Cache format : Harvard
I size : 32768
I assoc : 4
I line length : 32
I sets : 256
D size : 32768
D assoc : 4
D line length : 32
D sets : 256
Hardware : MT7108
Revision : 0000
Serial : 0000000000000000
This is the target machine I need to cross compile for. What flags should I
use when compiling?
You have an ARMv5 with no floating-point processor. It should have been enough with -march=armv5 and -mfloat-abi=soft flags.
However if those flags doesn't work for you, I would suggest writing the smallest c application for testing the toolchain.
/* no includes */
int main(void) {
return 42;
}
and compiling it with most complete/strict flags
$arm-linux-gnueabi-gcc -Wall --static -O2 -marm -march=armv5 simple.c -o simple
after this, push simple to target, run it then issue an echo $? to verify if you would get 42. If it works, try to see if you can get printf working. If that one also works, you are pretty much set for everything. If printf fails, easiest solution would be to find right toolchain for your target.
apt-cache search arm | grep ^gcc- gives the following list,
gcc-4.7-aarch64-linux-gnu - GNU C compiler
gcc-4.7-arm-linux-gnueabi - GNU C compiler
gcc-4.7-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (base package)
gcc-4.7-arm-linux-gnueabihf - GNU C compiler
gcc-4.7-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)
gcc-4.7-multilib-arm-linux-gnueabi - GNU C compiler (multilib files)
gcc-4.7-multilib-arm-linux-gnueabihf - GNU C compiler (multilib files)
gcc-aarch64-linux-gnu - The GNU C compiler for arm64 architecture
gcc-arm-linux-gnueabi - The GNU C compiler for armel architecture
gcc-arm-linux-gnueabihf - The GNU C compiler for armhf architecture
You should install gcc-arm-linux-gnueabi which is an alias for gcc-4.7-arm-linux-gnueabi. gcc-4.7-multilib-arm-linux-gnueabi is also possible, but more complicated. Use the flags, -march=armv5te -mtune=arm926ej-s -msoft-float -mfloat-abi=soft. You can do more tuning by specifying the --param NAME=VALUE option to gcc with parameters tuned to your systems memory sub-system timing.
You may not be able to use these gcc versions as your Linux maybe compiled with OABI and/or be quite ancient compared to the one the compiler was built for. In some cases, the libc will call a newer Linux API, which may not be present. If the compiler/libc was not configured to be backwards compatible, then it may not work with your system. You can use crosstool-ng to create a custom compiler that is built to suit your system, but this is much more complex.
Actually I have 2 questions:
Is SSE2 Compatibility a CPU issue or Compiler issue?
How to check if your CPU or Compiler support SSE2?
I am using GCC Version:
gcc (GCC) 4.5.1
When I tried to compile a code it give me this error:
$ gcc -O3 -msse2 -fno-strict-aliasing -DHAVE_SSE2=1 -DMEXP=19937 -o test-sse2-M19937 test.c
cc1: error: unrecognized command line option "-msse2"
And cpuinfo showed this:
processor : 0
vendor : GenuineIntel
arch : IA-64
family : 32
model : 1
model name : Dual-Core Intel(R) Itanium(R) Processor 9140M
revision : 1
archrev : 0
features : branchlong, 16-byte atomic ops
cpu number : 0
cpu regs : 4
cpu MHz : 1669.000503
itc MHz : 416.875000
BogoMIPS : 3325.95
siblings : 2
physical id: 0
core id : 0
thread id : 0
The CPU needs to be able to execute SSE2 instrcutions, and the compiler needs to be able to generate them.
To check if your cpu supports SSE2:
# cat /proc/cpuinfo
It will be somewhere under "flags" if it is supported.
Update: So you cpu doesn't support it.
For the compiler:
# gcc -dumpmachine
# gcc --version
Target of your compiler needs to a kind of x86*, since only this cpus support sse2, which is part of the x86 instruction set
AND
gcc version needs to be >= 3.1 (most likely, since this is about 10 years old or something) for supporting SSE2.
Update: So your compiler doesn't support it on this target, it will if you are using it as a cross compiler for x86.
It's both. The compiler/assembler need to be able to emit/handle SSE2 instructions, and then the CPU needs to support them. If your binary has SSE2 instructions with no conditions attached and you try to run it on a Pentium II you are out of luck.
The best way is to check your GCC manual. For example my GCC manpage refers to the -msse2 option which will allow you to explicitly enable SSE2 instructions in the binaries. Any relatively recent GCC or ICC should support it. As for your cpu, check the flags line in /proc/cpuinfo.
It would be best, though, to have checks in your code using cpuid etc, so that SSE2 sections can be disabled in CPUs that do not support it and your code can fall back on a more common instruction set.
EDIT:
Note that your compiler needs to either be a native compiler running on a x86 system, or a cross-compiler for x86. Otherwise it will not have the necessary options to compile binaries for x86 processors, which includes anything with SSE2.
In your case the CPU does not support x86 at all. Depending on your Linux distribution, there might be packages with the Intel IA32EL emulation layer for x86-software-on-IA64, which may allow you to run x86 software.
Therefore you have the following options:
Use a cross-compiler that will run on IA64 and produce binaries for x86. Cross-compiler toolchains are not an easy thing to setup though, because you need way more than just the compiler (binutils, libraries etc).
Use Intel IA32EL to run a native x86 compiler. I don't know how you would go about installing a native x86 toolchain and all the libraries that your project needs in your distributions does not support it directly. Perhaps a full-blown chroot'ed installation of an x86 distribution ?
Then if you want to test your build on this system you have to install Intel's IA32EL for Linux.
EDIT2:
I suppose you could also run a full x86 linux distribution on an emulator like Bochs or QEMU (with no virtualization of course). You are definitely not going to be dazzled by the resulting speeds though.
Another trick not yet mentioned is do:
gcc -march=native -dM -E - </dev/null | grep SSE2
and get:
#define __SSE2_MATH__ 1
#define __SSE2__ 1
With -march=native you are checking both your compiler and your CPU. If you give a different -march for a specific CPU, like -march=bonnell you can check for that CPU.
Consult your gcc docs for the correct version of gcc:
https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Submodel-Options.html
use asm to check the existence of sse2
enter code here
static
bool HaveSSE2()
{
return false;
__asm mov EAX,1 ;
__asm cpuid ;
__asm test EDX, 4000000h ;test whether bit 26 is set
__asm jnz yes ;yes
return false;
yes:
return true;
}
Try running:
lshw -class processor | grep -w sse2
and look under the processor section.