-
Notifications
You must be signed in to change notification settings - Fork 232
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
/hold |
933fd76
to
d997f4c
Compare
packaging/rpm/crc.spec.in
Outdated
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}/ |
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.
Could this use go env GOARCH
instead of hardcoding these ifarch
?
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.
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.
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.
Do you think https://github.com/kovyrin/rpmbuild/blob/master/golang/SPECS/golang.spec#L27-L38 is better what we are having now?
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.
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.
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. |
d997f4c
to
757f0c2
Compare
Hopefully you were only distracted ;) ( https://en.wiktionary.org/wiki/destruct ) |
757f0c2
to
db12a15
Compare
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 |
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.
Not ready for this. Please leave this as a specific target.
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.
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.
db12a15
to
52b9be6
Compare
@praveenkumar: The following tests failed, say
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") { |
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.
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") |
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.
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), |
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.
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 |
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.
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 |
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.
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 |
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.
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.
No description provided.