Hi Nicholas,
(+CC: Sam Ravnborg)
On Sat, May 23, 2020 at 7:06 PM Nicholas Piggin [off-list ref] wrote:
Excerpts from Masahiro Yamada's message of May 23, 2020 3:44 am:
quoted
+ Michael, and PPC ML.
They may know something about the reason of failure.
Because the linker can't put branch stubs within object code sections,
so when you incrementally link them too large, the linker can't resolve
branches into other object files.
Ah, you are right.
So, this is a problem not only for PPC
but also for ARM (both 32 and 64 bit), etc.
ARM needs to insert a veneer to jump far.
Prior to thin archive, we could not compile
ARCH=arm allyesconfig because
drivers/built-in.o was too large.
This patch gets us back to the too large
incremental object situation.
With my quick compile-testing,
ARCH=arm allyesconfig
and ARCH=arm64 allyesconfig are broken.
This is why we added incremental linking in the first place. I suppose
it could be made conditional for platforms that can use this
optimization.
What'd be really nice is if we could somehow build and link kallsyms
without relinking everything twice, and if we could do section mismatch
analysis without making that vmlinux.o as well. I had a few ideas but
not enough time to do much work on it.
Right, kallsyms links 3 times. (not twice)
Hmm, I think Sami's main motivation is Clang LTO.
LTO is very time-consuming.
So, the android common kernel implements Clang LTO
in the pre modpost stage:
1) LTO against vmlinux.o
2) modpost against vmlinux.o
3) Link vmlinux.o + kallsyms into vmlinux
(this requires linking 3 times)
If we move LTO to 3), we need to do LTO 3 times.
And, this was how GCC LTO was implemented in 2014,
(then rejected by Linus).
How to do modpost without making vmlinux.o ?
In old days, the section mismatch analysis was done
against the final vmlinux.
85bd2fddd68e757da8e1af98f857f61a3c9ce647 changed
it to run modpost for individual .o files.
Then, 741f98fe298a73c9d47ed53703c1279a29718581
introduced vmlinux.o to use it for modpost.
59 more lines
Thanks,
Nick
quoted
On Sat, May 23, 2020 at 2:41 AM Masahiro Yamada [off-list ref] wrote:
quoted
On Fri, May 22, 2020 at 5:27 AM Sami Tolvanen [off-list ref] wrote:
quoted
Instead of linking all compilation units again each time vmlinux_link is
called, reuse vmlinux.o from modpost_link.
With x86_64 allyesconfig, vmlinux_link is called three times and reusing
vmlinux.o reduces the build time ~38 seconds on my system (59% reduction
in the time spent in vmlinux_link).
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
scripts/link-vmlinux.sh | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index d09ab4afbda4..c6cc4305950c 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -77,11 +77,8 @@ vmlinux_link()
if [ "${SRCARCH}" != "um" ]; then
objects="--whole-archive \
- ${KBUILD_VMLINUX_OBJS} \
+ vmlinux.o \
--no-whole-archive \
- --start-group \
- ${KBUILD_VMLINUX_LIBS} \
- --end-group \
${@}"
${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \
58 more quoted lines
--
Best Regards
Masahiro Yamada