mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.51k stars 1.59k forks source link

User cannot set `gnu_symbol_visibility` to `''` with python `extension_module` #13554

Open arcondello opened 3 weeks ago

arcondello commented 3 weeks ago

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

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 (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

  [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

eli-schwartz commented 3 weeks ago

Meson doesn't have a "null" type, and hence cannot use it to signal "should not use this kwarg". IIRC my original assumption was indeed that people would specify gnu_symbol_visibility: 'default'.

arcondello commented 3 weeks ago

Would there be interest in adding an explicit 'unset' option? I'd be happy to take a crack at the PR. If not, I think 'default' should be OK for us and this issue can be closed. Thanks!