tools: Makefile: improve cross_tools target usability
PATCH 1/1 tools: Makefile: improve cross_tools target usability
When building the cross_tools target, HOSTCFLAGS and HOSTLDFLAGS will propagate to the target build. This should not happen and is easy to prevent.
--- tools/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/Makefile +2 -0
@@ -263,6 +263,8 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) HOSTCC = $(CC) +HOSTCFLAGS = $(CFLAGS) +HOSTLDFLAGS = $(LDFLAGS) quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@
Signature · 1 line
1.9.1
PATCH 1/1 tools: Makefile: improve cross_tools target usability
Quoted 5 lines · Stefan M?ller-Klieser
When building the
cross_toolstarget, HOSTCFLAGS and HOSTLDFLAGS will propagate to the target build. This should not happen and is easy to prevent.Signed-off-by Stefan M?ller-Klieser <[email protected]>
+CC Masahiro Yamada-san .
Quoted 18 lines
--- tools/Makefile | 2 ++ 1 file changed, 2 insertions(+)tools/Makefile +2
-0@@ -263,6 +263,8 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) HOSTCC = $(CC) +HOSTCFLAGS = $(CFLAGS) +HOSTLDFLAGS = $(LDFLAGS) quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 tools: Makefile: improve cross_tools target usability
In reply to Stefan Müller-KlieserHi.
2016-10-31 22:15 GMT+09:00 Stefan M?ller-Klieser <[email protected]>:
Quoted 14 lines
When building the
cross_toolstarget, HOSTCFLAGS and HOSTLDFLAGS will propagate to the target build. This should not happen and is easy to prevent.Signed-off-by Stefan M?ller-Klieser <[email protected]>--- tools/Makefile | 2 ++ 1 file changed, 2 insertions(+)tools/Makefile +0
-0
tools/Makefile subdir- += env · line 267
Quoted 5 lines
tools/Makefile +2
-0@@ -263,6 +263,8 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) HOSTCC = $(CC) +HOSTCFLAGS = $(CFLAGS) +HOSTLDFLAGS = $(LDFLAGS)
In the current U-Boot build system (= Kbuild),
CFLAGS is never set, never referenced.
For the target build, KBUILD_CFLAGS is used instead.
So, $(CFLAGS) is always empty unless your environment explicitly sets it.
Likewise for LDFLAGS.
Did you mean
HOSTCFLAGS =
HOSTLDFLAGS =
or
HOSTCFLAGS = $(KBUILD_CFLAGS)
HOSTLDFLAGS =
?
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH 1/1 tools: Makefile: improve cross_tools target usability
Quoted 1 line · Masahiro Yamada
Hi.
Hi!
Quoted 26 lines
2016-10-31 22:15 GMT+09:00 Stefan M?ller-Klieser <[email protected]>:
Quoted 14 lines
When building the
cross_toolstarget, HOSTCFLAGS and HOSTLDFLAGS will propagate to the target build. This should not happen and is easy to prevent.Signed-off-by Stefan M?ller-Klieser <[email protected]>--- tools/Makefile | 2 ++ 1 file changed, 2 insertions(+)tools/Makefile +0
-0tools/Makefile subdir- += env · line 267
Quoted 5 lines
tools/Makefile +2
-0@@ -263,6 +263,8 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) HOSTCC = $(CC) +HOSTCFLAGS = $(CFLAGS) +HOSTLDFLAGS = $(LDFLAGS)In the current U-Boot build system (=
Kbuild),
CFLAGS is never set, never referenced.
Quoted 1 line
For the target build,
KBUILD_CFLAGSis used instead.
Well, having the cross_tools target, Kbuild actually creates binaries for two different runtime environments. First we have the u-boot, which is a bare metal app controlled by e.g. the KBUILD_CFLAGS, and then we have the cross tools which are linux userspace binaries. The compilation of the userspace binaries can be very different and kbuild cannot know about it, e.g. it does not make much sense to set compiler defaults, in my opinion,
Quoted 5 lines
So, $(CFLAGS) is always empty unless your environment explicitly sets it.
Likewise for LDFLAGS.
As intended.
Quoted 6 lines
Did you mean
HOSTCFLAGS =
HOSTLDFLAGS =
That would certainly fix the current bug. Reading your comments make me think that I should have created two different patches, and I even have one more queued.
Quoted 5 lines
or
HOSTCFLAGS = $(KBUILD_CFLAGS)
HOSTLDFLAGS =
That being said, no I think that would create even more confusion.
Quoted 2 lines
?
Thanks for the review. Looking at the kbuild documentation, the case for CFLAGS and LDFLAGS is actually different, as LDFLAGS are well defined and CFLAGS are not. The case for cross tools is not specified, to my understanding, please correct me. So another proposal would be:
HOSTCFLAGS = $(TARGETCFLAGS)
HOSTLDFLAGS = $(TARGETLDFLAGS)
?
Regards, Stefan