Source

pypy-patches / visibility.diff

Full commit
# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
# Date 1291299495 -3600
# Node ID d1bfa37112c029846cd4aa8c4328bd3178d8a5f9
# Parent  50d860703529d1e4aad03a2e8fc395bb74cfbde5
Make symbols hidden by default.

diff --git a/pypy/module/cpyext/include/Python.h b/pypy/module/cpyext/include/Python.h
--- a/pypy/module/cpyext/include/Python.h
+++ b/pypy/module/cpyext/include/Python.h
@@ -11,8 +11,13 @@
 # include <errno.h>
 # include <unistd.h>
 # define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
-# define PyAPI_FUNC(RTYPE) RTYPE
-# define PyAPI_DATA(RTYPE) extern RTYPE
+# if defined(__GCC__) && defined(Py_BUILD_CORE)
+#  define PyAPI_FUNC(RTYPE) __attribute__((externally_visible)) RTYPE
+#  define PyAPI_DATA(RTYPE) __attribute__((externally_visible)) extern RTYPE
+# else
+#  define PyAPI_FUNC(RTYPE) RTYPE
+#  define PyAPI_DATA(RTYPE) extern RTYPE
+# endif
 # define Py_LOCAL_INLINE(type) static inline type
 #else
 # define MS_WIN32 1
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c
--- a/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c
+++ b/pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test.c
@@ -5,6 +5,8 @@
 
 #if defined(MS_WIN32)
 #define EXPORT(x) __declspec(dllexport) x
+#elif defined(__GCC__)
+#define EXPORT(x) __attribute__((externally_visible)) x
 #else
 #define EXPORT(x) x
 #endif
diff --git a/pypy/translator/platform/darwin.py b/pypy/translator/platform/darwin.py
--- a/pypy/translator/platform/darwin.py
+++ b/pypy/translator/platform/darwin.py
@@ -5,7 +5,7 @@ from pypy.translator.platform import pos
 class Darwin(posix.BasePosix):
     name = "darwin"
 
-    link_flags = ('-mmacosx-version-min=10.4',)
+    link_flags = ('-mmacosx-version-min=10.4', '-fvisibility=hidden')
     cflags = ('-O3', '-fomit-frame-pointer', '-mmacosx-version-min=10.4')
     standalone_only = ('-mdynamic-no-pic',)
     shared_only = ()