-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use GCC visibility attrs in PyAPI_* #55619
Comments
This patch adds support for the GCC visibility attributes to the PyAPI_* macros (currently only used for Windows.) GCC's default visibility is 'public', but can be changed to 'hidden' with the '-fvisibility=hidden' argument; see http://gcc.gnu.org/wiki/Visibility. This patch does not make the build use that, it merely makes Python function correctly when the default visibility *is* changed. (The benefit of building Python with -fvisibility=hidden is very small, as it causes only a handful of symbols to not be exported. When embedding Python, though, this can make a lot of difference.) The patch also fixes a few modules that don't use PyMODINIT_FUNC for their module-init function definitions, like they should. |
Uploaded to Rietveld, too: http://codereview.appspot.com/4260052/ |
Why the cygwin changes? Are they related? Also, is the change in Python/getargs.c necessary? |
The cygwin changes are no-ops, just refactoring the needlessly nested if statement for clarity. I can revert them. The getargs.c change *is* necessary, although it doesn't have to be that exact change. The problem is that the functions in that block are not declared in any file in Include/, although I don't know why not (it's true that these function shouldn't be called directly, but they are symbols that should be exported. The ifdef the patch removes makes the export happen only for Windows, but I see no reason to do that conditionally.) To be clear, the #define of (for example) PyArg_Parse to _PyArg_Parse_SizeT in Include/modsupport.h doesn't apply, because Python/getargs.c does not (and must not) define PY_SSIZE_T_CLEAN (or we wouldn't be able to define both PyArg_Parse and _PyArg_Parse_SizeT.) We could just list these functions in Include/modsupport.h, along with the 'public' (non-PY_SSIZE_T_CLEAN) ones -- but that only makes sense if we want code to call the ssize_t functions directly, which I don't think we want. |
Perhaps you can commit them separately? I don't think they need review. As for the getargs.c change, perhaps Martin has an opinion. I bet he's more knowledgeable than me on the matter. |
Exporting the SizeT functions on all systems is fine. It's not true that they aren't declared: they are declared in modsupport.h if PY_SSIZE_T_CLEAN is defined. Else they are not declared. The patch looks fine to. I agree that mere cleanup shouldn't get committed along with substantial changes. |
Windows/Cygwin parts of the patch reverted and new patch uploaded. My point about the _Py*_SizeT functions is that they're only declared when you define PY_SSIZE_T_CLEAN, and I don't know if we want to change that (I don't think it makes sense to.) |
Um ... any progress on reviewing this? |
I extracted the changes on the PyMODINIT_FUNC macro and I opened the issue bpo-23685. |
+#if defined(GNUC) && __GNUC__ >= 4 Clang now also supports __attribute__((visibility("..."))). I don't know since which version. I'm not sure because I don't see it: I see it there: |
Why not moving these declarations to Include/modsupport.h where _PyArg_Parse...() are already used? |
In the issue bpo-23685, I proposed a patch to add _PyBUILTIN_MODINIT_FUNC for builtin modules. It makes possible to hide PyInit_xxx symbols of builtin symbols with __attribute__((visibility("hidden"))). It also avoids to export these privates symbols on Windows in the Python DLL (and on Linux in the Python .so library). |
See also the issue bpo-19569: "Use __attribute__((deprecated)) to warn usage of deprecated functions and macros". |
Was this actually fixed, or did everyone just get tired and give up on the original patch? |
Reopening, as a new patch is available. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: