X Tutup
Skip to content

Commit 4073aaa

Browse files
committed
Allow arm64 to fallback to arm (v8, v7, v6, v5)
This isn't supported by *all* arm64 chips, but it is common enough that I think it's worth an explicit fallback. I think it will be more common for images to have arm64 support without arm support, but even if a user has an arm64 chip that does not support arm32, having it fail to run the arm32 image is an acceptable compromise (because it's non-trivial to detect arm32 support without running a binary, AFAIK). Also, before this change the failure would've simply been "no such image" instead of "failed to run" so I think it's pretty reasonable to allow it to try the additional 32bit set of images just in case one of them actually does work (like it will on many popular chips like 64bit Raspberry Pis and AWS Graviton). Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
1 parent 124fc14 commit 4073aaa

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

platforms/compare.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ func platformVector(platform specs.Platform) []specs.Platform {
5757
})
5858
}
5959
}
60+
case "arm64":
61+
variant := platform.Variant
62+
if variant == "" {
63+
variant = "v8"
64+
}
65+
vector = append(vector, platformVector(specs.Platform{
66+
Architecture: "arm",
67+
OS: platform.OS,
68+
OSVersion: platform.OSVersion,
69+
OSFeatures: platform.OSFeatures,
70+
Variant: variant,
71+
})...)
6072
}
6173

6274
return vector

platforms/compare_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ func TestOnly(t *testing.T) {
166166
platform: "linux/arm64",
167167
matches: map[bool][]string{
168168
true: {
169+
"linux/arm",
170+
"linux/arm/v5",
171+
"linux/arm/v6",
172+
"linux/arm/v7",
173+
"linux/arm/v8",
169174
"linux/arm64",
170175
"linux/arm64/v8",
171176
},
172177
false: {
173178
"linux/amd64",
174-
"linux/arm",
175179
"linux/arm/v4",
176-
"linux/arm/v5",
177-
"linux/arm/v6",
178-
"linux/arm/v7",
179-
"linux/arm/v8",
180180
"linux/arm/v9",
181181
"linux/arm64/v9",
182182
"windows/amd64",

platforms/cpuinfo.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ func getCPUVariant() string {
107107

108108
switch strings.ToLower(variant) {
109109
case "8", "aarch64":
110-
// special case: if running a 32-bit userspace on aarch64, the variant should be "v7"
111-
if runtime.GOARCH == "arm" {
112-
variant = "v7"
113-
} else {
114-
variant = "v8"
115-
}
110+
variant = "v8"
116111
case "7", "7m", "?(12)", "?(13)", "?(14)", "?(15)", "?(16)", "?(17)":
117112
variant = "v7"
118113
case "6", "6tej":

0 commit comments

Comments
 (0)
X Tutup