0

This question might be sound obvious to some of you, but to me, it looks like a missing piece that I need in order to understand the picture.

Edit: Specifically, I'm using Ubuntu VM on my PC, trying to build Out-of-Tree kernel module that should run on BeagleBone Black,

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C M=$PWD

In the make command I usually need to enter the following 2 parameters:

  1. ARCH=
  2. CROSS_COMPILE=

To me "1" looks like redundant information that only adds to the complexity of the make command.

Of course, there is a solid reason why using both of them, and I tried to search in many forums and sites, but couldn't find an "answer for dummies" - I guess this is what I'm looking for.

So - my question: Isn't specifying the CROSS_COMPILE= enough to build the source code? taking for example:

  • arm-linux-gnueabihf-
  • aarch64-none-elf-
  • arm-none-linux-gnueabihf

In all of the above options, we have the target CPU architecture, which is arm or aarch64 (which is also arm64).

So why do we need a specific directive such as ARCH= if the architecture is already implied in the CROSS_COMPILE= directive?

Yaniv G
  • 307
  • 4
  • 11
  • There's nothing built into make or standard makefiles about any of these variables. They are a pure invention of whatever build system you are using. As such, it's not useful to ask us on StackOverflow about them, particularly since you haven't described which build systems you're using. Instead you should ask the authors of those build systems. Maybe you're talking about the Linux kernel build system KBuild? If so you should make that clear. Maybe the docs will help: https://www.kernel.org/doc/html/latest/kbuild/kbuild.html – MadScientist Dec 12 '21 at 18:02
  • `$ARCH` defines which folder to use for architectural code (_arch/$ARCH/_), the other what compiler to use. They are about different and independent things. – 0andriy Dec 15 '21 at 23:32

0 Answers0