mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Configure extra compile args in setup.py (#28264)
Fixes https://github.com/protocolbuffers/protobuf/issues/28261 by setting symbol visibility in `setup.py`, similar to `py_extension.bzl`, using the existing branching logic to bypass the flag on MSVC.
This issue manifests in the [NixOS/nixpkgs](https://github.com/NixOS/nixpkgs) build of the `protobuf` python package, which contains upb symbols, and causes fatal failures when loaded in a process that separately links/loads libprotobuf. We'll supply a patch there as well, until this can be backported or released in future protobuf versions.
Closes #28264
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/28264 from mitchallain:mallain/fix-python-upb-symbols 6e118a62bf
PiperOrigin-RevId: 942223178
This commit is contained in:
parent
e1b94ce8f9
commit
3aa022a269
1 changed files with 4 additions and 0 deletions
4
python/dist/setup.py
vendored
4
python/dist/setup.py
vendored
|
|
@ -33,9 +33,12 @@ def GetVersion():
|
|||
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
extra_link_args = []
|
||||
extra_compile_args = []
|
||||
|
||||
if sys.platform.startswith('win'):
|
||||
extra_link_args = ['-static']
|
||||
else:
|
||||
extra_compile_args = ['-fvisibility=hidden']
|
||||
|
||||
# If at some point the fasttable decoder is ready for prime time, we could
|
||||
# enable it here. But even then we'll need to disable it on platforms where
|
||||
|
|
@ -86,6 +89,7 @@ setup(
|
|||
include_dirs=[current_dir, os.path.join(current_dir, 'utf8_range')],
|
||||
language='c',
|
||||
extra_link_args=extra_link_args,
|
||||
extra_compile_args=extra_compile_args,
|
||||
)
|
||||
],
|
||||
python_requires='>=3.10',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue