Unrecognized CPU by ARM gcc - c

I want to compile a C file for stellaris board. (cortex m4)
But the compiler always throws the following errors:
Building file: ../main.c
Invoking: Cross GCC Compiler
arm-none-eabi-gcc -DPART_LM4F120H5QR -DARM_MATH_CM4 -DTARGET_IS_BLIZZARD_RA1 -I/home/erbal/src/stellaris -I/usr/lib/gcc/arm-none-eabi/4.5.1/include-fixed -I/usr/lib/gcc/arm-none-eabi/4.5.1/include -I/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/include -O0 -g3 -Wall -c -fmessage-length=0 -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.c"
as: unrecognized option '-mcpu=cortex-m4'
subdir.mk:21: recipe for target 'main.o' failed
make: *** [main.o] Error 1

You need to install the arm-none-eabi-binutils package in addition to arm-none-eabi-gcc.

You can use the GCC -B option to specify the prefix of the tool chain binaries, so the cross-compiler is used instead of the native.

Need to put the arm-none-eabi-c++ or arm-none-eabi-gcc together with the whole gcc folder [e.g inside arm-none-eabi folder]. Because compiler will depend on others binutils component/files as well.

Let's say you have the tool chain specific to ARM EABI at /usr/local/arduino-packages-1.6.8, ensure that /usr/local/arduino-packages-1.6.8/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin is readable and in the PATH environment variable and its contents have executable permissions.

Related

How to Cross-Compile from LLVM IR to Assembly for ARM Cortex M4?

I'm trying to cross-compile an llvm-ir file to assembly, or better generate an object file, for an ARM Cortex M4 microprocessor using llc compiler.
Which are the parameters that I have to specify in order to do so?
I have tried with this command
llc -mtriple=armv7m-eabi -mcpu=cortex-m4 file.ll -o file.s
It doesn't throw any error but the assembly code generated is still for an x86 machine.
In particular, trying to compiling with random parameters, e.g.
llc -mtriple=randomwords -mcpu=cortex-m4 file.ll -o file.s
It goes smooth, producing an assembly code for the x86 machine. It ignores what I specify.
I found a solution, or better a work around to this problem.
Instead of using directly llc, first I've obtained the binary code through this command
llvm-as file.ll -o file.bc
An than I used clang to crosscompile and obtain the object file for ARM Cortex M4 using this instruction
clang --target=arm-none-eabi -march=armv7e-m -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -nostdlib file.bc -c -o file.o
The -c is used to compile only.
It is also possible to obtain the assembly code by using the following command line
clang -S --target=arm-none-eabi -march=armv7e-m -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -nostdlib file.bc -o file.s
llc (not sure about prior to v9) seems to only care about the architecture.
I can cross compile and link with the following script (for a RPI running Linux):
#/bin/sh
llc-9 -march=arm -float-abi=hard -O3 -filetype obj $1.ll -o $1.o
~/devel/musl/musl-cross-make/output/bin/arm-linux-musleabihf-gcc -mfloat-abi=hard -static $1.o -o $1
llc --version will show the available architectures
Try the following for your case (or use a more specific architecture if it is in the list):
llc -march=arm -mcpu=cortex-m4 -filetype obj file.ll -o file.o

Error 2: The system cannot find the file specified. "Cygwin Make"

I have a project with a makefile, linker file and some other c files. Whenever i try to run the make command from my windows. i end up with this error. I am using a cygwin terminal. The project was initially used Linux environment.
process_begin: CreateProcess(NULL, arm-none-eabi-gcc -c -g -Os -I. -fno-common -
ffunction-sections -ffreestanding -fno-builtin -mthumb -mcpu=cortex-m7 -specs=na
no.specs -Wall -Winline -fstack-usage -DSTM32F769xx -mfloat-abi=hard -mfpu=fpv5-
d16 -fno-strict-aliasing -Wno-discarded-qualifiers stm32init.c -o stm32init.o, .
..) failed.
make (e=2): The system cannot find the file specified.
make: *** [makefile:20: stm32init.o] Error 2
Let me know how i can fix this problem.

Cross Compile Raspberry with external libraries - copying of target folders

I am cross compiling C-Code from Mac OS (Host) for a Raspberry Pi B+, running Raspbian Jessie, (Target). In order to link external libraries ("WiringPi" and "pthread") during make I have used a somewhat lazy approach of copying the relevant folders containing headers and libraries from the target (i.e. /lib/, /usr/include/, /usr/lib/, /usr/local/lib/, /usr/local/include/) to the host machine in advance.
My Cross GCC Compiler call is then modified as:
arm-linux-gnueabihf-gcc -I"/Path/to/copy/of/target-folders/.../usr/local/include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.c"
The GCC Linker call is modified as:
arm-linux-gnueabihf-gcc --sysroot=/Path/to/copy/of/target-folders/ -o "BlinkLedCrossCompile" ./main.o -lWiringPi -lpthread
This uses the copied target folders as sysroot. And so far, it works without any problems.
My question is: Is this a valid approach? Can I expect any problems further on?

unrecognized option '-tree-vectorize

I have the following error
make all
Building file: ../src/asm.S
Invoking: GCC Assembler
arm-linux-gnueabi-as -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree- vectorize -o "src/asm.o" "../src/asm.S"
arm-linux-gnueabi-as: unrecognized option '-tree-vectorize'
make: *** [src/asm.o] Error 1
while compiling FFMpeg code for fourier transform code using .S files which include VFP commands
the options used in compiler:
Commands in Build C/C++ settings section
GCC C Compiler :
arm-linux-gnueabi-gcc -O3 -S -mcpu=cortex-a8 -mfpu=neon -ffast-math -mfloat-abi=softfp
GCC C Linker:
arm-linux-gnueabi-gcc -mcpu=cortex-a8 -mfpu=neon -ffast-math -ftree-vectorize -mthumb -mfloat-abi=softfp
GCC Assembler
arm-linux-gnueabi-as -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize
I am using Eclipse.
Thanks in advance for your help.
Mahmoud
-ftree- vectorize is a gcc option used for automatic vectorization of C and C++ code. You shouldn't (can't) use it on as.

GNU Make --output-sync doesn't work?

this is driving me bonkers.
For parallel make builds (-j), you're supposed to be able to synchronize the console output. Here is ref:
GNU Make Manual: 5.4.1 Output During Parallel Execution
I'm using GNU Make 3.82 for x86_64-redhat-linux-gnu
Un-Synchronized:
make -j8 all //not synchronized
yields (i'm using eclipse-cdt managedbuild here):
Building file: ../dome.c
Building file: ../main.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"dome.d" -MT"dome.d" -o "dome.o" "../dome.c"
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.c"
Finished building: ../dome.c
Finished building: ../main.c
Building target: empty_linux
Invoking: GCC C Linker
gcc -o "empty_linux" ./dome.o ./main.o
Finished building target: empty_linux
Synchronized Attempt
make -j8 all --output-sync
yields (same result for -O/-Oline/etc):
make: unrecognized option '--output-sync
Question
what the heck am I doing wrong??
The --output-sync option is only available in GNU make 4.0. Also, in your case you should use:
--output-sync=target
or
-Otarget
But this won't work with version 3.82.

Resources