[Mesa-dev] [PATCH] mapi: Massage code to allow clang to compile.

Matt Turner mattst88 at gmail.com
Mon Jul 11 17:49:53 UTC 2016


According to https://llvm.org/bugs/show_bug.cgi?id=19778#c3 this code
was violating the spec, resulting in it failing to compile.

Cc: mesa-stable at lists.freedesktop.org
Co-authored-by: Tomasz Paweł Gajc <tpgxyz at gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89599
---
I've tried for months to reproduce this, and I've still never been
able to on 64-bit builds. I can reproduce it on 32-bit however.

On MSVC, this patch will have the effect of changing the variables
from static to extern. I do not know if this will adversely affect
anything, so this patch would benefit from MSVC testing.

 configure.ac                |  1 +
 src/mapi/entry_x86-64_tls.h |  9 +++++++--
 src/mapi/entry_x86_tls.h    | 10 ++++++++--
 src/mapi/entry_x86_tsd.h    |  9 +++++++--
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 367e9b5..ddd8e1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,6 +225,7 @@ AX_GCC_FUNC_ATTRIBUTE([packed])
 AX_GCC_FUNC_ATTRIBUTE([pure])
 AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
 AX_GCC_FUNC_ATTRIBUTE([unused])
+AX_GCC_FUNC_ATTRIBUTE([visibility])
 AX_GCC_FUNC_ATTRIBUTE([warn_unused_result])
 AX_GCC_FUNC_ATTRIBUTE([weak])
 
diff --git a/src/mapi/entry_x86-64_tls.h b/src/mapi/entry_x86-64_tls.h
index 38faccc..c5262a1 100644
--- a/src/mapi/entry_x86-64_tls.h
+++ b/src/mapi/entry_x86-64_tls.h
@@ -25,6 +25,11 @@
  *    Chia-I Wu <olv at lunarg.com>
  */
 
+#ifdef HAVE_FUNC_ATTRIBUTE_VISIBIITY
+#define HIDDEN __attribute__((visibility("hidden")))
+#else
+#define HIDDEN
+#endif
 
 __asm__(".text\n"
         ".balign 32\n"
@@ -54,8 +59,8 @@ entry_patch_public(void)
 {
 }
 
-static char
-x86_64_entry_start[];
+extern char
+x86_64_entry_start[] HIDDEN;
 
 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..231b409 100644
--- a/src/mapi/entry_x86_tls.h
+++ b/src/mapi/entry_x86_tls.h
@@ -27,6 +27,12 @@
 
 #include <string.h>
 
+#ifdef HAVE_FUNC_ATTRIBUTE_VISIBIITY
+#define HIDDEN __attribute__((visibility("hidden")))
+#else
+#define HIDDEN
+#endif
+
 __asm__(".text");
 
 __asm__("x86_current_tls:\n\t"
@@ -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[] HIDDEN;
+extern char x86_entry_end[] HIDDEN;
 
 void
 entry_patch_public(void)
diff --git a/src/mapi/entry_x86_tsd.h b/src/mapi/entry_x86_tsd.h
index ea7bacb..03d9735 100644
--- a/src/mapi/entry_x86_tsd.h
+++ b/src/mapi/entry_x86_tsd.h
@@ -25,6 +25,11 @@
  *    Chia-I Wu <olv at lunarg.com>
  */
 
+#ifdef HAVE_FUNC_ATTRIBUTE_VISIBIITY
+#define HIDDEN __attribute__((visibility("hidden")))
+#else
+#define HIDDEN
+#endif
 
 #define X86_ENTRY_SIZE 32
 
@@ -58,8 +63,8 @@ __asm__(".balign 32\n"
 #include <string.h>
 #include "u_execmem.h"
 
-static const char x86_entry_start[];
-static const char x86_entry_end[];
+extern const char x86_entry_start[] HIDDEN;
+extern const char x86_entry_end[] HIDDEN;
 
 void
 entry_patch_public(void)
-- 
2.7.3



More information about the mesa-dev mailing list