mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Hide all symbols in the compiled python extensions on unix
They were already hidden on windows. Avoids the possibility of symbol collisions and also means ld has to do less work when loading them extensions.
This commit is contained in:
parent
7bb017d94c
commit
aee8af31f3
@ -34,6 +34,13 @@ class Extension(object):
|
|||||||
self.error = d['error'] = kwargs.get('error', None)
|
self.error = d['error'] = kwargs.get('error', None)
|
||||||
self.libraries = d['libraries'] = kwargs.get('libraries', [])
|
self.libraries = d['libraries'] = kwargs.get('libraries', [])
|
||||||
self.cflags = d['cflags'] = kwargs.get('cflags', [])
|
self.cflags = d['cflags'] = kwargs.get('cflags', [])
|
||||||
|
if iswindows:
|
||||||
|
self.cflags.append('/DCALIBRE_MODINIT_FUNC=PyMODINIT_FUNC')
|
||||||
|
else:
|
||||||
|
if self.needs_cxx:
|
||||||
|
self.cflags.append('-DCALIBRE_MODINIT_FUNC=extern "C" __attribute__ ((visibility ("default"))) void')
|
||||||
|
else:
|
||||||
|
self.cflags.append('-DCALIBRE_MODINIT_FUNC=__attribute__ ((visibility ("default"))) void')
|
||||||
self.ldflags = d['ldflags'] = kwargs.get('ldflags', [])
|
self.ldflags = d['ldflags'] = kwargs.get('ldflags', [])
|
||||||
self.optional = d['options'] = kwargs.get('optional', False)
|
self.optional = d['options'] = kwargs.get('optional', False)
|
||||||
of = kwargs.get('optimize_level', None)
|
of = kwargs.get('optimize_level', None)
|
||||||
@ -145,6 +152,7 @@ def init_env():
|
|||||||
ldflags = shlex.split(ldflags)
|
ldflags = shlex.split(ldflags)
|
||||||
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
cflags += shlex.split(os.environ.get('CFLAGS', ''))
|
||||||
ldflags += shlex.split(os.environ.get('LDFLAGS', ''))
|
ldflags += shlex.split(os.environ.get('LDFLAGS', ''))
|
||||||
|
cflags += ['-fvisibility=hidden']
|
||||||
|
|
||||||
if islinux:
|
if islinux:
|
||||||
cflags.append('-pthread')
|
cflags.append('-pthread')
|
||||||
|
@ -119,7 +119,7 @@ static PyMethodDef libusb_methods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initlibusb(void) {
|
initlibusb(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ static PyMethodDef libmtp_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initlibmtp(void) {
|
initlibmtp(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ static PyMethodDef wpd_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initwpd(void) {
|
initwpd(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ static PyMethodDef usbobserver_methods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initusbobserver(void) {
|
initusbobserver(void) {
|
||||||
(void) Py_InitModule("usbobserver", usbobserver_methods);
|
(void) Py_InitModule("usbobserver", usbobserver_methods);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ static PyMethodDef cPalmdocMethods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initcPalmdoc(void) {
|
initcPalmdoc(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
m = Py_InitModule3("cPalmdoc", cPalmdocMethods,
|
m = Py_InitModule3("cPalmdoc", cPalmdocMethods,
|
||||||
|
@ -694,7 +694,7 @@ static PyMethodDef bzzdecmethods[] = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initbzzdec(void) {
|
initbzzdec(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
m = Py_InitModule3("bzzdec", bzzdecmethods,
|
m = Py_InitModule3("bzzdec", bzzdecmethods,
|
||||||
|
@ -1258,7 +1258,7 @@ static PyMethodDef cpatiencediff_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
init_patiencediff_c(void)
|
init_patiencediff_c(void)
|
||||||
{
|
{
|
||||||
PyObject* m;
|
PyObject* m;
|
||||||
|
@ -474,7 +474,7 @@ static PyMethodDef html_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
inithtml(void) {
|
inithtml(void) {
|
||||||
PyObject *m, *temp;
|
PyObject *m, *temp;
|
||||||
if (PyType_Ready(&html_TagType) < 0)
|
if (PyType_Ready(&html_TagType) < 0)
|
||||||
|
@ -10,7 +10,7 @@ SQLITE_EXTENSION_INIT1
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define MYEXPORT __declspec(dllexport)
|
#define MYEXPORT __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define MYEXPORT
|
#define MYEXPORT __attribute__ ((visibility ("default")))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// sortconcat {{{
|
// sortconcat {{{
|
||||||
@ -271,7 +271,7 @@ static PyMethodDef sqlite_custom_methods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initsqlite_custom(void) {
|
initsqlite_custom(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
m = Py_InitModule3("sqlite_custom", sqlite_custom_methods,
|
m = Py_InitModule3("sqlite_custom", sqlite_custom_methods,
|
||||||
|
@ -379,7 +379,7 @@ static PyMethodDef certgen_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initcertgen(void) {
|
initcertgen(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
m = Py_InitModule3("certgen", certgen_methods,
|
m = Py_InitModule3("certgen", certgen_methods,
|
||||||
|
@ -708,7 +708,7 @@ IndexMethods[] = {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
MODEXPORT(void)
|
CALIBRE_MODINIT_FUNC
|
||||||
initchm_extra (void) {
|
initchm_extra (void) {
|
||||||
Py_InitModule ("chm_extra", IndexMethods);
|
Py_InitModule ("chm_extra", IndexMethods);
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1106,7 @@ static swig_const_info swig_const_table[] = {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
#endif
|
#endif
|
||||||
SWIGEXPORT(void) SWIG_init(void) {
|
CALIBRE_MODINIT_FUNC SWIG_init(void) {
|
||||||
static PyObject *SWIG_globals = 0;
|
static PyObject *SWIG_globals = 0;
|
||||||
static int typeinit = 0;
|
static int typeinit = 0;
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
|
@ -293,7 +293,7 @@ PyMethodDef methods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initfreetype(void) {
|
initfreetype(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ PyMethodDef winfonts_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initwinfonts(void) {
|
initwinfonts(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
m = Py_InitModule3(
|
m = Py_InitModule3(
|
||||||
|
@ -1175,7 +1175,7 @@ static PyMethodDef icu_methods[] = {
|
|||||||
|
|
||||||
#define ADDUCONST(x) PyModule_AddIntConstant(m, #x, x)
|
#define ADDUCONST(x) PyModule_AddIntConstant(m, #x, x)
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initicu(void)
|
initicu(void)
|
||||||
{
|
{
|
||||||
PyObject* m;
|
PyObject* m;
|
||||||
|
@ -202,7 +202,7 @@ static PyMethodDef lzx_methods[] = {
|
|||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initlzx(void)
|
initlzx(void)
|
||||||
{
|
{
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
@ -508,7 +508,7 @@ static PyMethodDef matcher_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initmatcher(void) {
|
initmatcher(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
MatcherType.tp_new = PyType_GenericNew;
|
MatcherType.tp_new = PyType_GenericNew;
|
||||||
|
@ -71,7 +71,7 @@ static PyMethodDef monotonic_methods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initmonotonic(void) {
|
initmonotonic(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -78,7 +78,7 @@ static PyMethodDef msdes_methods[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initmsdes(void)
|
initmsdes(void)
|
||||||
{
|
{
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
@ -38,7 +38,7 @@ class PyLogMessage : public PdfError::LogMessageCallback {
|
|||||||
|
|
||||||
PyLogMessage log_message;
|
PyLogMessage log_message;
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initpodofo(void)
|
initpodofo(void)
|
||||||
{
|
{
|
||||||
PyObject* m;
|
PyObject* m;
|
||||||
|
@ -483,7 +483,7 @@ static PyMethodDef speedup_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initspeedup(void) {
|
initspeedup(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
m = Py_InitModule3("speedup", speedup_methods,
|
m = Py_InitModule3("speedup", speedup_methods,
|
||||||
|
@ -165,7 +165,7 @@ static PyTypeObject DictionaryType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
inithunspell(void) {
|
inithunspell(void) {
|
||||||
PyObject *mod;
|
PyObject *mod;
|
||||||
|
|
||||||
@ -185,4 +185,3 @@ inithunspell(void) {
|
|||||||
Py_INCREF(&DictionaryType);
|
Py_INCREF(&DictionaryType);
|
||||||
PyModule_AddObject(mod, "Dictionary", (PyObject *)&DictionaryType);
|
PyModule_AddObject(mod, "Dictionary", (PyObject *)&DictionaryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ static PyTypeObject RARArchiveType = { // {{{
|
|||||||
// }}} End RARArchive
|
// }}} End RARArchive
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initunrar(void) {
|
initunrar(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ be a unicode string. Returns unicode strings."
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initwinutil(void) {
|
initwinutil(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
m = Py_InitModule3("winutil", WinutilMethods,
|
m = Py_InitModule3("winutil", WinutilMethods,
|
||||||
|
@ -383,7 +383,7 @@ static PyMethodDef methods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initzlib2(void) {
|
initzlib2(void) {
|
||||||
PyObject *m, *ver;
|
PyObject *m, *ver;
|
||||||
Comptype.tp_new = PyType_GenericNew;
|
Comptype.tp_new = PyType_GenericNew;
|
||||||
|
@ -63,7 +63,12 @@ static struct PyModuleDef moduledef = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
#ifdef _MSVC
|
||||||
|
#define EXPORTED __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define EXPORTED __attribute__ ((visibility ("default")))
|
||||||
|
#endif
|
||||||
|
EXPORTED PyMODINIT_FUNC
|
||||||
#if PY_MAJOR_VERSION >= 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
PyInit_dukpy(void)
|
PyInit_dukpy(void)
|
||||||
#else
|
#else
|
||||||
|
@ -412,7 +412,7 @@ static PyMethodDef lzma_binding_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
initlzma_binding(void) {
|
initlzma_binding(void) {
|
||||||
PyObject *m = NULL, *preset_map = NULL, *temp = NULL;
|
PyObject *m = NULL, *preset_map = NULL, *temp = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -416,7 +416,7 @@ static PyMethodDef tokenizer_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
CALIBRE_MODINIT_FUNC
|
||||||
inittokenizer(void) {
|
inittokenizer(void) {
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
if (PyType_Ready(&tokenizer_TokenType) < 0)
|
if (PyType_Ready(&tokenizer_TokenType) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user