8000 BLD: ensure libnpymath and highway static libs use hidden visibility by rgommers · Pull Request #26286 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BLD: ensure libnpymath and highway static libs use hidden visibility #26286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BLD: ensure libnpymath and highway static libs use hidden visibility
The effect this has is that symbols don't get re-exported as public
by Python extension modules that link with these shared libraries.
E.g., building on macOS arm64 with Clang changes the set of exported
symbols for `_multiarray_umath` from:

```
% dy2ld_info -exports build/numpy/_core/_multiarray_umath.cpython-39-darwin.so
build/numpy/_core/_multiarray_umath.cpython-39-darwin.so [arm64]:
    -exports:
        offset      symbol
        0x00112BA4  _PyInit__multiarray_umath
        0x001C955C  _npy_spacingf
        0x001C95F8  _npy_spacing
        ...
        <many more _npy symbols>
```
to:
```
  build/numpy/_core/_multiarray_umath.cpython-311-darwin.so [arm64]:
    -exports:
        offset      symbol
        0x0010B8F8  _PyInit__multiarray_umath
```

This works for all compilers that support GNU-style
`__attribute__((visibility("hidden"))`, which both GCC and Clang do.

Note that the `libnpyrandom` static library is left alone here. Trying
to change visibility there breaks a test for CFFI, because that test
is accessing private symbols. This is clearly wrong, but explicitly
documented at
https://numpy.org/devdocs/reference/random/extending.html#cffi. So
leaving that alone here. `libnpyrandom` isn't used by SciPy anymore
and may well have zero users left, so it's not critical.
  • Loading branch information
rgommers committed Apr 16, 2024
commit 84f283a5ab2564a50c4e7a295d36280fc579930e
4 changes: 3 additions & 1 deletion numpy/_core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ if use_highway
],
cpp_args: '-DTOOLCHAIN_MISS_ASM_HWCAP_H',
include_directories: ['src/highway'],
install: false
install: false,
gnu_symbol_visibility: 'hidden',
)
else
highway_lib = []
Expand Down Expand Up @@ -561,6 +562,7 @@ npymath_lib = static_library('npymath',
install_dir: np_dir / '_core/lib',
name_prefix: name_prefix_staticlib,
name_suffix: name_suffix_staticlib,
gnu_symbol_visibility: 'hidden',
)

dir_separator = '/'
Expand Down
0