Make cannot find present cross compiler - linux

I'm using a make file to compile a kernel for an arm/Xilinx platform.
I'm setting an env variable CROSS_COMPILE which the make file will then use.
I'm trying to use a cross compiler, which is present on my system, called arm-xilinx-linux-gnueabi-gcc by setting the env var in the following ways;
export CROSS_COMPILE=/opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
The make file should append gcc.
The error given for both is
make: /opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-gcc: Command not found
scripts/kconfig/conf --silentoldconfig Kconfig
make: /opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-gcc: Command not found
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
/bin/sh: 1: /opt/Xilinx/SDK/2015.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
It works with other arm cross compilers but this one.
Why is this?

According answers you gave in comments, you are trying to run a 32bits executable on a 64bits host platform.
So, if your are on Ubuntu check this answer from askubuntu.

Related

Kernel module on cross-compile kernel: /bin/sh: 1: scripts/basic/fixdep: Exec format error

I'm doing some experiment on rpi4, and trying to reproduce this kernel module from github https://github.com/sysprog21/dont-trace on my rpi4. I encounter this problem:
make -C /lib/modules/`uname -r`/build M=/home/ubuntu/dont-trace modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.65-rt49-preemptrt-full-raspi'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
You are using: gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
CC [M] /home/ubuntu/dont-trace/dont_trace.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
make[2]: *** [scripts/Makefile.build:289: /home/ubuntu/dont-trace/dont_trace.o] Error 126
make[2]: *** Deleting file '/home/ubuntu/dont-trace/dont_trace.o'
make[1]: *** [Makefile:1896: /home/ubuntu/dont-trace] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.65-rt49-preemptrt-full-raspi'
make: *** [Makefile:7: all] Error 2
The kernel here is cross-compiled from x86 server and do show above. I was wondering how to solve this problem & what's the root cause. I can make it on x86 server. It should be something fundamental knowledge I don't understand. Thks!
it seems work this time
My solution might be a bit workaround, but it works. I follow the clues /bin/sh: 1: scripts/basic/fixdep: Exec format error. So I copy the source code to local raspberry pi, and make modules_prepare to construct complete /scripts, then move it into /lib/modules/`uname -r\`/build. It remain the gcc version warning, but work properly.

Cross-compiling linux module missing include file

I am having some issues cross-compiling a module for the Raspberry Pi 4.
The compiler used is: aarch64-linux-gnu-.
The kernel used is: linux-5.10.42
And the error during compilation is as follows:
make -C /opt/linux-5.10.42 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- M=/home/x/build/linux-driver-gpio-customled modules
make[1]: Entering directory '/opt/linux-5.10.42'
CC [M] /home/x/build/linux-driver-gpio-customled/customled.o
In file included from ./include/linux/types.h:6,
from ./include/linux/list.h:5,
from ./include/linux/module.h:12,
from /home/x/build/linux-driver-gpio-customled/customled.c:1:
./include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
5 | #include <asm/types.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:279: /home/x/build/linux-driver-gpio-customled/customled.o] Error 1
make[1]: *** [Makefile:1821: /home/x/build/linux-driver-gpio-customled] Error 2
make[1]: Leaving directory '/opt/linux-5.10.42'
make: *** [Makefile:5: default] Error 2
So my question is as follows: Where should this file asm/types.h come from? To my knowledge it should be included in the kernel arch/arm64/include/asm/ subdirectory. But it's not. Other architectures, namely x86 have it.
Is there another way to build a module without including linux/module.h that i'm not aware of?
Any help is greatly appreciated.
Got it!
The files are autogenerated, there is a handy make command used to prepare the build environment for out-of-tree kernel modules. What I did was run
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_prepare
inside the kernel source.
Hope this helps someone with not spending time on such a simple mistake.

GCC 5.3 failing in the make phase

Currently I have GCC 5.4.0-6 installed on my Ubuntu 16.04.4 machine. However nvcc wants me to use 5.3, so I am trying to install that version as well. I did this by:
1. downloading gcc-5.3.0.tar.gz
2. extracting it to ~/Documents/libraryDownloads/GCC-5/gcc-5.3.0
3. creating the folder ~/Documents/libraryDownloads/GCC-5/gcc-build
4. In ~/Documents/libraryDownloads/GCC-5/gcc-5.3.0 I used the command ./contrib/download_prerequisites.
5. In ~/Documents/libraryDownloads/GCC-5/gcc-build I used the command ./../gcc-5.3.0/configure --enable-multilib
6. and finally in ~/Documents/libraryDownloads/GCC-5/gcc-build I used the command make
The make-process rand for a short while and then ended with the following error:
checking whether the gcc -m32 linker (ld -m elf_x86_64 -m elf_i386) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.
Makefile:10699: recipe for target 'configure-stage1-zlib' failed
make[2]: *** [configure-stage1-zlib] Error 1
make[2]: Leaving directory '/home/myUser/Documents/libraryDownloads/GCC-5/gcc-build'
Makefile:22461: recipe for target 'stage1-bubble' failed
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory '/home/myUser/Documents/libraryDownloads/GCC-5/gcc-build'
Makefile:902: recipe for target 'all' failed
make: *** [all] Error 2
As far as I know, I have all prerequisites installed and I am doing all this in a separate build folder as recommended. I tried searching for error: Link tests are not allowed after GCC_NO_EXECUTABLES., but I couldn't find anyone with similar problems. Does anyone know what could be the cause of this error?

How to solve "cstring: No such file or directory" when compiling gcc from source?

I am trying to compile a gcc from source since I cannot use yum, apt-get and so forth. My steps are simple:
-I download the source GCC (I tried gcc-4.8.4 and gcc-5.3.0) in my pc and I used:
./contrib/download_prerequisites
-After this, I send this my gcc source file to my system using powerPC y Linux.
mkdir objdir
cd objdir
../gcc-4.6.2/configure --prefix=/usr --enable-languages=c,c++,fortran,go
make
I have got the next error:
In file included from ../../gcc-4.9.2/gcc/genmddeps.c:19:0:
../../gcc-4.9.2/gcc/system.h:205:20: fatal error: cstring: No such file or directory
# include <cstring>
^
compilation terminated.
make[3]: *** [build/genmddeps.o] Error 1
make[3]: Leaving directory `/home/root/build/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/root/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/root/build'
make: *** [all] Error 2
Any idea about what it is going wrong?
Best regards
Some advice: first, compile (notably for learning purposes) something simpler than GCC, e.g. GNU make if you never compiled GNU stuff from source code.
Then compile a recent GCC (so 5.3 in january 2016) - building issues would be the same with 4.8, and GCC 5 is better! You need the gcc & libc-dev & g++ & libstdc++-dev for your host machine (the one running your future cross-compiler). I am not sure your --prefix=/usr is a good idea. Consider perhaps a --program-suffix=-mine option (otherwise, your system's /usr/bin/gcc could be overwritten, which you don't want to happen)
You could leave the default --prefix=/usr/local and later add appropriately /usr/local/bin/ into your PATH

Linux kernel compiler for FriendlyARM

I'm trying to compile a Linux kernel for my FriendlyARM, but I'm getting this error:
kevin#kevin-VirtualBox:~/Desktop/FriendlyARM/linux-2.6.38-friendlyarm-newgccpatched$ make
make: arm-linux-gcc: Command not found
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
/bin/sh: 1: arm-linux-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
kevin#kevin-VirtualBox:~/Desktop/FriendlyARM/linux-2.6.38-friendlyarm-newgccpatched$
Is there an easy way to resolve this?
I have never done this before, therefore, if I'm asking a stupid question, please forgive me.
Firstly, you need to have arm cross compiler toolchain. For example arm-none-linux-gnueabi. You can download it here
When you have successfully installed the toolchain follow below steps to compile the kernel.
cd to kernel directory
execute
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- defconfig

Resources