Skip to content

Commit a516b06

Browse files
authored
Merge pull request matplotlib#32235 from meeseeksmachine/auto-backport-of-pr-32209-on-v3.11.x
Backport PR matplotlib#32209 on branch v3.11.x (BLD: Force all internal extension symbols to be hidden)
2 parents a18cc80 + 33dc49b commit a516b06

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/hidden-symbols.map

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
global:
3+
PyInit_*;
4+
local:
5+
*;
6+
};

src/meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,19 @@ else
125125
new_preprocessor = []
126126
endif
127127

128+
# Even though Meson defaults to hidden visibility, our bundled libraries like FreeType
129+
# may themselves export their own symbols individually. So force all symbols other than
130+
# the Python module initialization function to be hidden with a linker version script.
131+
mapfile = 'hidden-symbols.map'
132+
vflag = cc.get_supported_link_arguments([
133+
'-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
134+
])
135+
128136
foreach ext, kwargs : extension_data
129137
additions = {
130138
'cpp_args': [new_preprocessor] + kwargs.get('cpp_args', []),
139+
'link_args': [vflag] + kwargs.get('link_args', []),
140+
'link_depends': [mapfile] + kwargs.get('link_depends', []),
131141
}
132142
py3.extension_module(
133143
ext,

0 commit comments

Comments
 (0)