Skip to content

Commit

Permalink
feat: --cross-compiling overrides arch-specific settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Nov 16, 2020
1 parent 1ad39a1 commit a910a9f
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions pylib/gyp/xcode_emulation.py
Original file line number Diff line number Diff line change
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 a910a9f

Please sign in to comment.