Skip to content

Update winmake.ps1 to build arm64 artifacts #26048

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
May 5, 2025

Conversation

l0rd
Copy link
Member

@l0rd l0rd commented May 2, 2025

Winmake could only build AMD64 artifacts (podman-remote, gvproxy, win-sshproxy, podman.msi and podman-setup.exe).

This commit makes the necessary change to winmake so that it:

  1. builds ARM64 artifacts when executed on arm64
  2. cross-compiles to ARM64/AMD64 with the -architecture (or -arch) parameter

It depends on #26023, which removes the need to build check.c code (which is not used anyway).

Does this PR introduce a user-facing change?

None

Copy link
Contributor

openshift-ci bot commented May 2, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: l0rd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 2, 2025
winmake.ps1 Outdated
Comment on lines 7 to 16
$defaultArchitecture = "amd64"
# Property `OSArchitecture` of `System.Runtime.InteropServices.RuntimeInformation`
# gets the platform architecture on which the current app is running.
# Possible values are: X86, X64, Arm, Arm64, Wasm, S390x, LoongArch64, Armv6, Ppc64le, RiscV64
# https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.architecture
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
if ($arch -eq "Arm64") {
return "arm64"
} elseif ($arch -eq "X64") {
return "amd64"
} else {
Write-Host "Unsupported architecture $arch. Using default ($defaultArchitecture)."
return $defaultArchitecture
}
Copy link
Member

Choose a reason for hiding this comment

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

you could just run go env GOARCH to get the default golang arch which should match the default platform and then does not need any conversation logic at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good idea—I haven't thought about that. It would make the parameter definition simpler. But if go is not installed, the script will fail: it won't even print the usage or build targets that don't require go.

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 have changed the code to use go env GOARCH as it finally doesn't fail if Go isn't installed but prints an error (and we can catch it and set the default arch).

@l0rd l0rd force-pushed the winmake-arm64-support branch from 5ae3b97 to d3700c8 Compare May 2, 2025 13:08
@ashley-cui
Copy link
Member

ashley-cui commented May 2, 2025

Nit: Can we also support using -arch as a param? Personally, I'm prone to typos and -architecture is long

@l0rd l0rd force-pushed the winmake-arm64-support branch from d3700c8 to 9d11d01 Compare May 2, 2025 16:45
@l0rd
Copy link
Member Author

l0rd commented May 2, 2025

Nit: Can we also support using -arch as a param? Personally, I'm prone to typos and -architecture is long

Makes sense. I have added -arch as an alias. Thank you @ashley-cui

@l0rd l0rd force-pushed the winmake-arm64-support branch from 9d11d01 to c4a537d Compare May 2, 2025 16:55
Winmake could only build amd64 artifacts (podman-remote, gvproxy,
win-sshproxy, podman.msi and podman-setup.exe).

This commit makes the necessary change to winmake so that it:
1) builds arm64 artifacts when executed on arm64
2) cross-compiles to arm64/amd64 with the  `-architecture` parameter

It depends on containers#26023 that
removes the need to build `check.c` code (that is not used anyway).

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
@l0rd l0rd force-pushed the winmake-arm64-support branch from c4a537d to 7fddbd4 Compare May 2, 2025 18:22
@ashley-cui
Copy link
Member

My powershell isn't the best, but LGTM.

@mheon
Copy link
Member

mheon commented May 5, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 5, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 65352aa into containers:main May 5, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants