User cannot set `gnu_symbol_visibility` to `''` with python `extension_module`
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 1.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 33
Description
**Describe the bug**
Explicitly setting `gnu_symbol_visibility: ''` gets interpreted as `gnu_symbol_visibility: 'hidden'` for Python `extension_modules`.
This is because an empty string gets overriden by `hidden`, presumably to change the default
https://github.com/mesonbuild/meson/blob/42a4d1aaa0854d376e9d28cf4b6ca93df90c8213/mesonbuild/modules/python.py#L229
**To Reproduce**
Should be reproducible easily with
```meson
py = import('python').find_installation(pure: false)
py.extension_module(
'module-name',
'source.c',
install: true,
gnu_symbol_visibility: '',
)
```
For the originating example, compare
https://github.com/dwavesystems/dwave-optimization/pull/90/commits/21958780b5745634edee2aedb85930f18f0e5bd1
https://github.com/dwavesystems/dwave-optimization/pull/90/commits/1451e26d5e6eb653e4507e06300800d893c13986
The former [gives](https://app.circleci.com/pipelines/github/dwavesystems/dwave-optimization/227/workflows/be7787e4-56b3-4b33-b8f7-d85a86520185/jobs/6516) (for macos builds on CircleCI)
```
[16/19] c++ -Imodel.cpython-39-darwin.so.p -I. -I.. -I../dwave/optimization/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -fvisibility=hidden -fvisibility-inlines-hidden -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++20 -O3 -g1 -MD -MQ model.cpython-39-darwin.so.p/meson-generated_dwave_optimization_model.pyx.cpp.o -MF model.cpython-39-darwin.so.p/meson-generated_dwave_optimization_model.pyx.cpp.o.d -o model.cpython-39-darwin.so.p/meson-generated_dwave_optimization_model.pyx.cpp.o -c model.cpython-39-darwin.so.p/dwave/optimization/model.pyx.cpp
```
whereas the latter [gives](https://app.circleci.com/pipelines/github/dwavesystems/dwave-optimization/231/workflows/491a9740-ce50-4070-a485-211b85e56b8f/jobs/6627)
```
[16/19] c++ -Imodel.cpython-39-darwin.so.p -I. -I.. -I../dwave/optimization/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -fvisibility=default -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c++20 -O3 -g1 -MD -MQ model.cpython-39-darwin.so.p/meson-generated_dwave_optimization_model.pyx.cpp.o -MF model.cpython-39-darwin.so.p/meson-generated_dwave_optimization_model.pyx.cpp.o.d -o model.cpython-39-darwin.so.p/meson-generated_dwave_optimization_model.pyx.cpp.o -c model.cpython-39-darwin.so.p/dwave/optimization/model.pyx.cpp
```
```
```
**Expected behavior**
It would be nice to have some way to explicitly specify unset. Though I can use `'default'` for now.
**system parameters**
* Native build
* Ubuntu 22.04, as well as in CircleCI macos
* Tested on 3.8-3.12, see
* meson version 1.5.1
* ninja version 1.11.1
Contributor guide
Research direction
Start in mesonbuild/modules/python.py around the linked line 229 and reproduce the issue with the Meson snippet in the report. Compare the generated compiler flags against the expected command shown: completion should preserve an explicitly empty gnu_symbol_visibility rather than replacing it with hidden.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100