[05/46] compiler.h: introduce __global_on_lto

Message ID 20221114114344.18650-6-jirislaby@kernel.org
State New
Headers
Series gcc-LTO support for the kernel |

Commit Message

Jiri Slaby Nov. 14, 2022, 11:43 a.m. UTC
  From: Jiri Slaby <jslaby@suse.cz>

__global_on_lto is defined as "globl" when gcc LTO is turned on (see
later patches), and "local" otherwise. It is needed for top-level
symbols which are referenced in assembly. It is because the assembly and
the symbol can each end up in a different file with gcc LTO. And that
leads to linker errors.

So the symbols have to be global when gcc LTO is in charge. On the
contrary, they can remain local on non-gcc-LTO builds.

Cc: Martin Liska <mliska@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/compiler.h | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 2305a3cbe99c..16e4c1de14c4 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -135,8 +135,10 @@  void ftrace_likely_update(struct ftrace_likely_data *f, int val,
 
 #ifdef CONFIG_LTO_GCC
 # define __visible_on_lto		__visible
+# define __global_on_lto		"globl"
 #else
 # define __visible_on_lto		static
+# define __global_on_lto		"local"
 #endif
 
 #ifndef unreachable