kbuild changes, thin archives, --gc-sections
Subsystems (4)
v3 cover kbuild changes, thin archives, --gc-sections
Hi Michal,
I ended up deciding to do a v3, because I had several changes accumulated, as described in patches.
I've also left off the powerpc arch patches -- they can be found in previous posts, for reference.
I've again tested ARM and it seems to be building okay and without performance regression with my configurations. I think it's going to be a matter of some toolchain options for them to go through. arm64, x86, powerpc, and arm for me all built fine with thin archives and --gc-sections enabled, so I can't see there being a fundamental issue that can't be solved. Worst case, the incremental link option can remain for a time.
Thanks,
Nick
Nicholas Piggin (2):
kbuild: allow archs to select link dead code/data elimination
kbuild: add arch specific post-link Makefile
Stephen Rothwell (1):
kbuild: allow architectures to use thin archives instead of ld -r
Documentation/kbuild/makefiles.txt | 16 +++++++++ Makefile | 19 ++++++++-- arch/Kconfig | 26 ++++++++++++++ include/asm-generic/vmlinux.lds.h | 52 ++++++++++++++++------------ include/linux/compiler.h | 23 ++++++++++++ include/linux/export.h | 30 ++++++++-------- include/linux/init.h | 38 +++++++------------- init/Makefile | 2 ++ scripts/Makefile.build | 23 +++++++++--- scripts/Makefile.modpost | 14 +++++--- scripts/link-vmlinux.sh | 71 ++++++++++++++++++++++++++++++++------ 11 files changed, 228 insertions(+), 86 deletions(-)
Signature · 1 line
2.8.1
PATCH v3 1/3 kbuild: allow architectures to use thin archives instead of ld -r
From: Stephen Rothwell <[email protected]>
ld -r is an incremental link used to create built-in.o files in build subdirectories. It produces relocatable object files containing all its input files, and these are are then pulled together and relocated in the final link. Aside from the bloat, this constrains the final link relocations, which has bitten large powerpc builds with unresolvable relocations in the final link.
Alan Modra has recommended the kernel use thin archives for linking. This is an alternative and means that the linker has more information available to it when it links the kernel.
This patch enables a config option architectures can select, which causes all built-in.o files to be built as thin archives. built-in.o files in subdirectories do not get symbol table or index attached, which improves speed and size. The final link pass creates a built-in.o archive in the root output directory which includes the symbol table and index. The linker then uses takes this file to link.
The --whole-archive linker option is required, because the linker now has visibility to every individual object file, and it will otherwise just completely avoid including those without external references (consider a file with EXPORT_SYMBOL or initcall or hardware exceptions as its only entry points). The traditional built works "by luck" as built-in.o files are large enough that they're going to get external references. However this optimisation is unpredictable for the kernel (due to above external references), ineffective at culling unused, and costly because the .o files have to be searched for references. Superior alternatives for link-time culling should be used instead.
Build characteristics for inclink vs thinarc, on a small powerpc64le pseries VM with a modest .config:
inclink thinarc
sizes
vmlinux 15 618 680 15 625 028
sum of all built-in.o 56 091 808 1 054 334
sum excluding root built-in.o 151 430
find -name built-in.o | xargs rm ; time make vmlinux
real 22.772s 21.143s user 13.280s 13.430s
sys 4.310s 2.750s
- Final kernel pulled in only about 6K more, which shows how ineffective the object file culling is.
- Build performance looks improved due to less pagecache activity. On IO constrained systems it could be a bigger win.
- Build size saving is significant.
Side note, the toochain understands archives, so there's some tricks,
$ ar t built-in.o # list all files you linked with $ size built-in.o # and their sizes $ objdump -d built-in.o # disassembly (unrelocated) with filenames
Implementation by sfr, minor tweaks by npiggin.
---
Changes since v1
- Fixed um build breakage
- Fixed linking against lib.a archives (add symbol table)
- Tested x86 builds
- Tested arm64 defconfig thin archives cross compile inclinc - 385s 2.7GB; thinarc - 377s 1.8G
Changes since v2
- Add symbol index for lib.a archives, same as incremental link build
arch/Kconfig | 6 +++++ scripts/Makefile.build | 23 +++++++++++++--- scripts/link-vmlinux.sh | 71 +++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 85 insertions(+), 15 deletions(-)
arch/Kconfig +6 -0
@@ -424,6 +424,12 @@ config CC_STACKPROTECTOR_STRONG endchoice +config THIN_ARCHIVES + bool + help + Select this if the architecture wants to use thin archives + instead of ld -r to create the built-in.o files. + config HAVE_CONTEXT_TRACKING bool help
scripts/Makefile.build +19 -4
@@ -358,12 +358,22 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; # Rule to compile a set of .o files into one .o file # ifdef builtin-target -quiet_cmd_link_o_target = LD $@ + +ifdef CONFIG_THIN_ARCHIVES + cmd_make_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS) + cmd_make_empty_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS) + quiet_cmd_link_o_target = AR $@ +else + cmd_make_builtin = $(LD) $(ld_flags) -r -o + cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) + quiet_cmd_link_o_target = LD $@ +endif + # If the list of objects to link is empty, just create an empty built-in.o cmd_link_o_target = $(if $(strip $(obj-y)),\ - $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ + $(cmd_make_builtin) $@ $(filter $(obj-y), $^) \ $(cmd_secanalysis),\ - rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) + $(cmd_make_empty_builtin) $@) $(builtin-target): $(obj-y) FORCE $(call if_changed,link_o_target)
@@ -389,7 +399,12 @@ $(modorder-target): $(subdir-ym) FORCE # ifdef lib-target quiet_cmd_link_l_target = AR $@ -cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) + +ifdef CONFIG_THIN_ARCHIVES + cmd_link_l_target = rm -f $@; $(AR) rcsT$(KBUILD_ARFLAGS) $@ $(lib-y) +else + cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) +endif $(lib-target): $(lib-y) FORCE $(call if_changed,link_l_target)
scripts/link-vmlinux.sh +60 -11
102 lines not on this page · raw message
Signature · 1 line
2.8.1
PATCH v3 2/3 kbuild: allow archs to select link dead code/data elimination
In reply to Nicholas PigginIntroduce LD_DEAD_CODE_DATA_ELIMINATION option for architectures to select to build with -ffunction-sections, -fdata-sections, and link with --gc-sections. It requires some work (documented) to ensure all unreferenced entrypoints are live, and requires toolchain and build verification, so it is made a per-arch option for now.
On a random powerpc64le build, this yelds a significant size saving, it boots and runs fine, but there is a lot I haven't tested as yet, so these savings may be reduced if there are bugs in the link.
text data bss dec filename
11169741 1180744 1923176 14273661 vmlinux 10445269 1004127 1919707 13369103 vmlinux.dce
~700K text, ~170K data, 6% removed from kernel image size.
---
Since v1
- More descriptive config option name
- Improve some comments
- Tested x86 builds, boot in KVM
Since v2
- Kill unnecessary changes to remove CONFIG_LTO remnants in arch/x86
Makefile | 9 +++++++ arch/Kconfig | 13 ++++++++++ include/asm-generic/vmlinux.lds.h | 52 ++++++++++++++++++++++----------------- include/linux/compiler.h | 23 +++++++++++++++++ include/linux/export.h | 30 +++++++++++----------- include/linux/init.h | 38 ++++++++++------------------ init/Makefile | 2 ++ 7 files changed, 104 insertions(+), 63 deletions(-)
Makefile +9 -0
@@ -618,6 +618,11 @@ include arch/$(SRCARCH)/Makefile KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION +KBUILD_CFLAGS += $(call cc-option,-ffunction-sections,) +KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) +endif + ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) else
@@ -819,6 +824,10 @@ LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) +ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION +LDFLAGS_vmlinux += $(call ld-option, --gc-sections,) +endif + ifeq ($(CONFIG_STRIP_ASM_SYMS),y) LDFLAGS_vmlinux += $(call ld-option, -X,) endif
arch/Kconfig +13 -0
@@ -430,6 +430,19 @@ config THIN_ARCHIVES Select this if the architecture wants to use thin archives instead of ld -r to create the built-in.o files. +config LD_DEAD_CODE_DATA_ELIMINATION + bool + help + Select this if the architecture wants to do dead code and + data elimination with the linker by compiling with + -ffunction-sections -fdata-sections and linking with + --gc-sections. + + This requires that the arch annotates or otherwise protects + its external entry points from being discarded. Linker scripts + must also merge .text.*, .data.*, and .bss.* correctly into + output sections. + config HAVE_CONTEXT_TRACKING bool help
include/asm-generic/vmlinux.lds.h +29 -23
174 lines not on this page · raw message
include/linux/compiler.h +23 -0
@@ -184,6 +184,29 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);# define unreachable () do { } while (1)#endif +/* +* KENTRY - kernel entry point +* This can be used to annotate symbols (functions or data) that are used +* without their linker symbol being referenced explicitly. For example, +* interrupt vector handlers, or functions in the kernel image that are found +* programatically. +* +* Not required for symbols exported with EXPORT_SYMBOL, or initcalls. Those +* are handled in their own way (with KEEP() in linker scripts). +* +* KENTRY can be avoided if the symbols in question are marked as KEEP() in the +* linker script. For example an architecture could KEEP() its entire +* boot/exception vector code rather than annotate each function and data. +*/ +#ifndef KENTRY +# define KENTRY (sym) \ + extern typeof(sym) sym; \ + static const unsigned long __kentry_##sym \ + __used \ + __attribute__((section("___kentry" "+" #sym ), used)) \ + = (unsigned long)&sym; +#endif +#ifndef RELOC_HIDE # define RELOC_HIDE (ptr, off) \ ({ unsigned long __ptr; \
include/linux/export.h +15 -15
@@ -1,5 +1,6 @@#ifndef _LINUX_EXPORT_H#define _LINUX_EXPORT_H +/* * Export symbols from the kernel to modules. Forked from module.h * to reduce the amount of pointless cruft we feed to gcc when only
@@ -42,27 +43,26 @@ extern struct module __this_module;#ifdef CONFIG_MODVERSIONS /* Mark the CRC weak since genksyms apparently decides not to * generate a checksums for some symbols */ -#define __CRC_SYMBOL (sym, sec) \ - extern __visible void *__crc_##sym __attribute__((weak)); \ - static const unsigned long __kcrctab_##sym \ - __used \ - __attribute__((section("___kcrctab" sec "+" #sym), unused)) \ +#define __CRC_SYMBOL (sym, sec) \ + extern __visible void *__crc_##sym __attribute__((weak)); \ + static const unsigned long __kcrctab_##sym \ + __used \ + __attribute__((section("___kcrctab" sec "+" #sym), used)) \ = (unsigned long) &__crc_##sym;#else #define __CRC_SYMBOL (sym, sec)#endif /* For every exported symbol, place a struct in the __ksymtab section */ -#define ___EXPORT_SYMBOL (sym, sec) \ - extern typeof(sym) sym; \ - __CRC_SYMBOL(sym, sec) \ - static const char __kstrtab_##sym[] \ - __attribute__((section("__ksymtab_strings"), aligned(1))) \ - = VMLINUX_SYMBOL_STR(sym); \ - extern const struct kernel_symbol __ksymtab_##sym; \ - __visible const struct kernel_symbol __ksymtab_##sym \ - __used \ - __attribute__((section("___ksymtab" sec "+" #sym), unused)) \ +#define ___EXPORT_SYMBOL (sym, sec) \ + extern typeof(sym) sym; \ + __CRC_SYMBOL(sym, sec) \ + static const char __kstrtab_##sym[] \ + __attribute__((section("__ksymtab_strings"), aligned(1))) \ + = VMLINUX_SYMBOL_STR(sym); \ + static const struct kernel_symbol __ksymtab_##sym \ + __used \ + __attribute__((section("___ksymtab" sec "+" #sym), used)) \ = { (unsigned long)&sym, __kstrtab_##sym }#if defined(__KSYM_DEPS__)
include/linux/init.h +13 -25
@@ -156,24 +156,8 @@ extern bool initcall_debug;#ifndef __ASSEMBLY__ -#ifdef CONFIG_LTO -/* Work around a LTO gcc problem: when there is no reference to a variable -* in a module it will be moved to the end of the program. This causes -* reordering of initcalls which the kernel does not like. -* Add a dummy reference function to avoid this. The function is -* deleted by the linker. -*/ -#define LTO_REFERENCE_INITCALL(x) \ - ; /* yes this is needed */ \ - static __used __exit void *reference_##x(void) \ - { \ - return &x; \ - } -#else -#define LTO_REFERENCE_INITCALL (x) -#endif - -/* initcalls are now grouped by functionality into separate +/* +* initcalls are now grouped by functionality into separate * subsections. Ordering inside the subsections is determined * by link order. * For backwards compatibility, initcall() puts the call in
@@ -181,12 +165,16 @@ extern bool initcall_debug;* * The `id' arg to __define_initcall() is needed so that multiple initcalls * can point at the same handler without causing duplicate-symbol build errors. +* +* Initcalls are run by placing pointers in initcall sections that the +* kernel iterates at runtime. The linker can do dead code / data elimination +* and remove that completely, so the initcall sections have to be marked +* as KEEP() in the linker script. */ #define __define_initcall (fn, id) \ static initcall_t __initcall_##fn##id __used \ - __attribute__((__section__(".initcall" #id ".init"))) = fn; \ - LTO_REFERENCE_INITCALL(__initcall_##fn##id) + __attribute__((__section__(".initcall" #id ".init"))) = fn;/* * Early initcalls run before initializing SMP.
@@ -222,15 +210,15 @@ extern bool initcall_debug;#define __initcall (fn) device_initcall(fn) -#define __exitcall (fn) \ +#define __exitcall (fn) \ static exitcall_t __exitcall_##fn __exit_call = fn -#define console_initcall (fn) \ - static initcall_t __initcall_##fn \ +#define console_initcall (fn) \ + static initcall_t __initcall_##fn \ __used __section(.con_initcall.init) = fn -#define security_initcall (fn) \ - static initcall_t __initcall_##fn \ +#define security_initcall (fn) \ + static initcall_t __initcall_##fn \ __used __section(.security_initcall.init) = fnstruct obs_kernel_param {
init/Makefile +2 -0
@@ -2,6 +2,8 @@ # Makefile for the linux kernel. # +ccflags-y := -fno-function-sections -fno-data-sections + obj-y := main.o version.o mounts.o ifneq ($(CONFIG_BLK_DEV_INITRD),y) obj-y += noinitramfs.o
Signature · 1 line
2.8.1
PATCH v3 3/3 kbuild: add arch specific post-link Makefile
In reply to Nicholas PigginAllow architectures to create arch/xxx/Makefile.postlink with targets for vmlinux, modules.ko, and clean, which will be invoked after final linking of vmlinux and modules.
powerpc will use this to check vmlinux linker relocations for sanity, and may use it to fix up alternate instruction patch branch addresses.
---
Since v1,
- Switched to a more flexible arch makefile invocation.
- Provide a powerpc patch to use it to help existing build issue (rather than only justification being out-of-tree patch).
Since v2
- Depend on existence of Makefile.modpost, rather than config option.
- Add a clean target
- Move post-vmlinux invocation into Makefile rather than link-vmlinux.sh
- Arch postlink must always be done after final link, not on an if_changed basis, because the vmlinux itself is not a dependency.
Documentation/kbuild/makefiles.txt | 16 ++++++++++++++++ Makefile | 10 +++++++--- arch/Kconfig | 7 +++++++ scripts/Makefile.modpost | 14 +++++++++----- 4 files changed, 39 insertions(+), 8 deletions(-)
Documentation/kbuild/makefiles.txt +16 -0
@@ -41,6 +41,7 @@ This document describes the Linux kernel Makefiles. --- 6.8 Custom kbuild commands --- 6.9 Preprocessing linker scripts --- 6.10 Generic header files + --- 6.11 Post-link pass === 7 Kbuild syntax for exported headers --- 7.1 header-y
@@ -1236,6 +1237,21 @@ When kbuild executes, the following steps are followed (roughly): to list the file in the Kbuild file. See "7.4 generic-y" for further info on syntax etc. +--- 6.11 Post-link pass + + If the file arch/xxx/Makefile.postlink exists, this makefile + will be invoked for post-link objects (vmlinux and modules.ko) + for architectures to run post-link passes on. Must also handle + the clean target. + + This pass runs after kallsyms generation. If the architecture + needs to modify symbol locations, rather than manipulate the + kallsyms, it may be easier to add another postlink target for + .tmp_vmlinux? targets to be called from link-vmlinux.sh. + + For example, powerpc uses this to check relocation sanity of + the linked vmlinux file. + === 7 Kbuild syntax for exported headers The kernel includes a set of headers that is exported to userspace.
Makefile +7 -3
@@ -967,9 +967,12 @@ endif include/generated/autoksyms.h: FORCE $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh true -# Final link of vmlinux - cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -quiet_cmd_link-vmlinux = LINK $@ +ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) + +# Final link of vmlinux with optional arch pass after final link + cmd_link-vmlinux = \ + $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ + $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE +$(call if_changed,link-vmlinux)
@@ -1268,6 +1271,7 @@ $(clean-dirs): vmlinuxclean: $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean + $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) clean: archclean vmlinuxclean
arch/Kconfig +7 -0
@@ -424,6 +424,13 @@ config CC_STACKPROTECTOR_STRONG endchoice +config BUILD_ARCH_POSTLINK + bool + help + Select this if the architecture wants to have a Makefile invoked + on modules and vmlinux after they are linked. The architecture + must provide arch/?/Makefile.postlink + config THIN_ARCHIVES bool help
scripts/Makefile.modpost +9 -5
@@ -115,14 +115,18 @@ $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE targets += $(modules:.ko=.mod.o) -# Step 6), final link of the modules +ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) + +# Step 6), final link of the modules with optional arch pass after final link quiet_cmd_ld_ko_o = LD [M] $@ - cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ - $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ - -o $@ $(filter-out FORCE,$^) + cmd_ld_ko_o = \ + $(LD) -r $(LDFLAGS) \ + $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ + -o $@ $(filter-out FORCE,$^) ; \ + $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) $(modules): %.ko :%.o %.mod.o FORCE - $(call if_changed,ld_ko_o) + +$(call if_changed,ld_ko_o) targets += $(modules)
Signature · 1 line
2.8.1
Re: [PATCH 3/3] kbuild: add arch specific post-link Makefile
Quoted 18 lines · On Wed, 24 Aug 2016 22:29:21 +1000 Nicholas Piggin <[email protected]> wrote:
Allow architectures to create
arch/xxx/Makefile.postlinkwith targets for vmlinux, modules.ko, and clean, which will be invoked after final linking of vmlinux and modules.powerpc will use this to check vmlinux linker relocations for sanity, and may use it to fix up alternate instruction patch branch addresses.
Signed-off-by Nicholas Piggin <[email protected]>arch/Kconfig +0
-0@@ -424,6 +424,13 @@ config CC_STACKPROTECTOR_STRONG endchoice
arch/Kconfig config CC_STACKPROTECTOR_STRONG · line 436
Quoted 10 lines
arch/Kconfig +7
-0+config BUILD_ARCH_POSTLINK + bool + help + Select this if the architecture wants to have a Makefile invoked + on modules and vmlinux after they are linked. The architecture + must provide arch/?/Makefile.postlink + config THIN_ARCHIVES bool help
Argh! Sorry, this thing crept back in again. No other reference to BUILD_ARCH_POSTLINK in the patch, so it won't invalidate testing to just remove the hunk.
Thanks,
Nick
Quoted 8 lines · CEST Nicholas Piggin
Hi Michal,
I ended up deciding to do a v3, because I had several changes accumulated, as described in patches.
I've also left off the powerpc arch patches -- they can be found in previous posts, for reference.
Quoted 8 lines
I've again tested ARM and it seems to be building okay and without performance regression with my configurations. I think it's going to be a matter of some toolchain options for them to go through. arm64, x86, powerpc, and arm for me all built fine with thin archives and --gc-sections enabled, so I can't see there being a fundamental issue that can't be solved. Worst case, the incremental link option can remain for a time.
I clearly want to use this on ARM, and I am still investigating the performance regression that I see on my build box, but that is no reason to delay your patches.
Everything looks good to me,
Nicolas Pitre
Acked-byQuoted 18 lines · Arnd Bergmann
Quoted 8 lines · CEST Nicholas Piggin
Hi Michal,
I ended up deciding to do a v3, because I had several changes accumulated, as described in patches.
I've also left off the powerpc arch patches -- they can be found in previous posts, for reference.
Quoted 8 lines
I've again tested ARM and it seems to be building okay and without performance regression with my configurations. I think it's going to be a matter of some toolchain options for them to go through. arm64, x86, powerpc, and arm for me all built fine with thin archives and --gc-sections enabled, so I can't see there being a fundamental issue that can't be solved. Worst case, the incremental link option can remain for a time.
Quoted 7 lines
I clearly want to use this on ARM, and I am still investigating the performance regression that I see on my build box, but that is no reason to delay your patches.
Everything looks good to me,
Acked-by Arnd Bergmann <[email protected]>
Ditto here.
Nicolas
Out of interest, does using LTO also fix the problem?
David
Quoted 1 line · David Howells
Out of interest, does using LTO also fix the problem?
With those patches in place, that would be the next thing to try. Reducing our reliance on 'ld -r' will greatly help promoting LTO for the kernel.
Personally I'd like to have the choice between LTO and -gc-sections at configure time. They both have advantages of their own.
Nicolas
Quoted 10 lines · On Wed, 24 Aug 2016 11:21:33 -0400 (EDT) Nicolas Pitre…
Quoted 1 line · David Howells
Out of interest, does using LTO also fix the problem?
With those patches in place, that would be the next thing to try. Reducing our reliance on 'ld -r' will greatly help promoting LTO for the kernel.
Personally I'd like to have the choice between LTO and -gc-sections at configure time. They both have advantages of their own.
We discussed this in previous rounds of patches, but to just expand on Nicolas' answer with some overview:
- Thin archives are needed for linking large kernels of some ISAs. I believe the linker becomes constrained in where it can use branch stubs when linking large inputs, but haven't looked into the internals exactly. There are a number of other ways proposed to solve it, but archives are well understood by toolchain and look like quite an elegant solution (with other benefits such as build output size and helping to enable LTO).
- gc-sections patch is mainly to address some small regressions in binary size with the first patch, but I think the results make it stand on its own. It's very fast, mature, does not transform code, and gives surprisingly good size saving without much enablement work. The work that is required (e.g., to annotate entry points) is mostly shared with LTO if we add that in future, so it's not dead-end cruft.
- LTO: Nicolas has posted far more significant size improvements with his more advanced work with reference annotatation and LTO. I'm surprised there has not been more interest, but I hope if we get this merged, it might give him motivation to look at it again. Discussion seemed to die down last time with people saying we should look at gc-sections first.
I see this as enabler to LTO rather than a replacement. LTO is bigger change to build and less mature, but long term it is the right way to go IMO. When we iron out toolchains, perhaps have LTO option for just static elimination rather than transformations for high speed / low optimization builds, etc., then gc-sections would be completely supplanted could be removed. Using sections for dce is a nice linker hack, but real LTO information seems cleaner in the end (and of course allows more optimization).
Thanks,
Nick
Quoted 4 lines · Nicholas Piggin
Hi Michal,
I ended up deciding to do a v3, because I had several changes accumulated, as described in patches.
What is the prospect of those patches going upstream?
I ask because I didn't see them in the kbuild repo yet, nor in next for that matter.
Nicolas
Dne 9.9.2016 v 02:23 Nicolas Pitre napsal(a):
Quoted 11 lines · Nicholas Piggin
Quoted 5 lines
Hi Michal,
I ended up deciding to do a v3, because I had several changes accumulated, as described in patches.
What is the prospect of those patches going upstream?
I ask because I didn't see them in the kbuild repo yet, nor in next for that matter.
I merged the patches into the kbuild.git repository now.
Michal
Quoted 8 lines · Michal Marek
Dne 9.9.2016 v 02:23 Nicolas Pitre napsal(a):
Quoted 7 lines · Nicholas Piggin
Quoted 5 lines
Hi Michal,
I ended up deciding to do a v3, because I had several changes accumulated, as described in patches.
Quoted 6 lines
Quoted 4 lines
What is the prospect of those patches going upstream?
I ask because I didn't see them in the kbuild repo yet, nor in next for that matter.
I merged the patches into the kbuild.git repository now.
Excellent, thanks.
Nicolas