-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Avoid executing unnecessary tasks when computing properties for NativeAOT. #123373
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
Conversation
…eAOT. For background: when building iOS projects on Windows, we run 'dotnet build' on the Windows machine, and then run tasks that need to run on the Mac remotely from the Windows machine using our own remoting logic. This has a few requirements/consequences: * Any task that must run remotely must be aware of this fact. Our own tasks can be made aware, external (to the iOS SDK) tasks can't be. * The build will fail in confusing ways if a task is executed on Windows when it shouldn't be. For instance: without this change, building an iOS project on Windows with NativeAOT enabled, will fail because the build fails to run 'xcrun' (which obviously doesn't exist on Windows): > Microsoft.NETCore.Native.Unix.targets(115): error: 'xcrun' not found in PATH. Make sure 'xcrun' is available in PATH. The fix is to avoid running any tasks on Windows: * The 'SetupOSSpecificProps' target runs 'xcrun' to compute the 'SysRoot' property, so avoid running 'xcrun' if 'SysRoot' is already set (which the iOS SDK will do; we already have this value computed). * Add an escape hatch for validating that 'SysRoot' exists (it won't exist on Windows), by setting '_SkipiOSLikePlatformValidation=true'. * Don't get the Xcode version if we don't need it (it's only used to determine if the classic linker should be used, but if 'UseLdClassicXCodeLinker' is already set, then we don't need to know the Xcode version because a decision has already been made). * Don't try to find or validate the presence of a native linker if a native linker isn't needed (when 'NativeLib=Static'). As a side effect this will also make our build on macOS faster, because unnecessary tasks won't be executed. Contributes towards dotnet/macios#21808.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request optimizes the NativeAOT build process for Unix targets, specifically to enable building iOS projects with NativeAOT on Windows and to improve build performance on macOS by avoiding unnecessary task executions.
Changes:
- Skip xcrun and SysRoot-related checks when SysRoot is already set or when validation can be skipped
- Skip Xcode version detection when linker preference is already determined
- Skip all linker validation and detection when building static libraries (NativeLib=Static)
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
We use |
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
Show resolved
Hide resolved
I have no problems changing the property name if that's the consensus :) |
For background: when building iOS projects on Windows, we run 'dotnet build' on the Windows machine, and then run tasks that need to run on the Mac remotely from the Windows machine using our own remoting logic. This has a few requirements/consequences:
For instance: without this change, building an iOS project on Windows with NativeAOT enabled, will fail because the build fails to run 'xcrun' (which obviously doesn't exist on Windows):
The fix is to avoid running any tasks on Windows:
As a side effect this will also make our build on macOS faster, because unnecessary tasks won't be executed.
Contributes towards dotnet/macios#21808.