[Mesa-dev] [PATCH] mapi: fix LTO compilation
Jan Ziak (⚛)
0xe2.0x9a.0x9b at gmail.com
Thu Jun 2 17:41:14 UTC 2016
LTO compilation can sometimes fail with GCC 4.9 and GCC 5.3 because
src/mapi uses unusual mixing of C code and assembly code. The issue
may be present in case of GCC 6.1 as well.
This is a Mesa bug rather than a compiler bug (although in an ideal
world the compilation with -flto should fail if and only if normal
compilation fails).
The error message:
entry_x86-64_tls.h:61: undefined reference to `x86_64_entry_start'
Without the patch:
- using "-flto -O2 -DDEBUG" fails with GCC 4.9 and 5.3
- using "-flto -O3 -DDEBUG" succeeds with GCC 4.9 and 5.3
- using "-flto -O2 -DNDEBUG" succeeds with GCC 4.9 and 5.3
The patch assumes that the assembler understands ".hidden" directive.
Signed-off-by: Jan Ziak (⚛) <0xe2.0x9a.0x9b at gmail.com>
---
src/mapi/entry_x86-64_tls.h | 5 +++--
src/mapi/entry_x86_tls.h | 12 +++++++++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/mapi/entry_x86-64_tls.h b/src/mapi/entry_x86-64_tls.h
index 38faccc..acabecc 100644
--- a/src/mapi/entry_x86-64_tls.h
+++ b/src/mapi/entry_x86-64_tls.h
@@ -28,6 +28,8 @@
__asm__(".text\n"
".balign 32\n"
+ ".globl x86_64_entry_start\n"
+ ".hidden x86_64_entry_start\n"
"x86_64_entry_start:");
#define STUB_ASM_ENTRY(func) \
@@ -54,8 +56,7 @@ entry_patch_public(void)
{
}
-static char
-x86_64_entry_start[];
+extern char x86_64_entry_start[];
mapi_func
entry_get_public(int slot)
diff --git a/src/mapi/entry_x86_tls.h b/src/mapi/entry_x86_tls.h
index 46d2ece..6078b9a 100644
--- a/src/mapi/entry_x86_tls.h
+++ b/src/mapi/entry_x86_tls.h
@@ -29,7 +29,9 @@
__asm__(".text");
-__asm__("x86_current_tls:\n\t"
+__asm__( ".globl x86_current_tls\n"
+ ".hidden x86_current_tls\n"
+ "x86_current_tls:\n\t"
"call 1f\n"
"1:\n\t"
"popl %eax\n\t"
@@ -42,6 +44,8 @@ __asm__(".section wtext, \"awx\", @progbits");
#endif /* GLX_X86_READONLY_TEXT */
__asm__(".balign 16\n"
+ ".globl x86_entry_start\n"
+ ".hidden x86_entry_start\n"
"x86_entry_start:");
#define STUB_ASM_ENTRY(func) \
@@ -60,6 +64,8 @@ __asm__(".balign 16\n"
#ifndef GLX_X86_READONLY_TEXT
__asm__(".balign 16\n"
+ ".globl x86_entry_end\n"
+ ".hidden x86_entry_end\n"
"x86_entry_end:");
__asm__(".text");
#endif /* GLX_X86_READONLY_TEXT */
@@ -71,8 +77,8 @@ __asm__(".text");
extern unsigned long
x86_current_tls();
-static char x86_entry_start[];
-static char x86_entry_end[];
+extern char x86_entry_start[];
+extern char x86_entry_end[];
void
entry_patch_public(void)
--
2.8.3
More information about the mesa-dev
mailing list