kbuild overwrites $CC

Rich Felker dalias at libc.org
Sat Jul 2 18:31:35 UTC 2016


On Fri, Jul 01, 2016 at 06:16:59PM +0200, Martin Kaiser wrote:
> Dear all,
> 
> I'm trying to compile busysbox with a toolchain created from
> yoctoproject. This toolchain comes with a setup script to set $CC and
> cross-compiler related environment variables. If the toolchain is
> installed to a non-standard path, $CC contains the --sysroot parameter,
> e.g.
> 
> martin at vagrant-ubuntu-trusty-32:~/src/busybox$ echo $CC
> arm-poky-linux-gnueabi-gcc -march=armv5te -marm -mthumb-interwork --sysroot=/opt/poky-1.7.3/sysroots/armv5te-poky-linux-gnueabi
> 
> Busybox' Makefile unconditionally overwrites CC with
> 
> CC              = $(CROSS_COMPILE)gcc
> 
> CROSS_COMPILE ist set up correctly in the environment, so I get the
> right compiler but the --sysroot parameter is stripped. As the include
> path depends on sysroot, the compiler doesn't find some include files
> and busybox compilation fails.
> 
> Do you have an idea how this is supposed to work? Should I submit a
> patch that replaces CC = ... with CC ?= ... ;-)

In general, putting CC= on the make command line rather than in the
environment will override any make variables (unless an obscure GNU
make feature to force them is used, and it's not used here). If you
already have it in the environment, this will work:

make CC="$CC"

or if you want _all_ vars from the environment to take precedence:

make -e

That can be dangerous though since makefiles might happen to use var
names that happen to clash with something in your environment for
purely internal purposes, and in a worst case it could end up leading
to rm -rf of some directory you care about (I doubt this is likely
with the busybox makefile but I still don't recommend -e).

Rich


More information about the busybox mailing list