-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LTO on ARM 32bit ARM system fails #1627
Comments
I think the orphan section warnings are the root cause of the issue? Does this help? diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S
index 1bcb68ac4b01..5538f205449c 100644
--- a/arch/arm/boot/compressed/vmlinux.lds.S
+++ b/arch/arm/boot/compressed/vmlinux.lds.S
@@ -123,7 +123,7 @@ SECTIONS
. = BSS_START;
__bss_start = .;
- .bss : { *(.bss) }
+ .bss : { *(.bss) *(.bss.*) }
_end = .;
. = ALIGN(8); /* the stack must be 64-bit aligned */ Alternatively, disabling LTO for the compressor might work? diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 41bcbb460fac..78e2bf5f5fb8 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -97,6 +97,7 @@ OBJS += lib1funcs.o ashldi3.o bswapsdi2.o
targets := vmlinux vmlinux.lds piggy_data piggy.o \
head.o $(OBJS)
+KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ |
Hello, Thanks for your swift response. I'll try both and get back to you with results. |
First suggestion did not work, it only skipped those linker warnings, bu produced the same error message after. |
So...the resulting image boots? That's news if so, since we haven't supported (or tried) LTO on arm32. |
It does. Not sure if it is stable on the long-term. Will be deployed to 0-24 production after meticulous testing, I'll get back with my experience if you are interested. |
We should upstream Nathan's patch if it works. |
Keep in mind that the alpha architecture has exactly the same code for the de-compressor routine, I would eat my hat if it wouldn't behave the same. (LTO-ig the whole kernel just fine then dying at the compression part) |
It does for me (with
LLVM does not have an Alpha backend as far as I can tell, so it is not really relevant since the only other option for LTO would be GCC, which is not upstream. |
via
(That's not an explanation as to why though).
I interpret this point more so as "let's figure out why the decompressor goes wrong under LTO BEFORE sending arm32 LTO support upstream, so that we can drop the proposed diff to |
Also, I forgot to mention that I had enabled 32-bit ARM support by doing an ugly hack on the arch/Kconfig file and removing all the needed dependency factors for "HAS_LTO", so if we send this patch upstream, a proper patch for enabling ARM32 LTO should be included in the pull request, too. |
Will be deployed to 500+ of these devices soon, as it passed preliminary testing. |
Exciting! Any measurements you can share? That would help us when sending a patch upstream.
Perhaps that's a better question for #armlinux on Libera chat IRC. |
@MaskRay any idea if it's intentional that LTO promotes bss symbols from STB_LOCAL to global STB_GLOBAL? |
I haven't looked into the case in the PR, but in general: ThinLTO may change symbols from STB_LOCAL to STB_GLOBAL. If a function accessing a local variable is imported to another compile unit, the only way for the two compile units to see the same copy is to promote the variable to a global variable, then let the linker resolves references to the same copy. See 4.1 Promotion of Symbols with Local Linkage in ThinLTO: Scalable and Incremental LTO. T. Johnson, M. Amini and X. David Li, "ThinLTO: Scalable and incremental LTO," 2017 IEEE/ACM International Symposium on Code Generation and Optimization (CGO), 2017, pp. 111-121, doi: 10.1109/CGO.2017.7863733. A simplest example: static int var;
int foo(void) { return ++var; } If |
Thanks! Right, I'm guessing it promotes+renames to avoid any kind of collision at the global level. Edit, yep the paper says exactly that.
I think that's satisfactory to include in a commit message. |
For what it's worth, that issue is also reproducible with full LTO but I will still try to draft up a series for it, once I can verify there are no problems on real hardware and run it through a few other configurations. |
I also see a spew of warnings:
|
Also, the issue is that global symbols are being changed to local symbols, not the other way around, if I am understanding the check and the commit message of both 5de813b and 8d7e4cc. Is that still expected with LTO? I guess that is expected if the global symbol is not referred to outside of its one translation unit? |
re
I wonder if the arch version isn't being set correctly for LTO, or if explicit Probably a similar issue for Though 8d7e4cc makes me wonder why they're using |
Hello,
My company has a relatively old AT91-based embedded product, and it only has 4 megabytes of flash to boot the kernel from, so I started experimenting with LTO for size reduction and possible performance improvement.
I have ran into an issue - see the attached screenshot.
I suspect the linker incorrectly identifies these symbols in the kernel de-compressor routine as unused, and strips them out.
These are declared at:
https://elixir.bootlin.com/linux/v5.18-rc4/source/arch/arm/boot/compressed/misc.c
What I have tried already:
Setting KBUILD flags in corresponding Makefiles to disable LTO.
Setting the "used" compiler attribute on these specific variables/symbols.
I am honestly at a loss, please help me out on this one.
I am facing this issue on all kernels with existing LTO support.
Making a non-compressed target like "Image" instead of the default zImage works, although it is obviously way bigger.
Steps to reproduce it:
make at91_dt_defconfig - (I use a similar config for this custom board)
make -j $(nproc)
.
The text was updated successfully, but these errors were encountered: