This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Hide symbols in _decimal.so
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: skrah Nosy List: christian.heimes, dmalcolm, doko, lemburg, loewis, meador.inge, pitrou, python-dev, skrah
Priority: normal Keywords: patch

Created on 2012-12-21 17:15 by skrah, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
libmpdec-hide-non-api-symbols.diff skrah, 2012-12-21 17:15 review
Messages (8)
msg177883 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-12-21 17:15
This issue is for the _decimal specific parts from #4555. The patch
depends on _Pragma (C99) and gcc >= 4.0 for the contents of the pragma.
I think it will work for clang, too.

Should the libmpdec API symbols (i.e. the ones starting with mpd_*)
be hidden for _decimal.c, too?
msg177886 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-12-21 17:22
Adding everyone from issue #4555, in case you can think of a different
(portable) solution for hiding symbols (with minimal effort).
msg177890 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2012-12-21 19:51
Personally I prefer using attributes instead of pragmas.  The GCC manual recommends such as well.  There are also other sources in Modules/* that use '__attribute__ ((visibility ("hidden")))'.  Namely ctypes and zlib.

I can understand that it is more work, but I find something like the following more readable (I am not actually suggesting names here, just an example):

   #define PY_LOCAL __attribute__ ((visibility ("hidden")))

   ...

   void foo(void) PY_LOCAL;
   void bar(void) PY_LOCAL;
msg177894 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-12-21 20:50
Meador Inge <report@bugs.python.org> wrote:
> Personally I prefer using attributes instead of pragmas.  The GCC manual recommends such as well.

I followed www.akkadia.org/drepper/dsohowto.pdf . Drepper seems to be fine
with the use of pragmas in internal headers.

> There are also other sources in Modules/* that use '__attribute__ ((visibility ("hidden")))'.  Namely ctypes and zlib.

They do, but for a tiny amount of functions. mpdecimal.h, which is internal
as far as _decimal.so is concerned, also needs to be changed. There you have
something like 200 lines of

[...]
void mpd_qrescale(mpd_t *result, const mpd_t *a, mpd_ssize_t exp, const mpd_context_t *ctx, uint32_t *status) Py_HIDDEN;
void mpd_qrescale_fmt(mpd_t *result, const mpd_t *a, mpd_ssize_t exp, const mpd_context_t *ctx, uint32_t *status) Py_HIDDEN;
[...],

which increases the size of the diff between the standalone libmpdec and the
one shipped with Python.
msg177896 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2012-12-21 21:06
Ah, I missed how big of a line range these pragmas are covering when I scanned the patch before.  In that case, I agree with the current patch.
msg177904 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-21 22:28
New changeset 24f6c6f3b7bf by Stefan Krah in branch '3.3':
Issue #16745: Hide a couple of symbols by making them local.
http://hg.python.org/cpython/rev/24f6c6f3b7bf
msg177941 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-22 13:25
New changeset 51b0a150f8aa by Stefan Krah in branch '3.3':
Issue #16745: Hide symbols in _decimal.so.
http://hg.python.org/cpython/rev/51b0a150f8aa
msg177959 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-22 22:09
New changeset ccc372b37fbb by Stefan Krah in branch '3.3':
Issue #16745: The gcc visibility pragma is buggy on OpenIndiana and NetBSD.
http://hg.python.org/cpython/rev/ccc372b37fbb
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60949
2012-12-23 11:09:58skrahsetstatus: open -> closed
resolution: fixed
stage: resolved
2012-12-22 22:09:37python-devsetmessages: + msg177959
2012-12-22 13:25:58python-devsetmessages: + msg177941
2012-12-21 22:28:11python-devsetnosy: + python-dev
messages: + msg177904
2012-12-21 21:06:17meador.ingesetmessages: + msg177896
2012-12-21 20:50:07skrahsetmessages: + msg177894
2012-12-21 19:51:49meador.ingesetmessages: + msg177890
2012-12-21 17:38:02meador.ingesetnosy: + meador.inge
2012-12-21 17:22:01skrahsetnosy: + lemburg, loewis, doko, pitrou, christian.heimes, dmalcolm
messages: + msg177886
2012-12-21 17:15:33skrahcreate