use a gcc with target triplet from PATH if CC=gcc is set

The motivation of this change is to be able to use the gcc version from
PATH (e.g. the bundled prebuilt) even in case CC=clang has been set
as default by the build.config:

-- Build with Clang from $PATH
$ ./build/

-- Build with GCC from $PATH
$ CC=gcc ./build/

In case of build/, $PATH is usually setup for a prebuilt
cross-compiler toolchain.
In order to accomodate any cross compiler settings when falling back to
gcc, simply unset CC to let kbuild figure out the correct compiler from

It appears a bit hacky, but only breaks backward compatibility for the
case that somebody uses CC=gcc and expects the gcc from PATH to be used.
That case is still supported by passing an absolute path.

Change-Id: I537192168a27bdda9b288443de88ed45d7c4ec68
Signed-off-by: Matthias Maennich <>
1 file changed