Andi Kleen <[email protected]> writes:

>> Thanks both!
>
> For modules the Makefile needs to be adjusted to run final LTO before
> modpost etc. These were the respective hunks from the old patchkit
> (may need some tweaks)

Thanks Andi. This got me further:

--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -232,11 +232,11 @@ endef
 # ===========================================================================
 # These are shared by some Makefile.* files.
 
-ifdef CONFIG_LTO_CLANG
+ifdef CONFIG_LTO
 # Run $(LD) here to convert LLVM IR to ELF in the following cases:
 #  - when this object needs objtool processing, as objtool cannot process LLVM IR
 #  - when this is a single-object module, as modpost cannot process LLVM IR
-cmd_ld_single = $(if $(objtool-enabled)$(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
+cmd_ld_single = $(if $(objtool-enabled)$(is-single-obj-m), ; $(LDFINAL) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
 endif
 
 quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -73,7 +73,7 @@
 #endif
 
 #define __EXPORT_SYMBOL(sym, license, ns)			\
-	extern typeof(sym) sym;					\
+	extern __visible typeof(sym) sym;			\
 	__ADDRESSABLE(sym)					\
 	__GENDWARFKSYMS_EXPORT(sym)				\
 	asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -130,7 +130,7 @@ extern void cleanup_module(void);
 #define module_init(initfn)					\
 	static inline initcall_t __maybe_unused __inittest(void)		\
 	{ return initfn; }					\
-	int init_module(void) __copy(initfn)			\
+	int __visible init_module(void) __copy(initfn)			\
 		__attribute__((alias(#initfn)));		\
 	___ADDRESSABLE(init_module, __initdata);
 
@@ -138,7 +138,7 @@ extern void cleanup_module(void);
 #define module_exit(exitfn)					\
 	static inline exitcall_t __maybe_unused __exittest(void)		\
 	{ return exitfn; }					\
-	void cleanup_module(void) __copy(exitfn)		\
+	void __visible cleanup_module(void) __copy(exitfn)		\
 		__attribute__((alias(#exitfn)));		\
 	___ADDRESSABLE(cleanup_module, __exitdata);
 
@@ -277,7 +277,7 @@ static typeof(name) __mod_device_table__##type##__##name		\
 #else
 #define MODULE_VERSION(_version)					\
 	MODULE_INFO(version, _version);					\
-	static const struct module_version_attribute __modver_attr	\
+	static __visible const struct module_version_attribute __modver_attr	\
 		__used __section("__modver")				\
 		__aligned(__alignof__(struct module_version_attribute)) \
 		= {							\
@@ -309,7 +309,7 @@ extern int modules_disabled; /* for sysctl */
 void *__symbol_get(const char *symbol);
 void *__symbol_get_gpl(const char *symbol);
 #define symbol_get(x)	({ \
-	static const char __notrim[] \
+	static __visible const char __notrim[] \
 		__used __section(".no_trim_symbol") = __stringify(x); \
 	(typeof(&x))(__symbol_get(__stringify(x))); })
 
depmod no longer complains.

(Some of the __visible may not be needed, was slightly shotgun there.)

Then I get booted, just hangs at some point after amdgpu handover in the
initramfs. I'll play around more with that in a VM.

One thing I'm not yet sure about is initcall.lds and whether we need an
equivalent or not.

Reply via email to