aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
diff options
context:
space:
mode:
authorAlbert Tang <tangalbert919@yahoo.com>2023-07-28 10:02:50 -0500
committerEli Schwartz <eschwartz93@gmail.com>2024-01-26 00:42:24 -0500
commitd2740cf0d1ce049bb77da24e0a620292b7ff424d (patch)
tree6932033afd60eb24e043d6b33c73c799ad66ac0b /mesonbuild/backend
parentd7bf365acdadf6bb5a456bbe405132cd17c3e5af (diff)
downloadmeson-d2740cf0d1ce049bb77da24e0a620292b7ff424d.zip
meson-d2740cf0d1ce049bb77da24e0a620292b7ff424d.tar.gz
meson-d2740cf0d1ce049bb77da24e0a620292b7ff424d.tar.bz2
xcode: Autodetect host machine's CPU architecture
Currently, the backend has "x86_64" hardcoded as the architecture, which breaks cross compiling and compiling normally on arm64. Fix this by setting it to the host machine's CPU architecture instead.
Diffstat (limited to 'mesonbuild/backend')
-rw-r--r--mesonbuild/backend/xcodebackend.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index 6cb7f3f..989b2bf 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -195,6 +195,9 @@ class XCodeBackend(backends.Backend):
self.regen_dependency_id = self.gen_id()
self.top_level_dict = PbxDict()
self.generator_outputs = {}
+ self.arch = self.build.environment.machines.host.cpu
+ if self.arch == 'aarch64':
+ self.arch = 'arm64'
# In Xcode files are not accessed via their file names, but rather every one of them
# gets an unique id. More precisely they get one unique id per target they are used
# in. If you generate only one id per file and use them, compilation will work but the
@@ -233,11 +236,10 @@ class XCodeBackend(backends.Backend):
project = self.build.project_name
buildtype = self.buildtype
tname = target.get_id()
- arch = 'x86_64'
if isinstance(source, mesonlib.File):
source = source.fname
stem = os.path.splitext(os.path.basename(source))[0]
- obj_path = f'{project}.build/{buildtype}/{tname}.build/Objects-normal/{arch}/{stem}.o'
+ obj_path = f'{project}.build/{buildtype}/{tname}.build/Objects-normal/{self.arch}/{stem}.o'
return obj_path
def determine_swift_dep_dirs(self, target: build.BuildTarget) -> T.List[str]:
@@ -1391,7 +1393,7 @@ class XCodeBackend(backends.Backend):
bt_dict.add_item('isa', 'XCBuildConfiguration')
settings_dict = PbxDict()
bt_dict.add_item('buildSettings', settings_dict)
- settings_dict.add_item('ARCHS', '"$(NATIVE_ARCH_ACTUAL)"')
+ settings_dict.add_item('ARCHS', f'"{self.arch}"')
settings_dict.add_item('ONLY_ACTIVE_ARCH', 'YES')
settings_dict.add_item('SWIFT_VERSION', '5.0')
settings_dict.add_item('SDKROOT', '"macosx"')
@@ -1435,7 +1437,7 @@ class XCodeBackend(backends.Backend):
bt_dict.add_item('isa', 'XCBuildConfiguration')
settings_dict = PbxDict()
bt_dict.add_item('buildSettings', settings_dict)
- settings_dict.add_item('ARCHS', '"$(NATIVE_ARCH_ACTUAL)"')
+ settings_dict.add_item('ARCHS', f'"{self.arch}"')
settings_dict.add_item('ONLY_ACTIVE_ARCH', 'YES')
settings_dict.add_item('SDKROOT', '"macosx"')
settings_dict.add_item('SYMROOT', '"%s/build"' % self.environment.get_build_dir())