buildman: Fetch 12.2.0 toolchains by default
Subsystems (2)
PATCH 1/6 buildman: Fetch 12.2.0 toolchains by default
Update the toolchain list to be first 12.2.0 and second 11.1.0 and that's it.
--- tools/buildman/toolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/buildman/toolchain.py +1 -1
@@ -498,7 +498,7 @@ class Toolchains: if arch == 'aarch64': arch = 'arm64' base = 'https://www.kernel.org/pub/tools/crosstool/files/bin' - versions = ['11.1.0', '9.2.0', '7.3.0', '6.4.0', '4.9.4'] + versions = ['12.2.0', '11.1.0'] links = [] for version in versions: url = '%s/%s/%s/' % (base, arch, version)
Signature · 1 line
2.25.1
PATCH 2/6 Makefile: Enforce DWARF4 output
At this point in time, using DWARF-5 format isn't easy to do by default with all toolchains that we support. And relying on the implicit default can lead to mixing 4 and 5 and then the debug info not being useful to tools. For now, enforce using DWARF-4 only.
--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -761,10 +761,10 @@ KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) # change __FILE__ to the relative path from the srctree KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) -KBUILD_CFLAGS += -g +KBUILD_CFLAGS += -gdwarf-4 # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format> # option to the assembler. -KBUILD_AFLAGS += -g +KBUILD_AFLAGS += -gdwarf-4 # Report stack usage if supported # ARC tools based on GCC 7.1 has an issue with stack usage
Signature · 1 line
2.25.1
Re: [PATCH 2/6] Makefile: Enforce DWARF4 output
Quoted 10 lines · Tom Rini
At this point in time, using DWARF-5 format isn't easy to do by default with all toolchains that we support. And relying on the implicit default can lead to mixing 4 and 5 and then the debug info not being useful to tools. For now, enforce using DWARF-4 only.
Signed-off-by Tom Rini <[email protected]>--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 3/6 event: Re-add file paths to the tests
In reply to Tom RiniNow that we are enforcing dwarf-4 to be used we will have the full file paths present.
--- test/py/tests/test_event_dump.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
test/py/tests/test_event_dump.py +3 -3
@@ -16,7 +16,7 @@ def test_event_dump(u_boot_console): out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox]) expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ -EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*vbe_request.c:.* -EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*vbe_simple_os.c:.* -EVT_MISC_INIT_F sandbox_misc_init_f .*start.c:''' +EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.* +EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple_os.c:.* +EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:''' assert re.match(expect, out, re.MULTILINE) is not None
Signature · 1 line
2.25.1
Re: [PATCH 3/6] event: Re-add file paths to the tests
Quoted 10 lines · Tom Rini
Now that we are enforcing dwarf-4 to be used we will have the full file paths present.
Cc Simon Glass <[email protected]>Signed-off-by Tom Rini <[email protected]>--- test/py/tests/test_event_dump.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH 4/6 arm: Use the WEAK assembly entry point consistently
In reply to Tom RiniIt is a bad idea, and more modern toolchains will fail, if you declare an assembly function to be global and then weak, instead of declaring it weak to start with. Update assorted assembly files to use the WEAK macro directly.
--- arch/arm/cpu/armv7/nonsec_virt.S | 3 +- arch/arm/cpu/armv7/psci.S | 77 +++++++++++--------------------- arch/arm/cpu/armv7/start.S | 6 +-- arch/arm/cpu/armv8/psci.S | 12 ++--- arch/arm/lib/relocate.S | 3 +- 5 files changed, 34 insertions(+), 67 deletions(-)
arch/arm/cpu/armv7/nonsec_virt.S +1 -2
@@ -207,7 +207,7 @@ ENDPROC(_nonsec_init) #ifdef CONFIG_SMP_PEN_ADDR /* void __weak smp_waitloop(unsigned previous_address); */ -ENTRY(smp_waitloop) +WEAK(smp_waitloop) wfi ldr r1, =CONFIG_SMP_PEN_ADDR @ load start address ldr r1, [r1]
@@ -219,7 +219,6 @@ ENTRY(smp_waitloop) mov r0, r1 b _do_nonsec_entry ENDPROC(smp_waitloop) -.weak smp_waitloop #endif .popsection
arch/arm/cpu/armv7/psci.S +26 -51
134 lines not on this page · raw message
arch/arm/cpu/armv7/start.S +2 -4
@@ -151,16 +151,14 @@ ENDPROC(c_runtime_cpu_setup) * Don't save anything to stack even if compiled with -O0 * *************************************************************************/ -ENTRY(save_boot_params) +WEAK(save_boot_params) b save_boot_params_ret @ back to my caller ENDPROC(save_boot_params) - .weak save_boot_params #ifdef CONFIG_ARMV7_LPAE -ENTRY(switch_to_hypervisor) +WEAK(switch_to_hypervisor) b switch_to_hypervisor_ret ENDPROC(switch_to_hypervisor) - .weak switch_to_hypervisor #endif /*************************************************************************
arch/arm/cpu/armv8/psci.S +4 -8
@@ -12,11 +12,10 @@ /* Default PSCI function, return -1, Not Implemented */ #define PSCI_DEFAULT(__fn) \ - ENTRY(__fn); \ + WEAK(__fn); \ mov w0, #ARM_PSCI_RET_NI; \ ret; \ ENDPROC(__fn); \ - .weak __fn /* PSCI function and ID table definition*/ #define PSCI_TABLE(__id, __fn) \
@@ -207,7 +206,7 @@ handle_smc64: * used for the return value, while in this PSCI environment, X0 usually holds * the SMC function identifier, so X0 should be saved by caller function. */ -ENTRY(psci_get_cpu_id) +WEAK(psci_get_cpu_id) #ifdef CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER mrs x9, MPIDR_EL1 ubfx x9, x9, #8, #8
@@ -221,7 +220,6 @@ ENTRY(psci_get_cpu_id) add x0, x10, x9 ret ENDPROC(psci_get_cpu_id) -.weak psci_get_cpu_id /* CPU ID input in x0, stack top output in x0*/ LENTRY(psci_get_cpu_stack_top)
@@ -261,10 +259,9 @@ handle_sync: * Override this function if custom error handling is * needed for asynchronous aborts */ -ENTRY(plat_error_handler) +WEAK(plat_error_handler) ret ENDPROC(plat_error_handler) -.weak plat_error_handler handle_error: bl psci_get_cpu_id
@@ -323,9 +320,8 @@ ENTRY(psci_setup_vectors) ret ENDPROC(psci_setup_vectors) -ENTRY(psci_arch_init) +WEAK(psci_arch_init) ret ENDPROC(psci_arch_init) -.weak psci_arch_init .popsection
arch/arm/lib/relocate.S +1 -2
@@ -23,9 +23,8 @@ */ .section .text.relocate_vectors,"ax",%progbits - .weak relocate_vectors -ENTRY(relocate_vectors) +WEAK(relocate_vectors) #ifdef CONFIG_CPU_V7M /*
Signature · 1 line
2.25.1
Re: [PATCH 4/6] arm: Use the WEAK assembly entry point consistently
Quoted 6 lines · Tom Rini
It is a bad idea, and more modern toolchains will fail, if you declare an assembly function to be global and then weak, instead of declaring it weak to start with. Update assorted assembly files to use the WEAK macro directly.
Quoted 9 lines
Signed-off-by Tom Rini <[email protected]>--- arch/arm/cpu/armv7/nonsec_virt.S | 3 +- arch/arm/cpu/armv7/psci.S | 77 +++++++++++--------------------- arch/arm/cpu/armv7/start.S | 6 +-- arch/arm/cpu/armv8/psci.S | 12 ++--- arch/arm/lib/relocate.S | 3 +- 5 files changed, 34 insertions(+), 67 deletions(-)
Re: [PATCH 4/6] arm: Use the WEAK assembly entry point consistently
In reply to Tom RiniQuoted 6 lines · On Tuesday 22 November 2022 12:31:56 Tom Rini wrote:
It is a bad idea, and more modern toolchains will fail, if you declare an assembly function to be global and then weak, instead of declaring it weak to start with. Update assorted assembly files to use the WEAK macro directly.
Signed-off-by Tom Rini <[email protected]>
During debugging of Nokia N900 code I was looking at this and I originally thought that this redefinition is the issue why N900 u-boot did not work... (but as we now know, the n900 issue was somewhere else).
So I agree with this change, feel free to add my:
... but even after this change, linked u-boot.bin binary is not-so-correct. It works but has an issue: In final u-boot.bin binary there is both weak and non-weak version of every weak function. You can verify it for example by looking at "save_boot_params" code (really code, not just symbol) in u-boot ELF binary.
The reason for this is that linker (even LTO enabled) cannot eliminate code for weak version of function because it does not know how to "drop" it from binary/assembly code. So linker just set that non-weak version of function is active and let non-weak version present in binary as probably dead code.
This is affected only by assembly files, not by C files, because gcc is called with -ffunction-sections -fdata-sections flags which cause that every (weak) function is in its separate section (so C function "int abc() { ... }" is put into the section ".text.abc" instead of ".text") and linker's flag --gc-sections (or LTO optimization) then drop all unreferenced sections.
I do not know how fix this issue in assembly files. But cannot be WEAK macro modified to change section to ".text.<entry_name>" to mimic C compiler behavior? Would this cause any issues?
Quoted 271 lines
--- arch/arm/cpu/armv7/nonsec_virt.S | 3 +- arch/arm/cpu/armv7/psci.S | 77 +++++++++++--------------------- arch/arm/cpu/armv7/start.S | 6 +-- arch/arm/cpu/armv8/psci.S | 12 ++--- arch/arm/lib/relocate.S | 3 +- 5 files changed, 34 insertions(+), 67 deletions(-)arch/arm/cpu/armv7/nonsec_virt.S +1
-2@@ -207,7 +207,7 @@ ENDPROC(_nonsec_init) #ifdef CONFIG_SMP_PEN_ADDR /* void __weak smp_waitloop(unsigned previous_address); */ -ENTRY(smp_waitloop) +WEAK(smp_waitloop) wfi ldr r1, =CONFIG_SMP_PEN_ADDR @ load start address ldr r1, [r1]@@ -219,7 +219,6 @@ ENTRY(smp_waitloop) mov r0, r1 b _do_nonsec_entry ENDPROC(smp_waitloop) -.weak smp_waitloop #endif .popsectionarch/arm/cpu/armv7/psci.S +26
-51@@ -36,34 +36,32 @@ _psci_vectors: b default_psci_vector @ irq b psci_fiq_enter @ fiq -ENTRY(psci_fiq_enter) +WEAK(psci_fiq_enter) movs pc, lr ENDPROC(psci_fiq_enter) -.weak psci_fiq_enter -ENTRY(default_psci_vector) +WEAK(default_psci_vector) movs pc, lr ENDPROC(default_psci_vector) -.weak default_psci_vector - -ENTRY(psci_version) -ENTRY(psci_cpu_suspend) -ENTRY(psci_cpu_off) -ENTRY(psci_cpu_on) -ENTRY(psci_affinity_info) -ENTRY(psci_migrate) -ENTRY(psci_migrate_info_type) -ENTRY(psci_migrate_info_up_cpu) -ENTRY(psci_system_off) -ENTRY(psci_system_reset) -ENTRY(psci_features) -ENTRY(psci_cpu_freeze) -ENTRY(psci_cpu_default_suspend) -ENTRY(psci_node_hw_state) -ENTRY(psci_system_suspend) -ENTRY(psci_set_suspend_mode) -ENTRY(psi_stat_residency) -ENTRY(psci_stat_count) + +WEAK(psci_version) +WEAK(psci_cpu_suspend) +WEAK(psci_cpu_off) +WEAK(psci_cpu_on) +WEAK(psci_affinity_info) +WEAK(psci_migrate) +WEAK(psci_migrate_info_type) +WEAK(psci_migrate_info_up_cpu) +WEAK(psci_system_off) +WEAK(psci_system_reset) +WEAK(psci_features) +WEAK(psci_cpu_freeze) +WEAK(psci_cpu_default_suspend) +WEAK(psci_node_hw_state) +WEAK(psci_system_suspend) +WEAK(psci_set_suspend_mode) +WEAK(psi_stat_residency) +WEAK(psci_stat_count) mov r0, #ARM_PSCI_RET_NI @ Return -1 (Not Implemented) mov pc, lr ENDPROC(psci_stat_count)@@ -84,24 +82,6 @@ ENDPROC(psci_cpu_on) ENDPROC(psci_cpu_off) ENDPROC(psci_cpu_suspend) ENDPROC(psci_version) -.weak psci_version -.weak psci_cpu_suspend -.weak psci_cpu_off -.weak psci_cpu_on -.weak psci_affinity_info -.weak psci_migrate -.weak psci_migrate_info_type -.weak psci_migrate_info_up_cpu -.weak psci_system_off -.weak psci_system_reset -.weak psci_features -.weak psci_cpu_freeze -.weak psci_cpu_default_suspend -.weak psci_node_hw_state -.weak psci_system_suspend -.weak psci_set_suspend_mode -.weak psi_stat_residency -.weak psci_stat_count _psci_table: .word ARM_PSCI_FN_CPU_SUSPEND@@ -179,12 +159,11 @@ _smc_psci: movs pc, lr @ Return to the kernel @ Requires dense and single-cluster CPU ID space -ENTRY(psci_get_cpu_id) +WEAK(psci_get_cpu_id) mrc p15, 0, r0, c0, c0, 5 /* read MPIDR */ and r0, r0, #0xff /* return CPU ID in cluster */ bx lr ENDPROC(psci_get_cpu_id) -.weak psci_get_cpu_id /* Imported from Linux kernel */ ENTRY(psci_v7_flush_dcache_all)@@ -236,7 +215,7 @@ finished: bx lr ENDPROC(psci_v7_flush_dcache_all) -ENTRY(psci_disable_smp) +WEAK(psci_disable_smp) mrc p15, 0, r0, c1, c0, 1 @ ACTLR bic r0, r0, #(1 << 6) @ Clear SMP bit mcr p15, 0, r0, c1, c0, 1 @ ACTLR@@ -244,16 +223,14 @@ ENTRY(psci_disable_smp) dsb bx lr ENDPROC(psci_disable_smp) -.weak psci_disable_smp -ENTRY(psci_enable_smp) +WEAK(psci_enable_smp) mrc p15, 0, r0, c1, c0, 1 @ ACTLR orr r0, r0, #(1 << 6) @ Set SMP bit mcr p15, 0, r0, c1, c0, 1 @ ACTLR isb bx lr ENDPROC(psci_enable_smp) -.weak psci_enable_smp ENTRY(psci_cpu_off_common) push {lr}@@ -316,15 +293,13 @@ ENTRY(psci_stack_setup) bx r6 ENDPROC(psci_stack_setup) -ENTRY(psci_arch_init) +WEAK(psci_arch_init) mov pc, lr ENDPROC(psci_arch_init) -.weak psci_arch_init -ENTRY(psci_arch_cpu_entry) +WEAK(psci_arch_cpu_entry) mov pc, lr ENDPROC(psci_arch_cpu_entry) -.weak psci_arch_cpu_entry ENTRY(psci_cpu_entry) bl psci_enable_smparch/arm/cpu/armv7/start.S +2
-4@@ -151,16 +151,14 @@ ENDPROC(c_runtime_cpu_setup) * Don't save anything to stack even if compiled with -O0 * *************************************************************************/ -ENTRY(save_boot_params) +WEAK(save_boot_params) b save_boot_params_ret @ back to my caller ENDPROC(save_boot_params) - .weak save_boot_params #ifdef CONFIG_ARMV7_LPAE -ENTRY(switch_to_hypervisor) +WEAK(switch_to_hypervisor) b switch_to_hypervisor_ret ENDPROC(switch_to_hypervisor) - .weak switch_to_hypervisor #endif /*************************************************************************arch/arm/cpu/armv8/psci.S +4
-8@@ -12,11 +12,10 @@ /* Default PSCI function, return -1, Not Implemented */ #define PSCI_DEFAULT(__fn) \ - ENTRY(__fn); \ + WEAK(__fn); \ mov w0, #ARM_PSCI_RET_NI; \ ret; \ ENDPROC(__fn); \ - .weak __fn /* PSCI function and ID table definition*/ #define PSCI_TABLE(__id, __fn) \@@ -207,7 +206,7 @@ handle_smc64: * used for the return value, while in this PSCI environment, X0 usually holds * the SMC function identifier, so X0 should be saved by caller function. */ -ENTRY(psci_get_cpu_id) +WEAK(psci_get_cpu_id) #ifdef CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER mrs x9, MPIDR_EL1 ubfx x9, x9, #8, #8@@ -221,7 +220,6 @@ ENTRY(psci_get_cpu_id) add x0, x10, x9 ret ENDPROC(psci_get_cpu_id) -.weak psci_get_cpu_id /* CPU ID input in x0, stack top output in x0*/ LENTRY(psci_get_cpu_stack_top)@@ -261,10 +259,9 @@ handle_sync: * Override this function if custom error handling is * needed for asynchronous aborts */ -ENTRY(plat_error_handler) +WEAK(plat_error_handler) ret ENDPROC(plat_error_handler) -.weak plat_error_handler handle_error: bl psci_get_cpu_id@@ -323,9 +320,8 @@ ENTRY(psci_setup_vectors) ret ENDPROC(psci_setup_vectors) -ENTRY(psci_arch_init) +WEAK(psci_arch_init) ret ENDPROC(psci_arch_init) -.weak psci_arch_init .popsectionarch/arm/lib/relocate.S +1
-2@@ -23,9 +23,8 @@ */ .section .text.relocate_vectors,"ax",%progbits - .weak relocate_vectors -ENTRY(relocate_vectors) +WEAK(relocate_vectors) #ifdef CONFIG_CPU_V7M /*Signature · 1 line
2.25.1
Re: [PATCH 4/6] arm: Use the WEAK assembly entry point consistently
Quoted 35 lines · Pali Rohár
Quoted 6 lines · On Tuesday 22 November 2022 12:31:56 Tom Rini wrote:
It is a bad idea, and more modern toolchains will fail, if you declare an assembly function to be global and then weak, instead of declaring it weak to start with. Update assorted assembly files to use the WEAK macro directly.
Signed-off-by Tom Rini <[email protected]>During debugging of Nokia N900 code I was looking at this and I originally thought that this redefinition is the issue why N900 u-boot did not work... (but as we now know, the n900 issue was somewhere else).
So I agree with this change, feel free to add my:
Reviewed-by Pali Rohár <[email protected]>... but even after this change, linked u-boot.bin binary is not-so-correct. It works but has an issue: In final u-boot.bin binary there is both weak and non-weak version of every weak function. You can verify it for example by looking at "
save_boot_params" code (really code, not just symbol) in u-boot ELF binary.The reason for this is that linker (even LTO enabled) cannot eliminate code for weak version of function because it does not know how to "drop" it from binary/assembly code. So linker just set that non-weak version of function is active and let non-weak version present in binary as probably dead code.
This is affected only by assembly files, not by C files, because gcc is called with -ffunction-sections -fdata-sections flags which cause that every (weak) function is in its separate section (so C function "int
abc(){ ... }" is put into the section ".text.abc" instead of ".text") and linker's flag --gc-sections (or LTO optimization) then drop all unreferenced sections.
Quoted 3 lines
I do not know how fix this issue in assembly files. But cannot be WEAK macro modified to change section to ".text.<entry_name>" to mimic C compiler behavior? Would this cause any issues?
Yes, you're right about the cause, and potential solution. If you can come up with a way to get each assembly function put in to a separate .text.funcname section, that would be great and much appreciated. I think I tried this at one point a long long time ago and it did work, but I didn't have something clean, either. I think I was hoping that the linux kernel folks would solve it in time, but they decided the time/effort for --gc-sections wasn't worth it, in the end.
Signature · 1 line
Tom
Re: [PATCH 4/6] arm: Use the WEAK assembly entry point consistently
Quoted 40 lines · On Wednesday 23 November 2022 18:15:17 Tom Rini wrote:
Quoted 35 lines · Pali Rohár
Quoted 6 lines · On Tuesday 22 November 2022 12:31:56 Tom Rini wrote:
It is a bad idea, and more modern toolchains will fail, if you declare an assembly function to be global and then weak, instead of declaring it weak to start with. Update assorted assembly files to use the WEAK macro directly.
Signed-off-by Tom Rini <[email protected]>During debugging of Nokia N900 code I was looking at this and I originally thought that this redefinition is the issue why N900 u-boot did not work... (but as we now know, the n900 issue was somewhere else).
So I agree with this change, feel free to add my:
Reviewed-by Pali Rohár <[email protected]>... but even after this change, linked u-boot.bin binary is not-so-correct. It works but has an issue: In final u-boot.bin binary there is both weak and non-weak version of every weak function. You can verify it for example by looking at "
save_boot_params" code (really code, not just symbol) in u-boot ELF binary.The reason for this is that linker (even LTO enabled) cannot eliminate code for weak version of function because it does not know how to "drop" it from binary/assembly code. So linker just set that non-weak version of function is active and let non-weak version present in binary as probably dead code.
This is affected only by assembly files, not by C files, because gcc is called with -ffunction-sections -fdata-sections flags which cause that every (weak) function is in its separate section (so C function "int
abc(){ ... }" is put into the section ".text.abc" instead of ".text") and linker's flag --gc-sections (or LTO optimization) then drop all unreferenced sections.Quoted 3 lines
I do not know how fix this issue in assembly files. But cannot be WEAK macro modified to change section to ".text.<entry_name>" to mimic C compiler behavior? Would this cause any issues?
Quoted 7 lines
Yes, you're right about the cause, and potential solution. If you can come up with a way to get each assembly function put in to a separate .text.funcname section, that would be great and much appreciated. I think I tried this at one point a long long time ago and it did work, but I didn't have something clean, either. I think I was hoping that the linux kernel folks would solve it in time, but they decided the time/effort for --gc-sections wasn't worth it, in the end.
I quickly looked at this. If "as" is invoked with --sectname-subst flag then it is possible to use '.section %S.<func_name>' and '.previous' directives. See documentation where is example of that:
https://sourceware.org/binutils/docs/as/Section.html#ELF-Version
I experimented with adding into include/linux/linkage.h:
#define WEAKSECT(name) \
.section .text.name ASM_NL \
WEAK(name)
#define ENDPROCSECT(name) \
ENDPROC(name) ASM_NL \
.previousAnd then defining in arch/arm/cpu/armv7/start.S:
WEAKSECT(save_boot_params)
b save_boot_params_ret
ENDPROCSECT(save_boot_params)
(Note that n900 has custom non-weak save_boot_params)
Then I run:
make CROSS_COMPILE=arm-linux-gnueabi- nokia_rx51_defconfig u-boot.bin KBUILD_LDFLAGS="--print-gc-sections"
And it showed me:
ld: removing unused section '.text.save_boot_params' in file 'arch/arm/cpu/armv7/start.o'
So seems that it is working.
For proper integration it would be needed to integrate --sectname-subst flag support and then replace all usage by new macros.
Re: [PATCH 4/6] arm: Use the WEAK assembly entry point consistently
Quoted 76 lines · Pali Rohár
Quoted 40 lines · On Wednesday 23 November 2022 18:15:17 Tom Rini wrote:
Quoted 35 lines · Pali Rohár
Quoted 6 lines · On Tuesday 22 November 2022 12:31:56 Tom Rini wrote:
It is a bad idea, and more modern toolchains will fail, if you declare an assembly function to be global and then weak, instead of declaring it weak to start with. Update assorted assembly files to use the WEAK macro directly.
Signed-off-by Tom Rini <[email protected]>During debugging of Nokia N900 code I was looking at this and I originally thought that this redefinition is the issue why N900 u-boot did not work... (but as we now know, the n900 issue was somewhere else).
So I agree with this change, feel free to add my:
Reviewed-by Pali Rohár <[email protected]>... but even after this change, linked u-boot.bin binary is not-so-correct. It works but has an issue: In final u-boot.bin binary there is both weak and non-weak version of every weak function. You can verify it for example by looking at "
save_boot_params" code (really code, not just symbol) in u-boot ELF binary.The reason for this is that linker (even LTO enabled) cannot eliminate code for weak version of function because it does not know how to "drop" it from binary/assembly code. So linker just set that non-weak version of function is active and let non-weak version present in binary as probably dead code.
This is affected only by assembly files, not by C files, because gcc is called with -ffunction-sections -fdata-sections flags which cause that every (weak) function is in its separate section (so C function "int
abc(){ ... }" is put into the section ".text.abc" instead of ".text") and linker's flag --gc-sections (or LTO optimization) then drop all unreferenced sections.Quoted 3 lines
I do not know how fix this issue in assembly files. But cannot be WEAK macro modified to change section to ".text.<entry_name>" to mimic C compiler behavior? Would this cause any issues?
Quoted 7 lines
Yes, you're right about the cause, and potential solution. If you can come up with a way to get each assembly function put in to a separate .text.funcname section, that would be great and much appreciated. I think I tried this at one point a long long time ago and it did work, but I didn't have something clean, either. I think I was hoping that the linux kernel folks would solve it in time, but they decided the time/effort for --gc-sections wasn't worth it, in the end.
I quickly looked at this. If "as" is invoked with --sectname-subst flag then it is possible to use '.section %S.<func_name>' and '.previous' directives. See documentation where is example of that:
https://sourceware.org/binutils/docs/as/Section.html#ELF-VersionI experimented with adding into
include/linux/linkage.h:#define WEAKSECT(name) \ .section .text.name ASM_NL \ WEAK(name) #define ENDPROCSECT(name) \ ENDPROC(name) ASM_NL \ .previousAnd then defining in
arch/arm/cpu/armv7/start.S:
WEAKSECT(save_boot_params)
bsave_boot_params_ret
ENDPROCSECT(save_boot_params)(Note that n900 has custom non-weak
save_boot_params)Then I run:
make CROSS_COMPILE=arm-linux-gnueabi-
nokia_rx51_defconfigu-boot.bin KBUILD_LDFLAGS="--print-gc-sections"
Quoted 8 lines
And it showed me:
ld: removing unused section '.text.save_boot_params' in file '
arch/arm/cpu/armv7/start.o'So seems that it is working.
For proper integration it would be needed to integrate --sectname-subst flag support and then replace all usage by new macros.
That's all good to know, thanks for digging more. It would be good to know if a quick and dirty experimental patch showed enough size savings to be worth a more full pursuit or if we really don't have many / any unused assembly functions or what we do have unused could be more easily handled with an ifdef or refactoring into multiple files.
Signature · 1 line
Tom
PATCH 5/6 pogo_v4: Disable LTO
In reply to Tom RiniWith gcc-12.2 we now get:lib/zlib/inflate.c:360: undefined reference to `__gnu_thumb1_case_si' when building this platform. This seems like some odd problem with LTO and Thumb, but since the platform continues to link, I assume it's within size constraints, so lets just disable LTO for now.
--- configs/pogo_v4_defconfig | 1 - 1 file changed, 1 deletion(-)
configs/pogo_v4_defconfig +0 -1
@@ -17,7 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="kirkwood-pogoplug-series-4" CONFIG_SYS_PROMPT="Pogo_V4> " CONFIG_IDENT_STRING="\nPogoplug V4" CONFIG_SYS_LOAD_ADDR=0x800000 -CONFIG_LTO=y CONFIG_DISTRO_DEFAULTS=y CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc8012000
Signature · 1 line
2.25.1
A message that is not in the archive (sent off-list or not yet received): CAJaLiFwY3eyeca4eOEW0XRF0NdaLvFAgi_BLTD-v7U=vjTemKg@mail.gmail.com
Re: [PATCH 5/6] pogo_v4: Disable LTO
Resend to include the mailing list!
Tony
Quoted 40 lines · Tony Dinh
Hi Tom,
Quoted 6 lines · Tom Rini
With gcc-12.2 we now get:
lib/zlib/inflate.c:360: undefined reference to `__gnu_thumb1_case_si' when building this platform. This seems like some odd problem with LTO and Thumb, but since the platform continues to link, I assume it's within size constraints, so lets just disable LTO for now.We don't have a hard size constraint for this board. Thumb and LTO were to help keep the image 512K or less (by convention, for some downstream scripts).
Thanks,
Acked-by Tony Dinh <[email protected]>Quoted 22 lines
Cc Tony Dinh <[email protected]>Signed-off-by Tom Rini <[email protected]>--- configs/pogo_v4_defconfig | 1 - 1 file changed, 1 deletion(-)configs/pogo_v4_defconfig +0
-2@@ -17,7 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="kirkwood-pogoplug-series-4" CONFIG_SYS_PROMPT="Pogo_V4> " CONFIG_IDENT_STRING="\nPogoplug V4" CONFIG_SYS_LOAD_ADDR=0x800000 -CONFIG_LTO=y CONFIG_DISTRO_DEFAULTS=y CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc8012000 --2.25.1
Re: [PATCH 5/6] pogo_v4: Disable LTO
Quoted 19 lines · Tony Dinh
Resend to include the mailing list!
Tony
Quoted 14 lines · Tony Dinh
Hi Tom,
Quoted 6 lines · Tom Rini
With gcc-12.2 we now get:
lib/zlib/inflate.c:360: undefined reference to `__gnu_thumb1_case_si' when building this platform. This seems like some odd problem with LTO and Thumb, but since the platform continues to link, I assume it's within size constraints, so lets just disable LTO for now.We don't have a hard size constraint for this board. Thumb and LTO were to help keep the image 512K or less (by convention, for some downstream scripts).
Ah, well, uh-oh. Then we needed to add:CONFIG_HAS_BOARD_SIZE_LIMIT=yCONFIG_BOARD_SIZE_LIMIT=524288
to the config. Which is fine now, but without both LTO and thumb, we now are too big. So this means digging harder at that error message. Which in turn shows that 806f86bd826e ("arm: lib: Import Thumb1 functions") is where we imported the __gnu_thumb1_case_* functions we have now, and need to do similar work to import (and then do the follow-up improvements to) __gnu_thumb1_case_si. Can you please take a look at that? FWIW, the gcc-12.2.0 toolchain I'm using is just
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-arm-linux-gnueabi.tar.xz
Signature · 1 line
Tom
Re: [PATCH 5/6] pogo_v4: Disable LTO
Hi Tom,
Quoted 22 lines · Tom Rini
Quoted 19 lines · Tony Dinh
Resend to include the mailing list!
Tony
Quoted 14 lines · Tony Dinh
Hi Tom,
Quoted 6 lines · Tom Rini
With gcc-12.2 we now get:
lib/zlib/inflate.c:360: undefined reference to `__gnu_thumb1_case_si' when building this platform. This seems like some odd problem with LTO and Thumb, but since the platform continues to link, I assume it's within size constraints, so lets just disable LTO for now.We don't have a hard size constraint for this board. Thumb and LTO were to help keep the image 512K or less (by convention, for some downstream scripts).
Quoted 11 lines
Ah, well, uh-oh. Then we needed to add:
CONFIG_HAS_BOARD_SIZE_LIMIT=yCONFIG_BOARD_SIZE_LIMIT=524288
to the config. Which is fine now, but without both LTO and thumb, we now are too big. So this means digging harder at that error message. Which in turn shows that806f86bd826e("arm: lib: Import Thumb1 functions") is where we imported the __gnu_thumb1_case_* functions we have now, and need to do similar work to import (and then do the follow-up improvements to)__gnu_thumb1_case_si. Can you please take a look at that? FWIW, the gcc-12.2.0 toolchain I'm using is just
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-arm-linux-gnueabi.tar.xz
I think I was not clear in my previous response. We did not implement a hard size constraint, but only tried to keep it small at 512K. If it grows larger, it's OK. Others and I just need to modify the flashing script, which is not a big deal. So removing LTO and Thumb is fine to get through this gcc build problem. Nothing will break because it is still small enough at 670K (built using gcc 11).
I'm not well versed in troubleshooting this type of compiler problem. I could try, but I think someone like Simon would be able to solve it quicker. Please let me know what you think.
All the best,
Tony
Quoted 3 lines
--
Tom
Re: [PATCH 5/6] pogo_v4: Disable LTO
In reply to Tom RiniQuoted 7 lines · Tom Rini
With gcc-12.2 we now get:
lib/zlib/inflate.c:360: undefined reference to `__gnu_thumb1_case_si' when building this platform. This seems like some odd problem with LTO and Thumb, but since the platform continues to link, I assume it's within size constraints, so lets just disable LTO for now.
Quoted 5 lines
Cc Tony Dinh <[email protected]>Signed-off-by Tom Rini <[email protected]>--- configs/pogo_v4_defconfig | 1 - 1 file changed, 1 deletion(-)
PATCH 6/6 CI: Update to gcc-12.2
In reply to Tom Rini- Update to gcc-12.2, and cherry-pick a fix in grub for risc-v
--- .azure-pipelines.yml | 8 ++--- .gitlab-ci.yml | 6 ++-- tools/docker/Dockerfile | 65 +++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 38 deletions(-)
.azure-pipelines.yml +4 -4
@@ -2,7 +2,7 @@ variables: windows_vm: windows-2019 ubuntu_vm: ubuntu-22.04 macos_vm: macOS-12 - ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20221003-17Oct2022 + ci_runner_image: trini/u-boot-gitlab-ci-runner:jammy-20221101-22Nov2022 # Add '-u 0' options for Azure pipelines, otherwise we get "permission # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer", # since our $(ci_runner_image) user is not root.
@@ -204,7 +204,7 @@ stages: options: $(container_option) steps: - script: | - export PATH=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin:$PATH + export PATH=/opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin:$PATH test/nokia_rx51_test.sh - job: pylint
@@ -242,7 +242,7 @@ stages: TEST_PY_BD: "sandbox" sandbox_clang: TEST_PY_BD: "sandbox" - OVERRIDE: "-O clang-13" + OVERRIDE: "-O clang-14" sandbox_nolto: TEST_PY_BD: "sandbox" BUILD_ENV: "NO_LTO=1"
@@ -486,7 +486,7 @@ stages: OVERRIDE: "-a ASAN" sandbox_clang_asan: BUILDMAN: "sandbox" - OVERRIDE: "-O clang-13 -a ASAN" + OVERRIDE: "-O clang-14 -a ASAN" samsung_socfpga: BUILDMAN: "samsung socfpga" sun4i:
.gitlab-ci.yml +3 -3
@@ -2,7 +2,7 @@ # Grab our configured image. The source for this is found # in the u-boot tree at tools/docker/Dockerfile -image: trini/u-boot-gitlab-ci-runner:jammy-20221003-17Oct2022 +image: trini/u-boot-gitlab-ci-runner:jammy-20221101-22Nov2022 # We run some tests in different order, to catch some failures quicker. stages:
@@ -225,7 +225,7 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites: Run tests for Nokia RX-51 (aka N900): stage: testsuites script: - - export PATH=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin:$PATH; + - export PATH=/opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin:$PATH; test/nokia_rx51_test.sh # Check for any pylint regressions
@@ -256,7 +256,7 @@ sandbox test.py: sandbox with clang test.py: variables: TEST_PY_BD: "sandbox" - OVERRIDE: "-O clang-13" + OVERRIDE: "-O clang-14" <<: *buildman_and_testpy_dfn sandbox without LTO test.py:
tools/docker/Dockerfile +34 -31
112 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 6/6] CI: Update to gcc-12.2
Quoted 9 lines · Tom Rini
- Update to gcc-12.2, and cherry-pick a fix in grub for risc-v
Signed-off-by Tom Rini <[email protected]>--- .azure-pipelines.yml | 8 ++--- .gitlab-ci.yml | 6 ++-- tools/docker/Dockerfile | 65 +++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 38 deletions(-)
Quoted 9 lines · Tom Rini
Update the toolchain list to be first 12.2.0 and second 11.1.0 and that's it.
Cc Simon Glass <[email protected]>Signed-off-by Tom Rini <[email protected]>--- tools/buildman/toolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines · Tom Rini
Update the toolchain list to be first 12.2.0 and second 11.1.0 and that's it.
Applied to u-boot/next, thanks!
Signature · 1 line
Tom