Skip to content

Commit

Permalink
feat(xcode): --cross-compiling overrides arch-specific settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg authored and gengjiawen committed Dec 17, 2020
1 parent fc22f83 commit 973bae0
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions pylib/gyp/xcode_emulation.py
Expand Up @@ -654,28 +654,32 @@ def GetCflags(self, configname, arch=None):
self._WarnUnimplemented("MACH_O_TYPE")
self._WarnUnimplemented("PRODUCT_TYPE")

if arch is not None:
archs = [arch]
else:
assert self.configname
archs = self.GetActiveArchs(self.configname)
if len(archs) != 1:
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented("ARCHS")
archs = ["i386"]
cflags.append("-arch " + archs[0])

if archs[0] in ("i386", "x86_64"):
if self._Test("GCC_ENABLE_SSE3_EXTENSIONS", "YES", default="NO"):
cflags.append("-msse3")
if self._Test(
"GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS", "YES", default="NO"
):
cflags.append("-mssse3") # Note 3rd 's'.
if self._Test("GCC_ENABLE_SSE41_EXTENSIONS", "YES", default="NO"):
cflags.append("-msse4.1")
if self._Test("GCC_ENABLE_SSE42_EXTENSIONS", "YES", default="NO"):
cflags.append("-msse4.2")
# If GYP_CROSSCOMPILE (--cross-compiling), disable architecture-specific
# additions and assume these will be provided as required via CC_host,
# CXX_host, CC_target and CXX_target.
if not gyp.common.CrossCompileRequested():
if arch is not None:
archs = [arch]
else:
assert self.configname
archs = self.GetActiveArchs(self.configname)
if len(archs) != 1:
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented("ARCHS")
archs = ["i386"]
cflags.append("-arch " + archs[0])

if archs[0] in ("i386", "x86_64"):
if self._Test("GCC_ENABLE_SSE3_EXTENSIONS", "YES", default="NO"):
cflags.append("-msse3")
if self._Test(
"GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS", "YES", default="NO"
):
cflags.append("-mssse3") # Note 3rd 's'.
if self._Test("GCC_ENABLE_SSE41_EXTENSIONS", "YES", default="NO"):
cflags.append("-msse4.1")
if self._Test("GCC_ENABLE_SSE42_EXTENSIONS", "YES", default="NO"):
cflags.append("-msse4.2")

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

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

if arch is not None:
archs = [arch]
else:
assert self.configname
archs = self.GetActiveArchs(self.configname)
if len(archs) != 1:
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented("ARCHS")
archs = ["i386"]
ldflags.append("-arch " + archs[0])
if not gyp.common.CrossCompileRequested():
if arch is not None:
archs = [arch]
else:
assert self.configname
archs = self.GetActiveArchs(self.configname)
if len(archs) != 1:
# TODO: Supporting fat binaries will be annoying.
self._WarnUnimplemented("ARCHS")
archs = ["i386"]
ldflags.append("-arch " + archs[0])

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

0 comments on commit 973bae0

Please sign in to comment.