changeset: 3753:62e52f105bc0
tag: tip
user: Gustavo Sverzut Barbieri <[email protected]>
date: Fri Sep 17 09:42:57 2010 -0300
files: Cython/Compiler/ModuleNode.py
description:
Force GCC>=4 to export module initialization function.
With GCC's -fvisibility=hidden (both CFLAGS and LDFLAGS) it is
possible to have the compiler to produce binaries where all symbols
are hidden (local to the binary). To force a symbol to be visible one
must specify __attribute__ ((visibility("default"))).
This patch introduces pre-processor code to always force module
symbols to be visible.
NOTE: in theory pyport.h from Python would do the right thing, but it
does not define any special cases for GCC, just Windows. As Python is
not changing that easily and even if it does is just for future releases,
it's better to have those in Cython.
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
--- a/Cython/Compiler/ModuleNode.py
+++ b/Cython/Compiler/ModuleNode.py
@@ -1671,9 +1671,15 @@
header2 = "PyMODINIT_FUNC init%s(void)" % env.module_name
header3 = "PyMODINIT_FUNC PyInit_%s(void)" % env.module_name
code.putln("#if PY_MAJOR_VERSION < 3")
+ code.putln("# if defined(__GNUC__) && (__GNUC__ >= 4)")
+ code.putln("__attribute__ ((visibility(\"default\")))")
+ code.putln("# endif")
code.putln("%s; /*proto*/" % header2)
code.putln(header2)
code.putln("#else")
+ code.putln("# if defined(__GNUC__) && (__GNUC__ >= 4)")
+ code.putln("__attribute__ ((visibility(\"default\")))")
+ code.putln("# endif")
code.putln("%s; /*proto*/" % header3)
code.putln(header3)
code.putln("#endif")
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
changeset: 3753:62e52f105bc0
tag: tip
user: Gustavo Sverzut Barbieri <[email protected]>
date: Fri Sep 17 09:42:57 2010 -0300
files: Cython/Compiler/ModuleNode.py
description:
Force GCC>=4 to export module initialization function.
With GCC's -fvisibility=hidden (both CFLAGS and LDFLAGS) it is
possible to have the compiler to produce binaries where all symbols
are hidden (local to the binary). To force a symbol to be visible one
must specify __attribute__ ((visibility("default"))).
This patch introduces pre-processor code to always force module
symbols to be visible.
NOTE: in theory pyport.h from Python would do the right thing, but it
does not define any special cases for GCC, just Windows. As Python is
not changing that easily and even if it does is just for future releases,
it's better to have those in Cython.
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
--- a/Cython/Compiler/ModuleNode.py
+++ b/Cython/Compiler/ModuleNode.py
@@ -1671,9 +1671,15 @@
header2 = "PyMODINIT_FUNC init%s(void)" % env.module_name
header3 = "PyMODINIT_FUNC PyInit_%s(void)" % env.module_name
code.putln("#if PY_MAJOR_VERSION < 3")
+ code.putln("# if defined(__GNUC__) && (__GNUC__ >= 4)")
+ code.putln("__attribute__ ((visibility(\"default\")))")
+ code.putln("# endif")
code.putln("%s; /*proto*/" % header2)
code.putln(header2)
code.putln("#else")
+ code.putln("# if defined(__GNUC__) && (__GNUC__ >= 4)")
+ code.putln("__attribute__ ((visibility(\"default\")))")
+ code.putln("# endif")
code.putln("%s; /*proto*/" % header3)
code.putln(header3)
code.putln("#endif")
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev