Skip to content
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

Implement building the repo for multiple configurations and architectures with a single command on Windows. #33295

Merged
merged 6 commits into from
Mar 11, 2020

Conversation

jkoritzinsky
Copy link
Member

This change allows developers to specify multiple configurations and architectures to build for in a single command by passing comma-separated lists to each parameter (PowerShell makes it comma separated instead of multiple instances of the option sadly). This feature is currently Windows only unless we also want to add support to the bash script.

For example:

./build -subset coreclr -a x64,arm,x86 -c debug,checked,release

This should enable users of the old ./src/coreclr/build.cmd all ... command to be able to generally keep their workflow when moving to the root script.

cc: @BruceForstall

@jkoritzinsky jkoritzinsky added this to the 5.0 milestone Mar 6, 2020
@jkoritzinsky jkoritzinsky requested a review from a team March 6, 2020 18:09
Copy link
Member

@trylek trylek left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

foreach ($singleArch in $arch) {
$argumentsWithArch = $argumentsWithConfig + " /p:ArchGroup=$singleArch /p:TargetArchitecture=$singleArch"
$env:__DistroRid="win-$singleArch"
Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $argumentsWithArch"
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking nit: would it be possible, at least optionally, to somehow run these in parallel?

Copy link
Member Author

Choose a reason for hiding this comment

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

I’ll check to see if Windows PowerShell supports that.

Copy link
Member

Choose a reason for hiding this comment

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

IMO, this should be a follow-on change, if done.

Copy link
Member Author

Choose a reason for hiding this comment

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

So there's ways to make it run in parallel, but I'm pretty sure that the restore process doesn't support being run in parallel so we'd likely end up with file locking issues during restore (since we'd have multiple different MSBuild processes running in parallel doing the same work).

Copy link
Member

Choose a reason for hiding this comment

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

I'm certainly not asking for implementing it in this PR, I'm just curious. I can easily imagine it's a more complex piece of work.

Copy link
Member

Choose a reason for hiding this comment

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

Presumably the build process is already using maximum machine parallelism, right? At least the compile step is.

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

Personally, I'd like it to always run through all the requested builds, and then report at the very end which ones failed. I'm ok with the current implementation that bails at the first failure, as a starter.

Question: this script is invoked from the root build.cmd. I think cmd.exe likes to eat argument commas, so does a comma-separated list make it to the ps1 file?

Request: update the "help" output to describe this new feature.

@jkoritzinsky
Copy link
Member Author

Personally, I'd like it to always run through all the requested builds, and then report at the very end which ones failed. I'm ok with the current implementation that bails at the first failure, as a starter.

I can change it to run through all requested builds.

Question: this script is invoked from the root build.cmd. I think cmd.exe likes to eat argument commas, so does a comma-separated list make it to the ps1 file?

I went back and tested this again and although cmd doesn't eat the commas, it combines the arguments into one, so powershell sees the comma as part of an argument instead of as a list. I'll need to go figure out how to work around this.

Request: update the "help" output to describe this new feature.

Will do.

@akoeplinger
Copy link
Member

This feature is currently Windows only unless we also want to add support to the bash script.

I'd love to have this in the bash version as well, especially for the Mono iOS/Android builds I'm working on cause I always need to build 3+ architectures there :)

…as to allow scripts to override them with MSBuild arguments.
@jkoritzinsky
Copy link
Member Author

I'll take a look at adding this to the bash script as well after this PR gets in since it's a bit more complex (mainly because of deciding how to handle cross builds).

@BruceForstall
Copy link
Member

I went back and tested this again and although cmd doesn't eat the commas, it combines the arguments into one, so powershell sees the comma as part of an argument instead of as a list. I'll need to go figure out how to work around this.

Example: if I have scripts x.bat:

call y.bat %*

and y.bat:

echo 1:%1 2:%2 3:%3 4:%4 5:%5

and run x -a x86,x64,arm, I see:

1:-a 2:x86 3:x64 4:arm 5:

The commas have disappeared.

eng/build.ps1 Outdated Show resolved Hide resolved
Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

Should we somehow protect this logic in CI?

@jkoritzinsky
Copy link
Member Author

I think the additional load on the machines/additional time for runs of runtime-live-build with testing this in CI is more expensive than the improvement it provides (since it's a relatively rarely used feature). There was never any CI validation of the equivalent feature in coreclr.

@jkoritzinsky jkoritzinsky merged commit 2b27323 into dotnet:master Mar 11, 2020
@jkoritzinsky jkoritzinsky deleted the root-build-all branch March 11, 2020 20:37
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants