Skip to content

Fix cross-compile build failure. #75970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ function Build-FoundationMacros() {

$SwiftSDK = $null
if ($Build) {
$SwiftSDK = $HostArch.SDKInstallRoot
$SwiftSDK = $BuildArch.SDKInstallRoot
}

$Targets = if ($Build) {
Expand All @@ -1766,6 +1766,12 @@ function Build-FoundationMacros() {
$InstallDir = "$($Arch.ToolchainInstallRoot)\usr"
}

$SwiftSyntaxCMakeModules = if ($Build -and $HostArch -ne $BuildArch) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not get away with if ($Build)? We will have the host build for distribution anyway.

Copy link
Contributor Author

@hjyamauchi hjyamauchi Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because SwiftSyntax is built part of Build-Compilers and in a normal (not cross-compiling) build, we only build in the host-arch binary cache (Get-HostProjectCMakeModules Compilers) and the build-arch binary cache (Get-BuildProjectCMakeModules Compilers) would be empty. If we just have if ($Build), we would look for the SwiftSyntax build artifacts in the empty location. It's true that we build FoundationMacros twice and both for the build-arch and host-arch binary caches. But this is about its dependency SwiftSyntax.

Get-BuildProjectCMakeModules Compilers
} else {
Get-HostProjectCMakeModules Compilers
}

Build-CMakeProject `
-Src $SourceCache\swift-foundation\Sources\FoundationMacros `
-Bin $FoundationMacrosBinaryCache `
Expand All @@ -1776,7 +1782,7 @@ function Build-FoundationMacros() {
-SwiftSDK:$SwiftSDK `
-BuildTargets $Targets `
-Defines @{
SwiftSyntax_DIR = (Get-HostProjectCMakeModules Compilers);
SwiftSyntax_DIR = $SwiftSyntaxCMakeModules;
}
}

Expand Down