This is an archive of the discontinued LLVM Phabricator instance.

Introduce options for Windows packaging script
ClosedPublic

Authored by pbo-linaro on Oct 5 2022, 4:16 AM.

Details

Summary

Options:
--version: [required] version to build
--help: display this help
--x86: build and test x86 variant
--x64: build and test x64 variant

Note: At least one variant to build is required.

Example: build_llvm_release.bat --version 15.0.0 --x64

Diff Detail

Event Timeline

pbo-linaro created this revision.Oct 5 2022, 4:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 4:16 AM
Herald added a subscriber: pengfei. · View Herald Transcript
pbo-linaro requested review of this revision.Oct 5 2022, 4:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 4:16 AM
thieta added a subscriber: thieta.Oct 5 2022, 11:36 PM

I wonder if we shouldn't just build both archs if nothing is specified to keep the old behavior.

llvm/utils/release/build_llvm_release.bat
13

Not sure I like --revision here. I would probably use --version instead.

pbo-linaro marked an inline comment as done.Oct 6 2022, 12:18 AM

I wonder if we shouldn't just build both archs if nothing is specified to keep the old behavior.

The first goal of all those patches, beyond cleanup, is to add arm64 support to this script.
Alas, it can't be run from an x64 machine (build yes, but not tests).
I think making explicit which targets you want is a better choice than enabling only two of the three targets.

I can still change to:

  • nothing: x86 + x64
  • add arm64 later, but not activated by default

Depends on your taste, I'm open to what you prefer :)

llvm/utils/release/build_llvm_release.bat
13

I'll switch back to version

pbo-linaro marked an inline comment as done.Oct 6 2022, 12:27 AM

I can still change to:

  • nothing: x86 + x64
  • add arm64 later, but not activated by default

I'll be happy with this. But I wonder what @hans thinks?

+CarlosAlbertoEnciso who also worked on this script recently.

I can still change to:

  • nothing: x86 + x64
  • add arm64 later, but not activated by default

I'll be happy with this. But I wonder what @hans thinks?

I think the other option would be to detect what platform we're on, and build x86+x64 or arm64 depending on that.

But having less magic is also good, so just having to pass the flags sounds good to me.

I'm more in favor of less magic, and more explicit.
For giving more context, a lot of projects are relying on platform detection to compile things for Windows on Arm, and frankly, it's a pain.
Most are using python (platform.machine()), which changes depending if you execute an x64 or arm64 interpreter.
So, depending on which python you install, you're not targeting exactly what you expect.
The env var PROCESSOR_ARCHITECTURE can be different too, depending if you use powershell.exe, or cmd.exe. Nice.

Being able to say clearly "this is what is expected" is a good property.
When requesting this from user, IMHO, the *important* is that the script stops (and fails) and asks you exactly what you want:

43 echo choose one or several variants from: --x86 --x64
44 exit /b 1

So, you don't have to dig in script internals to understand what is done/expected.

thieta added a comment.Oct 6 2022, 3:13 AM

I am fine with being explicit as well.

pbo-linaro updated this revision to Diff 465688.Oct 6 2022, 3:31 AM

Replaced --revision by --version.

pbo-linaro edited the summary of this revision. (Show Details)Oct 6 2022, 3:31 AM
pbo-linaro updated this revision to Diff 465693.Oct 6 2022, 3:44 AM

Fix conflict with 7zip version evaluation (same variable was used)

hans added a comment.Oct 6 2022, 3:46 AM

Basically lgtm, just some nitty comments.

llvm/utils/release/build_llvm_release.bat
20

Maybe we should add --x86 to the example too, just to highlight that more than one can be used?

41

The if .. if syntax looks funny. Is this a batch thing?

44

Is it intentional that for missing version we goto usage, but for missing build variant we just print and exit?

pbo-linaro updated this revision to Diff 465696.Oct 6 2022, 3:53 AM

Added --x86 to example, to show that several arch can be built with a single command.

pbo-linaro marked an inline comment as done.Oct 6 2022, 3:58 AM
pbo-linaro added inline comments.
llvm/utils/release/build_llvm_release.bat
41

batch IF does not have "and" operator.
https://stackoverflow.com/questions/2143187/logical-operators-and-or-in-dos-batch

I agree that's funny. If someone has a better syntax, I'll take it happily :)

44

That was chosen to avoid showing full help in this case (user will focus on latest lines, which is not the error).
Tried adding a separator, like "=======================", but it's not visual enough to focus attention IMHO.

hans accepted this revision.Oct 6 2022, 3:59 AM

lgtm

This revision is now accepted and ready to land.Oct 6 2022, 3:59 AM
pbo-linaro added inline comments.Oct 6 2022, 4:01 AM
llvm/utils/release/build_llvm_release.bat
44

To be more clear regarding your question, workflow for user will be:
1- try the script without args => show usage
2- "Oh, version is required" => call script with --version XXX
3- Instead of printing full help (user already saw it), just tell me is missing an arch.

@thieta Does that patch looks good to you?

If yes, would that be possible to merge it please?

thieta accepted this revision.Oct 20 2022, 4:51 AM

LGTM - sorry for the delay. Want me to merge this?

pbo-linaro marked 2 inline comments as done.Oct 20 2022, 4:53 AM

No problem, thanks very much for coming back :)

That would be very nice if you could merge it. Thanks.
Same applies for the other patch (VS detection).

This revision was landed with ongoing or failed builds.Oct 20 2022, 5:13 AM
This revision was automatically updated to reflect the committed changes.

Landed this.

Same applies for the other patch (VS detection).

That seems already landed.