0

Recently I tried to make my own cross-compile toolchain for a arm platform. I noticed with the autoconf script of GCC, I have to pass variables like:

--with-cpu=cortex-m4 \
--with-fpu=fpv4-sp-d16 \
--with-float=hard \
--with-mode=thumb \

So it seems different ARM platforms should have different tool chain/compiler cause I have to configure the cpu, fpu etc. But then I found there's some sort of pre-made binaries of these tool chain.

https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads

I tried this tool chain and compiled a hello world program and tried it on my target ARM board, then it shows "segmentation fault." OK, at least it's not "cannot execute binary file: Exec format error"

But I am still wondering, how come it does not work? Or is it suppose to work actually?

0

When building the toolchain itself, you have to configure which features to support. You can build a "slim" compiler, supporting just the features you need for the target you want.

But you can also support everything the ARM platform has to offer and get a clumsy compiler.

For the features themselves, you should differ between different types:

  • Optimization flags like -mcpu are not required, they are only to optimize the code for a certain ARM processor
  • The fpu feature of your ARM core on the other hand has to be available to use the fpu at all.
  • Your float=hard depends on the operating system, not on the processor: it allows to pass floats to functions in floating registers which can be a big speedup because transfer between ARM registers and float registers are slow. But for linkage, the system needs to agree on that.
  • Support for thumb is somehow optional, too. You can use either if the core supports it, but nowadays it would be stupid not to let the compiler choose thumb mode.
  • Ok, I got it. So the compiler can be set to support all the ARM platforms but it will becomes too fat or in-efficient. – J.R. Oct 25 '17 at 6:28
  • Whether this is "too" fat, is an individual decision. A crosscompiler typically runs on a PC or notebook with at least hundreds of Gigabytes, so it doesn't matter and I would take the all-inclusive binary. If you compile on the target system, you may want to get rid of everything you don't need. In any case: Make sure to give the correct parameters to gcc for your platform. – Philippos Oct 25 '17 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.