diff mbox

tools: fix cross-compiling tools when HOSTCC is overridden

Message ID 1489394596-1121-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 3b0825296aeba69c2cbfd3e179db2e9cbe5e70d7
Headers show

Commit Message

Masahiro Yamada March 13, 2017, 8:43 a.m. UTC
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>
---

 tools/Makefile     | 2 +-
 tools/env/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Masahiro Yamada March 13, 2017, 8:49 a.m. UTC | #1
+CC Richard
+CC Marek

2017-03-13 17:43 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> 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>
> ---
>
>  tools/Makefile     | 2 +-
>  tools/env/Makefile | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/Makefile b/tools/Makefile
> index 1c840d7..a894b5c 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -262,7 +262,7 @@ $(LOGO_DATA_H):     $(obj)/bmp_logo $(LOGO_BMP)
>  subdir- += env
>
>  ifneq ($(CROSS_BUILD_TOOLS),)
> -HOSTCC = $(CC)
> +override HOSTCC = $(CC)
>
>  quiet_cmd_crosstools_strip = STRIP   $^
>        cmd_crosstools_strip = $(STRIP) $^; touch $@
> diff --git a/tools/env/Makefile b/tools/env/Makefile
> index 38ad118..95b28c0 100644
> --- a/tools/env/Makefile
> +++ b/tools/env/Makefile
> @@ -8,7 +8,7 @@
>  # 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"
>  # 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
>  HOST_EXTRACFLAGS  = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Simon Glass March 13, 2017, 1:24 p.m. UTC | #2
On 13 March 2017 at 02:49, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> +CC Richard
> +CC Marek
>
> 2017-03-13 17:43 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
>> 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>
>> ---
>>
>>  tools/Makefile     | 2 +-
>>  tools/env/Makefile | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini March 16, 2017, 8:41 p.m. UTC | #3
On Mon, Mar 13, 2017 at 05:43:16PM +0900, Masahiro Yamada wrote:

> 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>


Applied to u-boot/master, thanks!

-- 
Tom
diff mbox

Patch

diff --git a/tools/Makefile b/tools/Makefile
index 1c840d7..a894b5c 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -262,7 +262,7 @@  $(LOGO_DATA_H):	$(obj)/bmp_logo $(LOGO_BMP)
 subdir- += env
 
 ifneq ($(CROSS_BUILD_TOOLS),)
-HOSTCC = $(CC)
+override HOSTCC = $(CC)
 
 quiet_cmd_crosstools_strip = STRIP   $^
       cmd_crosstools_strip = $(STRIP) $^; touch $@
diff --git a/tools/env/Makefile b/tools/env/Makefile
index 38ad118..95b28c0 100644
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -8,7 +8,7 @@ 
 # 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"
 # 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
 HOST_EXTRACFLAGS  = $(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \