2
votes

First time poster long time lurker.

So I have been using the GNU ARM Embedded Toolchain for a while and compiling my embedded C++ code using arm-none-eabi-g++, because it is what we did in my embedded systems university courses. For my computer science courses we used just g++ to compile C++ code. I have been poking around the GCC manual and found that there are ARM architecture compilation options for GCC. My question is what is the difference between using arm-none-eabi-g++binary provided by ARM and g++ with the -mcpu=cortex-m4 -march=armv7compile option for cross-compiling? It appears you can cross-compile for ARM using gcc (gcc that comes with Ubuntu) and I have been hard pressed so far to find a straight answer to this question on the internet.

1
gcc's design is such that it is a generic compiler with many targets (backends) as well as a number of frontends. But when you take it from source code into a usable binary you pick one (backend). The backend author determines how narrow/wide that is, arm-none-eabi for example will build from around arm1 or arm2 through to armv7 (depending on the version of gcc) full sized arm variants as well as thumb variants. the one on your x86 computer, gcc, builds for x86 and whatever variants that backend supports but it wont build for arm. - old_timer
if you install a generic pre-built clang/llvm it will at least get you to assembly or object level for all the targets using the command line to specify the backend, linking is another story (can use gnu binutils to assemble and link as needed). different folks different designs for their tools. - old_timer

1 Answers

1
votes

I think I figured it out. So using GCC you can build a cross compiler and an associated toolchain. ARM built their own cross compiler and put it up for people to use as the "Official GNU ARM Embedded Toolchain". It's basically a meta "I used the compiler to build the compiler problem". The options -mcpu=cortex-m4 -march=armv7 I was seeing was for targeting architectures when building GCC, not to be when compiling.