* Is LTO_REFERENCE_INITCALL() still needed? @ 2016-06-23 23:34 Luis R. Rodriguez 2016-06-24 21:07 ` Andi Kleen 0 siblings, 1 reply; 8+ messages in thread From: Luis R. Rodriguez @ 2016-06-23 23:34 UTC (permalink / raw) To: Andi Kleen Cc: H. Peter Anvin, linux-kernel@vger.kernel.org, X86 ML, Borislav Petkov, Andy Lutomirski Andi, is LTO_REFERENCE_INITCAL() still needed? I see external stuff like this: https://github.com/neo-technologies/linux-next/blob/master/scripts/Makefile.lto But nothing quite obviously setting these upstream. I'm probably just missing something obvious though. Either way I figured now would be a good time to ask as I have other code that would use this, the linker table stuff I've been working. If we can avoid propagating more use of LTO_REFERENCE_INITCALL() then great. If we still need it its probably good to document this a bit more as can't see anything super clear. Luis ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is LTO_REFERENCE_INITCALL() still needed? 2016-06-23 23:34 Is LTO_REFERENCE_INITCALL() still needed? Luis R. Rodriguez @ 2016-06-24 21:07 ` Andi Kleen 2016-06-28 0:47 ` Luis R. Rodriguez 0 siblings, 1 reply; 8+ messages in thread From: Andi Kleen @ 2016-06-24 21:07 UTC (permalink / raw) To: Luis R. Rodriguez Cc: Andi Kleen, H. Peter Anvin, linux-kernel@vger.kernel.org, X86 ML, Borislav Petkov, Andy Lutomirski > But nothing quite obviously setting these upstream. I'm probably just > missing something obvious though. Either way I figured now would be a > good time to ask as I have other code that would use this, the linker > table stuff I've been working. If we can avoid propagating more use of > LTO_REFERENCE_INITCALL() then great. If we still need it its probably > good to document this a bit more as can't see anything super clear. It was a work around for a gcc 4.7 LTO problem. I guess it could be dropped by now. Yes I've been slow in submitting the LTO patches, even though they have a quite active out of tree user base. Will try to do better. -Andi ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is LTO_REFERENCE_INITCALL() still needed? 2016-06-24 21:07 ` Andi Kleen @ 2016-06-28 0:47 ` Luis R. Rodriguez 2016-07-07 0:22 ` [PATCH] x86: remove LTO flags Luis R. Rodriguez 0 siblings, 1 reply; 8+ messages in thread From: Luis R. Rodriguez @ 2016-06-28 0:47 UTC (permalink / raw) To: Andi Kleen Cc: Luis R. Rodriguez, H. Peter Anvin, linux-kernel@vger.kernel.org, X86 ML, Borislav Petkov, Andy Lutomirski On Fri, Jun 24, 2016 at 02:07:53PM -0700, Andi Kleen wrote: > > But nothing quite obviously setting these upstream. I'm probably just > > missing something obvious though. Either way I figured now would be a > > good time to ask as I have other code that would use this, the linker > > table stuff I've been working. If we can avoid propagating more use of > > LTO_REFERENCE_INITCALL() then great. If we still need it its probably > > good to document this a bit more as can't see anything super clear. > > It was a work around for a gcc 4.7 LTO problem. I guess it could be > dropped by now. > > Yes I've been slow in submitting the LTO patches, even though they > have a quite active out of tree user base. Will try to do better. Would something like this make sense then? Tested by 0-day. >From 682579b548ccf5d33349f32fcbe0922f5c29f04d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" <mcgrof@kernel.org> Date: Mon, 27 Jun 2016 14:25:14 -0700 Subject: [PATCH] x86: remove LTO flags The setup for LTO never made it upstream, and although this has some users, this is now really old stuff for a gcc 4.7 LTO problem. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- arch/x86/entry/vdso/Makefile | 6 ++---- include/linux/init.h | 20 +------------------- kernel/Makefile | 3 --- scripts/Makefile.build | 2 +- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 3288dfa63706..d0f1cd210892 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -2,7 +2,6 @@ # Building vDSO images for x86. # -KBUILD_CFLAGS += $(DISABLE_LTO) KASAN_SANITIZE := n UBSAN_SANITIZE := n OBJECT_FILES_NON_STANDARD := y @@ -49,8 +48,7 @@ export CPPFLAGS_vdso.lds += -P -C VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ -Wl,--no-undefined \ - -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \ - $(DISABLE_LTO) + -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE $(call if_changed,vdso) @@ -171,7 +169,7 @@ quiet_cmd_vdso = VDSO $@ sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ - $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) + $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic GCOV_PROFILE := n # diff --git a/include/linux/init.h b/include/linux/init.h index 88646cb136e0..0370efacc839 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -157,23 +157,6 @@ 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 * subsections. Ordering inside the subsections is determined * by link order. @@ -186,8 +169,7 @@ extern bool initcall_debug; #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. diff --git a/kernel/Makefile b/kernel/Makefile index e2ec54e2b952..f80ce824bb4f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -29,9 +29,6 @@ KCOV_INSTRUMENT_extable.o := n KCOV_INSTRUMENT_kcov.o := n KASAN_SANITIZE_kcov.o := n -# cond_syscall is currently not LTO compatible -CFLAGS_sys_ni.o = $(DISABLE_LTO) - obj-y += sched/ obj-y += locking/ obj-y += power/ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 11602e5efb3b..a5dd16ffb06e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -147,7 +147,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi) $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c) -- 2.8.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] x86: remove LTO flags 2016-06-28 0:47 ` Luis R. Rodriguez @ 2016-07-07 0:22 ` Luis R. Rodriguez 2016-07-07 1:55 ` Andi Kleen 0 siblings, 1 reply; 8+ messages in thread From: Luis R. Rodriguez @ 2016-07-07 0:22 UTC (permalink / raw) To: andi; +Cc: hpa, linux-kernel, x86, bp, luto, Luis R. Rodriguez The setup for LTO never made it upstream, and although this has some users, this is now really old stuff for a gcc 4.7 LTO problem. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- arch/x86/entry/vdso/Makefile | 6 ++---- include/linux/init.h | 20 +------------------- kernel/Makefile | 3 --- scripts/Makefile.build | 2 +- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 3288dfa63706..d0f1cd210892 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -2,7 +2,6 @@ # Building vDSO images for x86. # -KBUILD_CFLAGS += $(DISABLE_LTO) KASAN_SANITIZE := n UBSAN_SANITIZE := n OBJECT_FILES_NON_STANDARD := y @@ -49,8 +48,7 @@ export CPPFLAGS_vdso.lds += -P -C VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ -Wl,--no-undefined \ - -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 \ - $(DISABLE_LTO) + -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 $(obj)/vdso64.so.dbg: $(src)/vdso.lds $(vobjs) FORCE $(call if_changed,vdso) @@ -171,7 +169,7 @@ quiet_cmd_vdso = VDSO $@ sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@' VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ - $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) + $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic GCOV_PROFILE := n # diff --git a/include/linux/init.h b/include/linux/init.h index 88646cb136e0..0370efacc839 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -157,23 +157,6 @@ 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 * subsections. Ordering inside the subsections is determined * by link order. @@ -186,8 +169,7 @@ extern bool initcall_debug; #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. diff --git a/kernel/Makefile b/kernel/Makefile index e2ec54e2b952..f80ce824bb4f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -29,9 +29,6 @@ KCOV_INSTRUMENT_extable.o := n KCOV_INSTRUMENT_kcov.o := n KASAN_SANITIZE_kcov.o := n -# cond_syscall is currently not LTO compatible -CFLAGS_sys_ni.o = $(DISABLE_LTO) - obj-y += sched/ obj-y += locking/ obj-y += power/ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 11602e5efb3b..a5dd16ffb06e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -147,7 +147,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi) $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< +cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c) -- 2.8.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] x86: remove LTO flags 2016-07-07 0:22 ` [PATCH] x86: remove LTO flags Luis R. Rodriguez @ 2016-07-07 1:55 ` Andi Kleen 2016-07-07 16:01 ` [PATCH v2] x86: remove LTO_REFERENCE_INITCALL() Luis R. Rodriguez 0 siblings, 1 reply; 8+ messages in thread From: Andi Kleen @ 2016-07-07 1:55 UTC (permalink / raw) To: Luis R. Rodriguez; +Cc: andi, hpa, linux-kernel, x86, bp, luto On Wed, Jul 06, 2016 at 05:22:50PM -0700, Luis R. Rodriguez wrote: > The setup for LTO never made it upstream, and although this has > some users, this is now really old stuff for a gcc 4.7 LTO problem. Sorry, the LTO flags are still needed. Please don't remove The 4.7 only workaround was only the LTO_REFERENCE_INITCALL macro, which can be removed (if LTO is not support 4.7 anymore) -Andi ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] x86: remove LTO_REFERENCE_INITCALL() 2016-07-07 1:55 ` Andi Kleen @ 2016-07-07 16:01 ` Luis R. Rodriguez 2016-07-07 16:32 ` Andi Kleen 0 siblings, 1 reply; 8+ messages in thread From: Luis R. Rodriguez @ 2016-07-07 16:01 UTC (permalink / raw) To: andi; +Cc: hpa, linux-kernel, x86, bp, luto, Luis R. Rodriguez The setup for LTO never made it upstream, and although this has some users, this is now really old stuff for a gcc 4.7 LTO problem. We know that at least LTO_REFERENCE_INITCALL() work around can be removed if LTO is not supported on v4.7 anymore. As per Andi the DISABLE_LTO and LTO_CFLAGS are still neeeded though. Tested-by: 0-day Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> --- include/linux/init.h | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/include/linux/init.h b/include/linux/init.h index 1e5c131d5c9a..aa662ad80d9c 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -151,23 +151,6 @@ 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 * subsections. Ordering inside the subsections is determined * by link order. @@ -180,8 +163,7 @@ extern bool initcall_debug; #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. -- 2.8.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] x86: remove LTO_REFERENCE_INITCALL() 2016-07-07 16:01 ` [PATCH v2] x86: remove LTO_REFERENCE_INITCALL() Luis R. Rodriguez @ 2016-07-07 16:32 ` Andi Kleen 2016-07-21 19:00 ` Luis R. Rodriguez 0 siblings, 1 reply; 8+ messages in thread From: Andi Kleen @ 2016-07-07 16:32 UTC (permalink / raw) To: Luis R. Rodriguez; +Cc: andi, hpa, linux-kernel, x86, bp, luto On Thu, Jul 07, 2016 at 09:01:49AM -0700, Luis R. Rodriguez wrote: > The setup for LTO never made it upstream, and although this has > some users, this is now really old stuff for a gcc 4.7 LTO problem. > We know that at least LTO_REFERENCE_INITCALL() work around can > be removed if LTO is not supported on v4.7 anymore. > > As per Andi the DISABLE_LTO and LTO_CFLAGS are still neeeded though. Looks good. Thanks Acked-by: Andi Kleen <ak@linux.intel.com> -Andi ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] x86: remove LTO_REFERENCE_INITCALL() 2016-07-07 16:32 ` Andi Kleen @ 2016-07-21 19:00 ` Luis R. Rodriguez 0 siblings, 0 replies; 8+ messages in thread From: Luis R. Rodriguez @ 2016-07-21 19:00 UTC (permalink / raw) To: Andi Kleen; +Cc: Luis R. Rodriguez, hpa, linux-kernel, x86, bp, luto On Thu, Jul 07, 2016 at 09:32:00AM -0700, Andi Kleen wrote: > On Thu, Jul 07, 2016 at 09:01:49AM -0700, Luis R. Rodriguez wrote: > > The setup for LTO never made it upstream, and although this has > > some users, this is now really old stuff for a gcc 4.7 LTO problem. > > We know that at least LTO_REFERENCE_INITCALL() work around can > > be removed if LTO is not supported on v4.7 anymore. > > > > As per Andi the DISABLE_LTO and LTO_CFLAGS are still neeeded though. > > Looks good. Thanks > > Acked-by: Andi Kleen <ak@linux.intel.com> This is not yet merged but since it makes more sense in the context of linker tables I'm going to fold this patch into that series and post today. Luis ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-07-21 19:00 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-06-23 23:34 Is LTO_REFERENCE_INITCALL() still needed? Luis R. Rodriguez 2016-06-24 21:07 ` Andi Kleen 2016-06-28 0:47 ` Luis R. Rodriguez 2016-07-07 0:22 ` [PATCH] x86: remove LTO flags Luis R. Rodriguez 2016-07-07 1:55 ` Andi Kleen 2016-07-07 16:01 ` [PATCH v2] x86: remove LTO_REFERENCE_INITCALL() Luis R. Rodriguez 2016-07-07 16:32 ` Andi Kleen 2016-07-21 19:00 ` Luis R. Rodriguez
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).