tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
When CROSS_BUILD_TOOLS is set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrong
--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)
tools/Makefile +1 -0
@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS) quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@
Signature · 1 line
2.20.1
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 4 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190503/de6aa4a2/attachment.sig>
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
In reply to Fabrice FontaineQuoted 14 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +0
-0
tools/Makefile subdir- += env · line 278
Quoted 7 lines
tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS) quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@
This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with CONFIG_FIT but without CONFIG_FIT_SIGNATURE because "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).
Jan
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)
Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).
I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y, tools/Makefile sets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.
This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on pthread.h
More information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385
Quoted 2 lines
Jan
Best Regards,
Fabrice
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Jan
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags. From my understanding, CFLAGS (and so HOSTCFLAGS when building tools for the target through cross-tools) will (or should?) contain -O2 or -Os depending on CONFIG_CC_OPTIMIZE_FOR_SIZE value. However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS in tools/Makefile (after the override).
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
Quoted 2 lines
Jan
Fabrice
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue. However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).
This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGN is 0 when CONFIG_FIT_SIGNATURE is not set. That will remove all code from tools/image-host.c which is not reachable then. When it's not removed because of default optimization settings, we get linker errors because common/image.sig.c is not built without CONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.
Jan
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 74 lines · Jan Kiszka
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue. However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 8 lines
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGNis 0 whenCONFIG_FIT_SIGNATUREis not set. That will remove all code fromtools/image-host.cwhich is not reachable then. When it's not removed because of default optimization settings, we get linker errors becausecommon/image.sig.cis not built withoutCONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.
Thanks a lot for your explanation.
I was able to reproduce the issue and I think that
https://github.com/ffontaine/u-boot/commit/61a162e5c0343fc55304902042f8c9adfe531f51
should fixed it.
Can you review it? I can also directly send a PR.
Quoted 2 lines
Jan
Fabrice
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 83 lines · Fabrice Fontaine
Quoted 74 lines · Jan Kiszka
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue. However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 8 lines
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGNis 0 whenCONFIG_FIT_SIGNATUREis not set. That will remove all code fromtools/image-host.cwhich is not reachable then. When it's not removed because of default optimization settings, we get linker errors becausecommon/image.sig.cis not built withoutCONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.
Quoted 5 lines
Thanks a lot for your explanation.
I was able to reproduce the issue and I think that
https://github.com/ffontaine/u-boot/commit/61a162e5c0343fc55304902042f8c9adfe531f51
should fixed it.
Can you review it? I can also directly send a PR.
I still think that dropping the content of HOSTCFLAGS is the actual bug. There is more than -O2 that you lose. If you want your CFLAGS to be respected, append them.
Jan
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 91 lines · Jan Kiszka
Quoted 83 lines · Fabrice Fontaine
Quoted 74 lines · Jan Kiszka
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue. However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 8 lines
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGNis 0 whenCONFIG_FIT_SIGNATUREis not set. That will remove all code fromtools/image-host.cwhich is not reachable then. When it's not removed because of default optimization settings, we get linker errors becausecommon/image.sig.cis not built withoutCONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.Quoted 5 lines
Thanks a lot for your explanation.
I was able to reproduce the issue and I think that
https://github.com/ffontaine/u-boot/commit/61a162e5c0343fc55304902042f8c9adfe531f51
should fixed it.
Can you review it? I can also directly send a PR.
Quoted 3 lines
I still think that dropping the content of HOSTCFLAGS is the actual bug. There is more than -O2 that you lose. If you want your CFLAGS to be respected, append them.
I add Arnout to the list to get his feedback as he is the one that suggested this solution during review of
https://patchwork.ozlabs.org/patch/1092227.
Quoted 2 lines
Jan
Fabrice
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 92 lines · Fabrice Fontaine
Quoted 91 lines · Jan Kiszka
Quoted 88 lines · Fabrice Fontaine
Quoted 74 lines · Jan Kiszka
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue.
However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 8 lines
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGNis 0 whenCONFIG_FIT_SIGNATUREis not set. That will remove all code fromtools/image-host.cwhich is not reachable then. When it's not removed because of default optimization settings, we get linker errors becausecommon/image.sig.cis not built withoutCONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.Thanks a lot for your explanation.
I was able to reproduce the issue and I think that
https://github.com/ffontaine/u-boot/commit/61a162e5c0343fc55304902042f8c9adfe531f51
should fixed it.
Can you review it? I can also directly send a PR.
Quoted 6 lines
Quoted 3 lines
I still think that dropping the content of HOSTCFLAGS is the actual bug. There is more than -O2 that you lose. If you want your CFLAGS to be respected, append them.
I add Arnout to the list to get his feedback as he is the one that suggested this solution during review of
https://patchwork.ozlabs.org/patch/1092227.
Nothing happened, bug is still present in master. Any suggestions how to resolve it?
Jan
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 96 lines · Jan Kiszka
Quoted 95 lines · Fabrice Fontaine
Quoted 94 lines · Jan Kiszka
Quoted 83 lines · Fabrice Fontaine
Quoted 74 lines · Jan Kiszka
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue.
However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 8 lines
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGNis 0 whenCONFIG_FIT_SIGNATUREis not set. That will remove all code fromtools/image-host.cwhich is not reachable then. When it's not removed because of default optimization settings, we get linker errors becausecommon/image.sig.cis not built withoutCONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.Quoted 5 lines
Thanks a lot for your explanation.
I was able to reproduce the issue and I think that
https://github.com/ffontaine/u-boot/commit/61a162e5c0343fc55304902042f8c9adfe531f51
should fixed it.
Can you review it? I can also directly send a PR.I still think that dropping the content of HOSTCFLAGS is the actual bug. There is more than -O2 that you lose. If you want your CFLAGS to be respected, append them.
Quoted 6 lines
Quoted 3 lines
I add Arnout to the list to get his feedback as he is the one that suggested this solution during review of
https://patchwork.ozlabs.org/patch/1092227.Nothing happened, bug is still present in master. Any suggestions how to resolve it?
OK, I've looked over the thread again. Where and how are you hitting a problem here again? This area is indeed a bit funky and I see OpenEmbedded has long been doing "shove everything we need in via CC, do not use CFLAGS/etc". Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191114/9afd0360/attachment.sig>
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 101 lines · Tom Rini
Quoted 100 lines · Jan Kiszka
Quoted 98 lines · Fabrice Fontaine
Quoted 91 lines · Jan Kiszka
Quoted 83 lines · Fabrice Fontaine
Quoted 74 lines · Jan Kiszka
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue.
However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 8 lines
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGNis 0 whenCONFIG_FIT_SIGNATUREis not set. That will remove all code fromtools/image-host.cwhich is not reachable then. When it's not removed because of default optimization settings, we get linker errors becausecommon/image.sig.cis not built withoutCONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.Quoted 5 lines
Thanks a lot for your explanation.
I was able to reproduce the issue and I think that
https://github.com/ffontaine/u-boot/commit/61a162e5c0343fc55304902042f8c9adfe531f51
should fixed it.
Can you review it? I can also directly send a PR.Quoted 3 lines
I still think that dropping the content of HOSTCFLAGS is the actual bug. There is more than -O2 that you lose. If you want your CFLAGS to be respected, append them.
I add Arnout to the list to get his feedback as he is the one that suggested this solution during review of
https://patchwork.ozlabs.org/patch/1092227.
Quoted 7 lines
Quoted 2 lines
Nothing happened, bug is still present in master. Any suggestions how to resolve it?
OK, I've looked over the thread again. Where and how are you hitting a problem here again? This area is indeed a bit funky and I see OpenEmbedded has long been doing "shove everything we need in via CC, do not use CFLAGS/etc". Thanks!
This is how you can easily reproduce it:
make avnet_ultra96_rev1_defconfig
make CROSS_COMPILE=aarch64-linux-gnu- CROSS_BUILD_TOOLS=y
Jan
PATCH 1/1 tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
Quoted 110 lines · Jan Kiszka
Quoted 101 lines · Tom Rini
Quoted 100 lines · Jan Kiszka
Quoted 98 lines · Fabrice Fontaine
Quoted 91 lines · Jan Kiszka
Quoted 83 lines · Fabrice Fontaine
Quoted 74 lines · Jan Kiszka
Quoted 56 lines · Fabrice Fontaine
Quoted 47 lines · Jan Kiszka
Quoted 45 lines · Fabrice Fontaine
Hello,
Quoted 20 lines · Jan Kiszka
Quoted 18 lines · Fabrice Fontaine
When
CROSS_BUILD_TOOLSis set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrongSigned-off-by Fabrice Fontaine <[email protected]>--- tools/Makefile | 1 + 1 file changed, 1 insertion(+)tools/Makefile +1
-0@@ -272,6 +272,7 @@ subdir- += env ifneq ($(CROSS_BUILD_TOOLS),) override HOSTCC = $(CC) +override HOSTCFLAGS = $(CFLAGS)Quoted 8 lines
tools/Makefile subdir- += env · line 278
Quoted 3 lines
tools/Makefile +0
-0quiet_cmd_crosstools_strip = STRIP $^ cmd_crosstools_strip = $(STRIP) $^; touch $@This eats - among other things - -O2, normally set in /Makefile. And that breaks CROSS_BUILD_TOOLS=y with
CONFIG_FITbut withoutCONFIG_FIT_SIGNATUREbecause "if (!IMAGE_ENABLE_SIGN)" is no longer optimized. I tend to believe this should simply be reverted (which is what I'm doing locally in order to fix my builds).I don't think this patch should be reverted, I sent it to fix a cross-compilation build issue with host-openssl.
Indeed, without this patch, with CROSS_BUILD_TOOLS=y,
tools/Makefilesets HOSTCC=$(CC) but it forgets
to override HOSTCFLAGS, though, so the tools are built with target compiler but host CFLAGS.This raises a build failure if host-openssl is built before uboot-tools because uboot-tools links with openssl headers from host which depends on
pthread.hMore information can be found on buildroot's patchwork here:
- https://patchwork.ozlabs.org/patch/1092227
- https://patchwork.ozlabs.org/patch/1093385Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Jan
Best Regards,
Fabrice
So what is your suggestion to fix the O2-regression best?
Quoted 10 lines
I'm far from being an expert in uboot so please excuse me if my answer contains some mistakes.
However, IMHO, we should not pass -O2 or any other optimization flags.
From my understanding, CFLAGS (and so HOSTCFLAGS when building tools
for the target through cross-tools) will (or should?) contain -O2 or -Os depending onCONFIG_CC_OPTIMIZE_FOR_SIZEvalue.
However, I do understand that this is a change in the former behavior that was always passing -O2 in HOSTCFLAGS.
So, if you really want to pass -O2, I would add it to HOSTCFLAGS intools/Makefile(after the override).This is a hack. U-boot relies on >= -O2 for proper build, so it must inject this setting on its own - which it did prior to your change. I think top-level HOSTCFLAGS belongs to the build, irrespective of native vs. cross. You may allow appending (and, thus, overwriting) settings but you cannot remove mandatory ones.
Quoted 8 lines
Quoted 2 lines
However, I have to confess that I don't understand why the build breaks "if (!IMAGE_ENABLE_SIGN)" is no longer optimized."
IMAGE_ENABLE_SIGNis 0 whenCONFIG_FIT_SIGNATUREis not set. That will remove all code fromtools/image-host.cwhich is not reachable then. When it's not removed because of default optimization settings, we get linker errors becausecommon/image.sig.cis not built withoutCONFIG_FIT_SIGNATURE. I assume this way was preferred over #ifdef'ery, but it's broken now.Quoted 5 lines
Thanks a lot for your explanation.
I was able to reproduce the issue and I think that
https://github.com/ffontaine/u-boot/commit/61a162e5c0343fc55304902042f8c9adfe531f51
should fixed it.
Can you review it? I can also directly send a PR.Quoted 3 lines
I still think that dropping the content of HOSTCFLAGS is the actual bug. There is more than -O2 that you lose. If you want your CFLAGS to be respected, append them.
I add Arnout to the list to get his feedback as he is the one that suggested this solution during review of
https://patchwork.ozlabs.org/patch/1092227.Quoted 7 lines
Quoted 2 lines
Nothing happened, bug is still present in master. Any suggestions how to resolve it?
OK, I've looked over the thread again. Where and how are you hitting a problem here again? This area is indeed a bit funky and I see OpenEmbedded has long been doing "shove everything we need in via CC, do not use CFLAGS/etc". Thanks!
Quoted 4 lines
This is how you can easily reproduce it:
make
avnet_ultra96_rev1_defconfig
make CROSS_COMPILE=aarch64-linux-gnu- CROSS_BUILD_TOOLS=y
Ah, OK. So, I wonder about:
commit 72c69ea8d603fd2448dd1d7c399c4f77b77773b7
Author: Fabrice Fontaine <[email protected]> Date: Wed May 1 15:08:25 2019 +0200
tools/Makefile: fix HOSTCFLAGS with CROSS_BUILD_TOOLS
When CROSS_BUILD_TOOLS is set, set HOSTCFLAGS to CFLAGS otherwise CC will be used with HOSTCFLAGS which seems wrong
As while it may seem wrong we consistently use KBUILD_CFLAGS for U-Boot itself (ala the kernel) and HOSTCFLAGS for the tools, both when we run them on the build host and when we build them for the target. So for example the above commit also breaks CONFIG_TOOLS_DEBUG. Buildroot may need to fix the problem by appending to HOSTCFLAGS or similar.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191114/f1b89c9a/attachment.sig>