diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2024-06-18 16:22:15 +0200 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-06-18 12:43:07 -0400 |
commit | bcbf0685492c61fbc9acac3e7b808a5036dd2439 (patch) | |
tree | 1bac6a8bf008c87ee9d1740fdac0c491f3094d5f | |
parent | a3d3efd3cfc6e9b0ce8a7536527e1e9ca134f80a (diff) | |
download | meson-bcbf0685492c61fbc9acac3e7b808a5036dd2439.zip meson-bcbf0685492c61fbc9acac3e7b808a5036dd2439.tar.gz meson-bcbf0685492c61fbc9acac3e7b808a5036dd2439.tar.bz2 |
Improve `nm` usage in symbolextractor script on macOS
This fixes the unit test `TestAllPlatformTests.test_noop_changes_cause_no_rebuilds`,
when run with an `nm` binary from `cctools-port` (as shipped by conda-forge, see
https://github.com/conda-forge/cctools-and-ld64-feedstock).
It also addresses the issue discussed in https://github.com/mesonbuild/meson/discussions/11131,
and this build warning:
```
[48/1383] Generating symbol file scipy/special/libsf_error_state.dylib.p/libsf_error_state.dylib.symbols
WARNING: ['arm64-apple-darwin20.0.0-nm'] does not work. Relinking will always happen on source changes.
error: arm64-apple-darwin20.0.0-nm: invalid argument --
```
as reported in scipy#20740.
The unit test traceback was:
```
> self.assertBuildRelinkedOnlyTarget('mylib')
E AssertionError: Lists differ: ['mylib', 'prog'] != ['mylib']
E
E First list contains 1 additional elements.
E First extra element 1:
E 'prog'
E
E - ['mylib', 'prog']
E + ['mylib']
unittests/allplatformstests.py:1292: AssertionError
```
The `nm` shipped by Apple yields the exact same results either way; the man page for `nm`
only lists the single-character form so this seems preferred either way.
-rw-r--r-- | mesonbuild/scripts/symbolextractor.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py index 52b9b80..5c45253 100644 --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -134,9 +134,10 @@ def osx_syms(libfilename: str, outfilename: str) -> None: match = i break result = [arr[match + 2], arr[match + 5]] # Libreoffice stores all 5 lines but the others seem irrelevant. - # Get a list of all symbols exported - output = call_tool('nm', ['--extern-only', '--defined-only', - '--format=posix', libfilename]) + # Get a list of all symbols exported. `nm -g -U -P` is equivalent to, and more portable than, + # `nm --extern-only --defined-only --format=posix`; cctools-port only understands the one-character form, + # as does `nm` on very old macOS versions, (see meson#11131). `llvm-nm` understands both forms. + output = call_tool('nm', ['-g', '-U', '-P', libfilename]) if not output: dummy_syms(outfilename) return |