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

Enable arm64 builds for Linux #4162

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

praveenkumar
Copy link
Member

No description provided.

@openshift-ci openshift-ci bot requested review from anjannath and gbraad May 14, 2024 07:27
Copy link

openshift-ci bot commented May 14, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from praveenkumar. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@praveenkumar
Copy link
Member Author

/hold

packaging/rpm/crc.spec.in Outdated Show resolved Hide resolved
@praveenkumar praveenkumar force-pushed the enable_linux_arm64 branch 2 times, most recently from 933fd76 to d997f4c Compare May 21, 2024 10:51
install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-amd64/crc %{buildroot}%{_bindir}/
%endif
%ifarch aarch64
install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-arm64/crc %{buildroot}%{_bindir}/
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this use go env GOARCH instead of hardcoding these ifarch?

Copy link
Member Author

Choose a reason for hiding this comment

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

didn't find how to run that in the install section? https://community.nethserver.org/t/cross-compiling-multi-arch-rpms/18493 is also suggest same what we are using.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think https://github.com/kovyrin/rpmbuild/blob/master/golang/SPECS/golang.spec#L27-L38 is better what we are having now?

Yes I'd prefer something like this, it's a lot easier to see what is arch-specific, and what is common.

@gbraad
Copy link
Contributor

gbraad commented May 29, 2024

Were other related issues addressed, like arm versions of the helper and driver?

@praveenkumar
Copy link
Member Author

Were other related issues addressed, like arm versions of the helper and driver?

not yet, I will look into this again today, was destructed by 4.15 bundle creation and other issues.

@cfergeau
Copy link
Contributor

cfergeau commented May 29, 2024

was destructed by 4.15 bundle creation

Hopefully you were only distracted ;) ( https://en.wiktionary.org/wiki/destruct )

@gbraad
Copy link
Contributor

gbraad commented Jun 21, 2024

What is the status of this overall? Seems this took a lot more effort than was anticipated.

Makefile Outdated
$(BUILD_DIR)/windows-amd64/crc.exe: $(SOURCES)
GOARCH=amd64 GOOS=windows go build -tags "$(BUILDTAGS)" -ldflags="$(LDFLAGS)" -o $@ $(GO_EXTRA_BUILDFLAGS) ./cmd/crc

$(HOST_BUILD_DIR)/crc-embedder: $(SOURCES)
go build --tags="build" -ldflags="$(LDFLAGS)" -o $(HOST_BUILD_DIR)/crc-embedder $(GO_EXTRA_BUILDFLAGS) ./cmd/crc-embedder

.PHONY: cross ## Cross compiles all binaries
cross: $(BUILD_DIR)/macos-arm64/crc $(BUILD_DIR)/macos-amd64/crc $(BUILD_DIR)/linux-amd64/crc $(BUILD_DIR)/windows-amd64/crc.exe
cross: $(BUILD_DIR)/macos-arm64/crc $(BUILD_DIR)/macos-amd64/crc $(BUILD_DIR)/linux-amd64/crc $(BUILD_DIR)/linux-arm64/crc $(BUILD_DIR)/windows-amd64/crc.exe
Copy link
Contributor

Choose a reason for hiding this comment

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

Not ready for this. Please leave this as a specific target.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, just have specific target not as part of cross.

This pr adds linux arm64 target to makefile and also make change to spec
file to generate right package for arm64.
This is the target which is used as part of `release` and currently
hardcoded to `amd64` which means even this target is run on `arm64`
machine it will still create the `amd64` binary. In spec file also
`release` target is used and for `arm64` builds `amd64` binary is used
without this fix.
ppc64le architecture not supported by OpenShift Local as of now and it
also create confusion because ppc64le package contains the amd64 binary.
admin-helper now have arm64 and amd64 binary for linux platfrom. This PR
will make sure correct binary is downloaded and used for specific
platform.
machine-driver-libvirt now have arm64 and amd64 binary for linux platfrom. This PR
will make sure correct binary is downloaded and used for specific
platform.
Copy link

openshift-ci bot commented Jun 21, 2024

@praveenkumar: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security 52b9be6 link false /test security
ci/prow/e2e-microshift-crc 52b9be6 link true /test e2e-microshift-crc
ci/prow/e2e-crc 52b9be6 link true /test e2e-crc
ci/prow/integration-crc 52b9be6 link true /test integration-crc

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

// Only supported arches are amd64, and arm64 on macOS
if runtime.GOARCH == "amd64" || (runtime.GOARCH == "arm64" && runtime.GOOS == "darwin") {
// Only supported arches are amd64, and arm64 on macOS & Linux
if runtime.GOARCH == "amd64" || (runtime.GOARCH == "arm64" && runtime.GOOS != "windows") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be easier to read as a switch case

switch runtime.GOARCH {
  case "amd64":
    return nil
  case "arm64":
    if runtime.GOOS != "windows" {
        return nil
    }
}

I'd keep explicit linux/darwin checks instead of runtime.GOOS != "windows" to avoid returning nil on freebsd if someone tries that. This also alllow to add a warning for linux/arm64 that it's not widely tested.

// Only supported arches are amd64, and arm64 on macOS
if runtime.GOARCH == "amd64" || (runtime.GOARCH == "arm64" && runtime.GOOS == "darwin") {
// Only supported arches are amd64, and arm64 on macOS & Linux
if runtime.GOARCH == "amd64" || (runtime.GOARCH == "arm64" && runtime.GOOS != "windows") {
return nil
}
return fmt.Errorf("CRC can only run on AMD64/Intel64 CPUs and Apple silicon")
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be updated.

@@ -55,7 +55,7 @@ const (

var adminHelperExecutableForOs = map[string]string{
"darwin": "crc-admin-helper-darwin",
"linux": "crc-admin-helper-linux",
"linux": fmt.Sprintf("crc-admin-helper-linux-%s", runtime.GOARCH),
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a "platfrom" typo in the commit log.
I don't think the old binary name is cleaned up on upgrades?

@@ -30,7 +30,7 @@ Name: %{goname}
Release: 1%{?dist}
Summary: CRC's main executable
License: APL 2.0
ExcludeArch: armv7hl i686
ExcludeArch: armv7hl i686 ppc64le
Copy link
Contributor

Choose a reason for hiding this comment

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

it also create confusion because ppc64le package contains the amd64 binary.

I'd prefer to fix this rather than add artificial hurdles to ppc64le enablement if someone ever wants to try this.

If you add this, you should also remove

# crc uses `go test -race`, which triggers gvisor issues on ppc64le:
# vendor/gvisor.dev/gvisor/pkg/sync/race_unsafe.go:47:6: missing function body
# and a ppc64le implementation is indeed missing on ppc64le:
# https://github.com/google/gvisor/blob/master/pkg/sync/race_unsafe.go
# https://github.com/google/gvisor/tree/master/pkg/sync
%ifnarch ppc64le
make test
%endif

@@ -30,7 +30,7 @@ Name: %{goname}
Release: 1%{?dist}
Summary: CRC's main executable
License: APL 2.0
ExcludeArch: armv7hl i686
ExcludeArch: armv7hl i686 ppc64le
URL: %{gourl}
ExcludeArch: s390x
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this separate?

else
$(HOST_BUILD_DIR)/crc-embedder embed --log-level debug --cache-dir=$(EMBED_DOWNLOAD_DIR) --no-download --goos=linux $(BUILD_DIR)/linux-amd64/crc
$(HOST_BUILD_DIR)/crc-embedder embed --log-level debug --cache-dir=$(EMBED_DOWNLOAD_DIR) --no-download --goos=linux $(BUILD_DIR)/linux-${GOARCH}/crc
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you checked that after the naming changes for crc-admin-helper and crc-driver-libvirt, the embedding process still works fine, and that crc setup is still able to find/use the embedded files (and not download them) if they are not cached locally?
It looks like this should work, but I may have missed something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants