tools: fix cross-compiling tools when HOSTCC is overridden

Richard reported U-Boot tools issues in OpenEmbedded/Yocto project.

OE needs to be able to change the default compiler. If we pass in
HOSTCC through the make command, it overwrites all HOSTCC instances,
including ones in tools/Makefile and tools/env/Makefile, which breaks
"make cross_tools" and "make env", respectively.

Add "override" directives to avoid overriding HOSTCC instances that
really need to point to the cross-compiler.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reported-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Masahiro Yamada 2017-03-13 17:43:16 +09:00 committed by Tom Rini
parent 433cbfb3b3
commit 3b0825296a
2 changed files with 2 additions and 2 deletions

View file

@ -262,7 +262,7 @@ $(LOGO_DATA_H): $(obj)/bmp_logo $(LOGO_BMP)
subdir- += env subdir- += env
ifneq ($(CROSS_BUILD_TOOLS),) ifneq ($(CROSS_BUILD_TOOLS),)
HOSTCC = $(CC) override HOSTCC = $(CC)
quiet_cmd_crosstools_strip = STRIP $^ quiet_cmd_crosstools_strip = STRIP $^
cmd_crosstools_strip = $(STRIP) $^; touch $@ cmd_crosstools_strip = $(STRIP) $^; touch $@

2
tools/env/Makefile vendored
View file

@ -8,7 +8,7 @@
# fw_printenv is supposed to run on the target system, which means it should be # fw_printenv is supposed to run on the target system, which means it should be
# built with cross tools. Although it may look weird, we only replace "HOSTCC" # built with cross tools. Although it may look weird, we only replace "HOSTCC"
# with "CC" here for the maximum code reuse of scripts/Makefile.host. # with "CC" here for the maximum code reuse of scripts/Makefile.host.
HOSTCC = $(CC) override HOSTCC = $(CC)
# Compile for a hosted environment on the target # Compile for a hosted environment on the target
HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \ HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \