Skip to content

Commit 4287a42

Browse files
committed
feat(xcode): --cross-compiling overrides arch-specific settings
1 parent 1ad39a1 commit 4287a42

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

pylib/gyp/xcode_emulation.py

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -654,28 +654,32 @@ def GetCflags(self, configname, arch=None):
654654
self._WarnUnimplemented("MACH_O_TYPE")
655655
self._WarnUnimplemented("PRODUCT_TYPE")
656656

657-
if arch is not None:
658-
archs = [arch]
659-
else:
660-
assert self.configname
661-
archs = self.GetActiveArchs(self.configname)
662-
if len(archs) != 1:
663-
# TODO: Supporting fat binaries will be annoying.
664-
self._WarnUnimplemented("ARCHS")
665-
archs = ["i386"]
666-
cflags.append("-arch " + archs[0])
667-
668-
if archs[0] in ("i386", "x86_64"):
669-
if self._Test("GCC_ENABLE_SSE3_EXTENSIONS", "YES", default="NO"):
670-
cflags.append("-msse3")
671-
if self._Test(
672-
"GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS", "YES", default="NO"
673-
):
674-
cflags.append("-mssse3") # Note 3rd 's'.
675-
if self._Test("GCC_ENABLE_SSE41_EXTENSIONS", "YES", default="NO"):
676-
cflags.append("-msse4.1")
677-
if self._Test("GCC_ENABLE_SSE42_EXTENSIONS", "YES", default="NO"):
678-
cflags.append("-msse4.2")
657+
# If GYP_CROSSCOMPILE (--cross-compiling), disable architecture-specific
658+
# additions and assume these will be provided as required via CC_host,
659+
# CXX_host, CC_target and CXX_target.
660+
if not gyp.common.CrossCompileRequested():
661+
if arch is not None:
662+
archs = [arch]
663+
else:
664+
assert self.configname
665+
archs = self.GetActiveArchs(self.configname)
666+
if len(archs) != 1:
667+
# TODO: Supporting fat binaries will be annoying.
668+
self._WarnUnimplemented("ARCHS")
669+
archs = ["i386"]
670+
cflags.append("-arch " + archs[0])
671+
672+
if archs[0] in ("i386", "x86_64"):
673+
if self._Test("GCC_ENABLE_SSE3_EXTENSIONS", "YES", default="NO"):
674+
cflags.append("-msse3")
675+
if self._Test(
676+
"GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS", "YES", default="NO"
677+
):
678+
cflags.append("-mssse3") # Note 3rd 's'.
679+
if self._Test("GCC_ENABLE_SSE41_EXTENSIONS", "YES", default="NO"):
680+
cflags.append("-msse4.1")
681+
if self._Test("GCC_ENABLE_SSE42_EXTENSIONS", "YES", default="NO"):
682+
cflags.append("-msse4.2")
679683

680684
cflags += self._Settings().get("WARNING_CFLAGS", [])
681685

@@ -938,16 +942,17 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None):
938942
+ gyp_to_build_path(self._Settings()["ORDER_FILE"])
939943
)
940944

941-
if arch is not None:
942-
archs = [arch]
943-
else:
944-
assert self.configname
945-
archs = self.GetActiveArchs(self.configname)
946-
if len(archs) != 1:
947-
# TODO: Supporting fat binaries will be annoying.
948-
self._WarnUnimplemented("ARCHS")
949-
archs = ["i386"]
950-
ldflags.append("-arch " + archs[0])
945+
if not gyp.common.CrossCompileRequested():
946+
if arch is not None:
947+
archs = [arch]
948+
else:
949+
assert self.configname
950+
archs = self.GetActiveArchs(self.configname)
951+
if len(archs) != 1:
952+
# TODO: Supporting fat binaries will be annoying.
953+
self._WarnUnimplemented("ARCHS")
954+
archs = ["i386"]
955+
ldflags.append("-arch " + archs[0])
951956

952957
# Xcode adds the product directory by default.
953958
# Rewrite -L. to -L./ to work around http://www.openradar.me/25313838

0 commit comments

Comments
 (0)