aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2022-08-22 09:01:21 -0700
committerDylan Baker <dylan@pnwbakers.com>2023-07-13 11:44:57 -0700
commitd2d31c3cc2c22a4ca1dd6464a6f9ecc40a725f0f (patch)
tree15c38e6bcadba8da227467e5c2ce57f1a0ee80ef
parent3e3d5e97c37a924478aef77806427a68f3f395b6 (diff)
downloadmeson-d2d31c3cc2c22a4ca1dd6464a6f9ecc40a725f0f.zip
meson-d2d31c3cc2c22a4ca1dd6464a6f9ecc40a725f0f.tar.gz
meson-d2d31c3cc2c22a4ca1dd6464a6f9ecc40a725f0f.tar.bz2
macos: map arm64e to aarch64, map "whole" architecture strings
Some macos libraries use arm64e instead of arm64 as architecture. Due to the string replace approach taken so far, we'd end up with aarch64e as architecture, which the rest of meson doesn't know. Move architecture mapping to map whole architecture names and add arm64e -> aarch64 mapping. This change doesn't touch the case for armv7[s], where we add arm, rather than replace armv7[s], but it's certainly not in line with the other mappings. Fixes: #9493 Co-authored-by: Tristan Partin <tristan@partin.io>
-rw-r--r--mesonbuild/utils/universal.py20
-rw-r--r--unittests/darwintests.py5
2 files changed, 19 insertions, 6 deletions
diff --git a/mesonbuild/utils/universal.py b/mesonbuild/utils/universal.py
index db59a60..8cfc04d 100644
--- a/mesonbuild/utils/universal.py
+++ b/mesonbuild/utils/universal.py
@@ -702,15 +702,23 @@ def darwin_get_object_archs(objpath: str) -> 'ImmutableListProtocol[str]':
mlog.debug(f'lipo {objpath}: {stderr}')
return None
stdo = stdo.rsplit(': ', 1)[1]
+
# Convert from lipo-style archs to meson-style CPUs
- stdo = stdo.replace('i386', 'x86')
- stdo = stdo.replace('arm64', 'aarch64')
- stdo = stdo.replace('ppc7400', 'ppc')
- stdo = stdo.replace('ppc970', 'ppc')
+ map_arch = {
+ 'i386': 'x86',
+ 'arm64': 'aarch64',
+ 'arm64e': 'aarch64',
+ 'ppc7400': 'ppc',
+ 'ppc970': 'ppc',
+ }
+ lipo_archs = stdo.split()
+ meson_archs = [map_arch.get(lipo_arch, lipo_arch) for lipo_arch in lipo_archs]
+
# Add generic name for armv7 and armv7s
if 'armv7' in stdo:
- stdo += ' arm'
- return stdo.split()
+ meson_archs.append('arm')
+
+ return meson_archs
def windows_detect_native_arch() -> str:
"""
diff --git a/unittests/darwintests.py b/unittests/darwintests.py
index 254b3d0..1f17760 100644
--- a/unittests/darwintests.py
+++ b/unittests/darwintests.py
@@ -148,3 +148,8 @@ class DarwinTests(BasePlatformTests):
testdir = os.path.join(self.objcpp_test_dir, '1 simple')
self.init(testdir)
self.assertIn('-std=c++14', self.get_compdb()[0]['command'])
+
+ def test_darwin_get_object_archs(self):
+ from mesonbuild.mesonlib import darwin_get_object_archs
+ archs = darwin_get_object_archs('/System/Library/CoreServices/Encodings/libSymbolConverter.dylib')
+ self.assertEqual(archs, ['x86_64', 'aarch64'])