[PATCH] Add gcc visibility support.

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH] Add gcc visibility support.

by tom fogal-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Patch is attached.  I'm trying to get our app to support
-fvisibility=hidden, and I'm hitting issues with some of our third
party dependencies.  It was easier to fix GLEW than to try to filter
out the -f flag ;)

In other news, the dynamic-loading patchset is slowly moving along.
Linux and Mac are working well.  I think I've got an idea to avoid
forcing an API change, or rather one only needs the API change if
they want the new functionality.  I've got someone looking at Windows
support (currently broken in the patchset), and then I hope to give my
idea a try.

-tom


From ee7a8b25812e2a1b76cca72a121e7301cddf95cb Mon Sep 17 00:00:00 2001
From: Tom Fogal <tfogal@...>
Date: Tue, 30 Jun 2009 20:40:38 -0600
Subject: [PATCH] Add gcc visibility support.

---
 auto/src/glew_head.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/auto/src/glew_head.h b/auto/src/glew_head.h
index 4a315dc..9c46018 100644
--- a/auto/src/glew_head.h
+++ b/auto/src/glew_head.h
@@ -122,7 +122,11 @@ typedef _W64 int ptrdiff_t;
 
 #define GLEW_APIENTRY_DEFINED
 #define APIENTRY
-#define GLEWAPI extern
+#if __GNUC__ >= 4 && !defined(GLEW_STATIC)
+# define GLEWAPI extern __attribute__ ((visibility("default")))
+#else
+# define GLEWAPI extern
+#endif
 
 /* <glu.h> */
 #ifndef GLAPI
--
1.5.6.5


------------------------------------------------------------------------------

_______________________________________________
glew-coders mailing list
glew-coders@...
https://lists.sourceforge.net/lists/listinfo/glew-coders

Re: [PATCH] Add gcc visibility support.

by tom fogal-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

tom fogal <tfogal@...> writes:
> Patch is attached.  I'm trying to get our app to support
> -fvisibility=hidden, and I'm hitting issues with some of our third
> party dependencies.

Ooops.  I rescind my previous patch; that broke glewX.  Attached patch
works with both glew and glewX funcs.  I'm surprised it took me this
long to notice...

w.r.t. dynamic loading, patches are coming along well.  I'd be very
surprised if the patchset didn't get posted for review this summer;
early August I'd bet.

-tom


From d536f0ab9bdfdbd92721d29cb74273bc79eae640 Mon Sep 17 00:00:00 2001
From: Tom Fogal <tfogal@...>
Date: Tue, 30 Jun 2009 20:40:38 -0600
Subject: [PATCH] Add gcc visibility support.

---
 auto/Makefile                    |   15 +++++++++++++--
 auto/bin/fix_OML_sync_control.sh |    6 +++---
 auto/core/GL_VERSION_1_1         |    1 +
 auto/src/glew_head.h             |    6 +++++-
 auto/src/glxew_tail.h            |    8 ++++----
 5 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/auto/Makefile b/auto/Makefile
index 657ea6d..791d6c1 100644
--- a/auto/Makefile
+++ b/auto/Makefile
@@ -146,8 +146,19 @@ $(I.DEST)/glxew.h: $(EXT)/.dummy
  cat $(SRC)/glxew_head.h >> $@
  $(BIN)/make_header.pl '' GLX $(GLX_CORE_SPEC) >> $@
  $(BIN)/make_header.pl '' GLX $(GLX_EXT_SPEC) >> $@
- echo -e "/* ------------------------------------------------------------------------- */\n\n#ifdef GLEW_MX\n#define GLXEW_EXPORT\n#else\n#define GLXEW_EXPORT extern\n#endif /* GLEW_MX */" >> $@
- $(BIN)/make_struct_fun.pl extern $(GLX_CORE_SPEC) $(GLX_EXT_SPEC) >> $@
+ echo -e "/* --------------------------------------------------- */\n\n" >> $@
+ echo -e "#if __GNUC__ >= 4 && !defined(GLEW_STATIC)" >> $@
+ echo -e "#  define GLXEW_VIS __attribute__((visibility(\"default\")))" >> $@
+ echo -e "#else" >> $@
+ echo -e "#  define GLXEW_VIS /* visibility not supported */" >> $@
+ echo -e "#endif" >> $@
+ echo -e "#ifdef GLEW_MX" >> $@
+ echo -e "#  define GLXEW_EXPORT GLXEW_VIS" >> $@
+ echo -e "#else" >> $@
+ echo -e "#  define GLXEW_EXPORT extern GLXEW_VIS" >> $@
+ echo -e "#endif /* GLEW_MX */" >> $@
+ $(BIN)/make_struct_fun.pl GLXEW_EXPORT $(GLX_CORE_SPEC) $(GLX_EXT_SPEC) >> $@
+ echo -e "/* -- end make_struct_fun.pl -- */" >> $@
  echo -e "\n#if defined(GLEW_MX)\nstruct GLXEWContextStruct\n{\n#endif /* GLEW_MX */\n" >> $@
  $(BIN)/make_struct_var.pl GLXEW_EXPORT $(GLX_CORE_SPEC) $(GLX_EXT_SPEC) >> $@
  echo -e "\n#ifdef GLEW_MX\n}; /* GLXEWContextStruct */\n#endif /* GLEW_MX */\n" >> $@
diff --git a/auto/bin/fix_OML_sync_control.sh b/auto/bin/fix_OML_sync_control.sh
index 2579ab4..279179c 100755
--- a/auto/bin/fix_OML_sync_control.sh
+++ b/auto/bin/fix_OML_sync_control.sh
@@ -9,9 +9,9 @@
 
 perl -e 's/#ifndef GLX_OML_sync_control/#if !defined(GLX_OML_sync_control) \&\& defined(__STDC_VERSION__) \&\& (__STDC_VERSION__ >= 199901L)\n#include <inttypes.h>/;' -pi $1
 perl -e 's/#ifdef GLX_OML_sync_control/#if defined(GLX_OML_sync_control) \&\& defined(__STDC_VERSION__) \&\& (__STDC_VERSION__ >= 199901L)\n#include <inttypes.h>/;' -pi $1
-perl -e 's/(extern PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML;)/#ifdef GLX_OML_sync_control\n\1/' -pi $1
-perl -e 's/(extern PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML;)/\1\n#endif/' -pi $1
-perl -e 's/(extern GLboolean __GLXEW_OML_sync_control;)/#ifdef GLX_OML_sync_control\n\1\n#endif/' -pi $1
+perl -e 's/(GLXEW_EXPORT PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML;)/#ifdef GLX_OML_sync_control\n\1/' -pi $1
+perl -e 's/(GLXEW_EXPORT PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML;)/\1\n#endif/' -pi $1
+perl -e 's/(GLXEW_EXPORT GLboolean __GLXEW_OML_sync_control;)/#ifdef GLX_OML_sync_control\n\1\n#endif/' -pi $1
 perl -e 's/(PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML = NULL;)/#ifdef GLX_OML_sync_control\n\1/' -pi $1
 perl -e 's/(PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML = NULL;)/\1\n#endif/' -pi $1
 perl -e 's/(GLboolean __GLXEW_OML_sync_control = GL_FALSE;)/#ifdef GLX_OML_sync_control\n\1\n#endif/' -pi $1
diff --git a/auto/core/GL_VERSION_1_1 b/auto/core/GL_VERSION_1_1
index 5338b8a..de1f039 100644
--- a/auto/core/GL_VERSION_1_1
+++ b/auto/core/GL_VERSION_1_1
@@ -534,6 +534,7 @@ http://www.opengl.org/documentation/specs/version1.1/GLspec1.1.ps
   GL_COLOR_INDEX8_EXT 0x80E5
   GL_COLOR_INDEX12_EXT 0x80E6
   GL_COLOR_INDEX16_EXT 0x80E7
+  typedef int GLsizei
 
   GLubyte* glGetString (GLenum s)
   void glAccum (GLenum op, GLfloat value)
diff --git a/auto/src/glew_head.h b/auto/src/glew_head.h
index 4a315dc..9c46018 100644
--- a/auto/src/glew_head.h
+++ b/auto/src/glew_head.h
@@ -122,7 +122,11 @@ typedef _W64 int ptrdiff_t;
 
 #define GLEW_APIENTRY_DEFINED
 #define APIENTRY
-#define GLEWAPI extern
+#if __GNUC__ >= 4 && !defined(GLEW_STATIC)
+# define GLEWAPI extern __attribute__ ((visibility("default")))
+#else
+# define GLEWAPI extern
+#endif
 
 /* <glu.h> */
 #ifndef GLAPI
diff --git a/auto/src/glxew_tail.h b/auto/src/glxew_tail.h
index 702eb94..8e3fc98 100644
--- a/auto/src/glxew_tail.h
+++ b/auto/src/glxew_tail.h
@@ -3,8 +3,8 @@
 #ifdef GLEW_MX
 
 typedef struct GLXEWContextStruct GLXEWContext;
-extern GLenum glxewContextInit (GLXEWContext* ctx);
-extern GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name);
+GLXEW_EXPORT GLenum glxewContextInit (GLXEWContext* ctx);
+GLXEW_EXPORT GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name);
 
 #define glxewInit() glxewContextInit(glxewGetContext())
 #define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x)
@@ -17,11 +17,11 @@ extern GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name);
 #define GLXEW_GET_VAR(x) (*(const GLboolean*)&x)
 #define GLXEW_GET_FUN(x) x
 
-extern GLboolean glxewIsSupported (const char* name);
+GLXEW_EXPORT GLboolean glxewIsSupported (const char* name);
 
 #endif /* GLEW_MX */
 
-extern GLboolean glxewGetExtension (const char* name);
+GLXEW_EXPORT GLboolean glxewGetExtension (const char* name);
 
 #ifdef __cplusplus
 }
--
1.5.6.5


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
glew-coders mailing list
glew-coders@...
https://lists.sourceforge.net/lists/listinfo/glew-coders