Skip to content

Commit 485f566

Browse files
authored
pipeline: Run proper cross compile host (#8304)
The build-using-self script was always using macos arm64 as a cross compile host. Modify the build-using-self's cross compile host to use x86_64 when on ARM, arm64 when on x86_64, and raise an exception when an any other architecture.
1 parent 54286a8 commit 485f566

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Utilities/build-using-self

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ logging.basicConfig(
5151
REPO_ROOT_PATH = pathlib.Path(__file__).parent.parent.resolve()
5252

5353

54+
class UnsupportedArchitecture(Exception):
55+
56+
pass
57+
58+
5459
def get_arguments() -> argparse.Namespace:
5560
parser = argparse.ArgumentParser(
5661
formatter_class=argparse.ArgumentDefaultsHelpFormatter
@@ -128,7 +133,7 @@ def get_swiftpm_bin_dir(config: Configuration) -> pathlib.Path:
128133

129134

130135
def is_on_darwin() -> bool:
131-
return platform.uname().system == "Darwin"
136+
return platform.system() == "Darwin"
132137

133138

134139
def set_environment(
@@ -148,14 +153,23 @@ def set_environment(
148153
def run_bootstrap(swiftpm_bin_dir: pathlib.Path) -> None:
149154
logging.info("Current working directory is %s", pathlib.Path.cwd())
150155
logging.info("Bootstrapping with the XCBuild codepath...")
156+
cross_compile_arch: str
157+
arch = platform.machine()
158+
if arch == "arm64":
159+
cross_compile_arch = "x86_64"
160+
elif arch == "x86_64":
161+
cross_compile_arch = "arm64"
162+
else:
163+
raise UnsupportedArchitecture(f"Architecture {arch} is not supported.")
164+
151165
call(
152166
[
153167
REPO_ROOT_PATH / "Utilities" / "bootstrap",
154168
"build",
155169
"--release",
156170
"--verbose",
157171
"--cross-compile-hosts",
158-
"macosx-arm64",
172+
f"macosx-{cross_compile_arch}",
159173
"--skip-cmake-bootstrap",
160174
"--swift-build-path",
161175
(swiftpm_bin_dir / "swift-build").resolve(),

0 commit comments

Comments
 (0)