smartweb: Enable LTO
PATCH 1/2 smartweb: Enable LTO
In order to prepare for slight size growth due to reworking linker list support, enable LTO here to save more space again.
---
Cc: Heiko Schocher <[email protected]>
--- configs/smartweb_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/smartweb_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x400 CONFIG_SPL=y CONFIG_ENV_OFFSET_REDUND=0x180000 CONFIG_SYS_LOAD_ADDR=0x22000000 +CONFIG_LTO=y CONFIG_FIT=y CONFIG_NAND_BOOT=y CONFIG_BOOTDELAY=3
Signature · 1 line
2.34.1
PATCH 2/2 linker_lists: Rework start/end macros to not rely on undefined behavior
Per the GCC bug listed below, the way we do linker lists is relying on undefined behavior that seems to work in gcc, but doesn't always work in clang. Andrew suggests rewriting our start/end macros in a different way (as implemented here, from what he said in comment 1) to avoid these problems.
---
Andrew, please feel free to reply with any further tags you want here, I wasn't exactly sure of the best way to attribute this to you. Thanks!
--- include/linker_lists.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
include/linker_lists.h +12 -4
@@ -127,7 +127,9 @@ static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ __attribute__((unused)) \ __section("__u_boot_list_2_"#_list"_1"); \ - (_type *)&start; \ +_type * tmp = (_type *)&start; \ +asm("":" +r"(tmp)); \ +tmp; \ }) /**
@@ -153,7 +155,9 @@ ({ \ static char end[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_2_"#_list"_3"); \ - (_type *)&end; \ +_type * tmp = (_type *)&end; \ + asm("" :"+r" (tmp)); \ + tmp; \ })/** * ll_entry_count() - Return the number of elements in linker-generated array
@@ -247,7 +251,9 @@ ({ \ static char start[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_1"); \ - (_type *)&start; \ +_type * tmp = (_type *)&start; \ + asm("" :"+r" (tmp)); \ + tmp; \ })/**
@@ -270,7 +276,9 @@ ({ \ static char end[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_3"); \ - (_type *)&end; \ +_type * tmp = (_type *)&end; \ + asm("" :"+r" (tmp)); \ + tmp; \ })#endif /* __ASSEMBLY__ */
Signature · 1 line
2.34.1
Re: [PATCH 2/2] linker_lists: Rework start/end macros to not rely on undefined behavior
Quoted 11 lines · Tom Rini
Per the GCC bug listed below, the way we do linker lists is relying on undefined behavior that seems to work in gcc, but doesn't always work in clang. Andrew suggests rewriting our start/end macros in a different way (as implemented here, from what he said in comment 1) to avoid these problems.
Reported-by AdityaK <[email protected]>Suggested-by Andrew Pinski <[email protected]>Signed-off-by Tom Rini <[email protected]>
Quoted 7 lines
---
Andrew, please feel free to reply with any further tags you want here, I wasn't exactly sure of the best way to attribute this to you. Thanks!--- include/linker_lists.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
Re: [PATCH 2/2] linker_lists: Rework start/end macros to not rely on undefined behavior
In reply to Tom RiniQuoted 9 lines · Tom Rini
Per the GCC bug listed below, the way we do linker lists is relying on undefined behavior that seems to work in gcc, but doesn't always work in clang. Andrew suggests rewriting our start/end macros in a different way (as implemented here, from what he said in comment 1) to avoid these problems.
Reported-by AdityaK <[email protected]>Suggested-by Andrew Pinski <[email protected]>
Other than that it looks good.
Thanks,
Andrew Pinski
Quoted 60 lines
---
Andrew, please feel free to reply with any further tags you want here, I wasn't exactly sure of the best way to attribute this to you. Thanks!--- include/linker_lists.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)include/linker_lists.h +12
-5@@ -127,7 +127,9 @@ static char start[0] __aligned(CONFIG_LINKER_LIST_ALIGN) \ __attribute__((unused)) \ __section("__u_boot_list_2_"#_list"_1"); \ - (_type *)&start; \ +_type * tmp = (_type *)&start; \ +asm("":" +r"(tmp)); \ +tmp; \ }) /** @@ -153,7 +155,9 @@ ({ \ static char end[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_2_"#_list"_3"); \ - (_type *)&end; \ +_type * tmp = (_type *)&end; \ + asm("" :"+r" (tmp)); \ + tmp; \ })/** * ll_entry_count() - Return the number of elements in linker-generated array @@ -247,7 +251,9 @@ ({ \ static char start[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_1"); \ - (_type *)&start; \ +_type * tmp = (_type *)&start; \ + asm("" :"+r" (tmp)); \ + tmp; \ })/** @@ -270,7 +276,9 @@ ({ \ static char end[0] __aligned(4) __attribute__((unused)) \ __section("__u_boot_list_3"); \ - (_type *)&end; \ +_type * tmp = (_type *)&end; \ + asm("" :"+r" (tmp)); \ + tmp; \ })#endif /* __ASSEMBLY__ */ --2.34.1
Re: [PATCH 2/2] linker_lists: Rework start/end macros to not rely on undefined behavior
In reply to Tom RiniQuoted 6 lines · Tom Rini
Per the GCC bug listed below, the way we do linker lists is relying on undefined behavior that seems to work in gcc, but doesn't always work in clang. Andrew suggests rewriting our start/end macros in a different way (as implemented here, from what he said in comment 1) to avoid these problems.
Quoted 6 lines
Reported-by AdityaK <[email protected]>Suggested-by Andrew Pinski <[email protected]>Signed-off-by Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Andrew Pinski <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom
Hello Tom,
Quoted 9 lines · Tom Rini
In order to prepare for slight size growth due to reworking linker list support, enable LTO here to save more space again.
Signed-off-by Tom Rini <[email protected]>---
Cc: Heiko Schocher <[email protected]>--- configs/smartweb_defconfig | 1 + 1 file changed, 1 insertion(+)
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Quoted 5 lines · Tom Rini
In order to prepare for slight size growth due to reworking linker list support, enable LTO here to save more space again.
Signed-off-by Tom Rini <[email protected]>Reviewed-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom