Skip to content

Commit 5b4318e

Browse files
committed
Add support to generate aarch64 bits for Linux
This pr adds linux arm64 target to makefile and also make change to spec file to generate right package for arm64.
1 parent 9a55385 commit 5b4318e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ $(BUILD_DIR)/macos-arm64/crc: $(SOURCES)
106106
$(BUILD_DIR)/linux-amd64/crc: $(SOURCES)
107107
GOOS=linux GOARCH=amd64 go build -tags "$(BUILDTAGS)" -ldflags="$(LDFLAGS)" -o $@ $(GO_EXTRA_BUILDFLAGS) ./cmd/crc
108108

109+
$(BUILD_DIR)/linux-arm64/crc: $(SOURCES)
110+
GOOS=linux GOARCH=arm64 go build -tags "$(BUILDTAGS)" -ldflags="$(LDFLAGS)" -o $@ $(GO_EXTRA_BUILDFLAGS) ./cmd/crc
111+
109112
$(BUILD_DIR)/windows-amd64/crc.exe: $(SOURCES)
110113
GOARCH=amd64 GOOS=windows go build -tags "$(BUILDTAGS)" -ldflags="$(LDFLAGS)" -o $@ $(GO_EXTRA_BUILDFLAGS) ./cmd/crc
111114

packaging/rpm/crc.spec.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ CRC's main executable}
1919
%global golicenses LICENSE
2020
%global godocs *.md
2121

22+
%ifarch x86_64
23+
%global gohostarch amd64
24+
%endif
25+
%ifarch aarch64
26+
%global gohostarch arm64
27+
%endif
2228

2329
Name: %{goname}
2430
Release: 1%{?dist}
@@ -65,7 +71,7 @@ make COMMIT_SHA=__COMMIT_SHA__ GO_EXTRA_LDFLAGS="-B 0x$(head -c20 /dev/urandom|o
6571
%install
6672
# with fedora macros: gopkginstall
6773
install -m 0755 -vd %{buildroot}%{_bindir}
68-
install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-amd64/crc %{buildroot}%{_bindir}/
74+
install -m 0755 -vp %{gobuilddir}/src/%{goipath}/out/linux-%{gohostarch}/crc %{buildroot}%{_bindir}/
6975

7076
install -d %{buildroot}%{_datadir}/%{name}-redistributable/{linux,macos,windows}
7177
install -m 0755 -vp %{gobuilddir}/src/%{goipath}/release/* %{buildroot}%{_datadir}/%{name}-redistributable/linux/

pkg/crc/preflight/preflight_checks_unix.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,18 @@ func fixAdminHelperExecutableCached() error {
139139

140140
func checkSupportedCPUArch() error {
141141
logging.Debugf("GOARCH is %s GOOS is %s", runtime.GOARCH, runtime.GOOS)
142-
// Only supported arches are amd64, and arm64 on macOS
143-
if runtime.GOARCH == "amd64" || (runtime.GOARCH == "arm64" && runtime.GOOS == "darwin") {
142+
// Only supported arches are amd64, and arm64 on macOS & Linux
143+
switch runtime.GOARCH {
144+
case "amd64":
144145
return nil
146+
case "arm64":
147+
if runtime.GOOS == "darwin" {
148+
return nil
149+
}
150+
if runtime.GOOS == "linux" {
151+
logging.Warnf("CRC is not officially supported on ARM64 CPUs for Linux.")
152+
return nil
153+
}
145154
}
146155
return fmt.Errorf("CRC can only run on AMD64/Intel64 CPUs and Apple silicon")
147156
}

0 commit comments

Comments
 (0)