Skip to content

Commit d8d38ee

Browse files
bsiegertLUCI CQ
authored and
LUCI CQ
committed
[swarming] Use armv7l for most 32-bit ARM on NetBSD
For the purposes of the Go netbsd-arm builder, we need to be able to distinguish ARMv6 from later (v7+) architectures. Only ARMv7 has the synchronization instructions that allow Go binaries to run on multi-core machines. This special-cases the 'netbsd' OS type to return armv7l for 32-bit ARMv7 machines. I have not added FreeBSD and OpenBSD support since their values for machine and processor are a bit different. Part of golang/go#63698 Change-Id: I798c7ec459b453ebfbc6bf2912f1bd06b8919325 Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-py/+/5943105 Reviewed-by: Vadim Shtayura <[email protected]> Commit-Queue: Benny Siegert <[email protected]>
1 parent 6f04345 commit d8d38ee

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

appengine/swarming/swarming_bot/api/os_utilities.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ def get_cpu_type():
249249
# platform.machine() returns the aix machine ID (uname -m), which is
250250
# not useful. Modern AIX only supports powerpc64.
251251
return 'ppc64'
252+
elif sys.platform.startswith('netbsd') and platform.machine() == 'evbarm':
253+
# NetBSD has multiple ARM sub-platforms.
254+
processor = platform.processor().lower()
255+
if processor == 'aarch64':
256+
return 'arm64'
257+
# The following are not quite accurate, since there are also big-endian
258+
# variants. E.g. earmv7hfeb is ARMv7, hardware FPU, big-endian.
259+
if processor.startswith('earmv6'):
260+
return 'armv6l'
261+
if processor.startswith('earmv'):
262+
return 'armv7l'
252263
machine = platform.machine().lower()
253264
if machine in ('amd64', 'x86_64', 'i386', 'i686', 'i86pc'):
254265
return 'x86'
@@ -317,6 +328,8 @@ def get_cipd_architecture():
317328
if cpu_type == 'x86':
318329
return 'amd64' if get_cpu_bitness() == '64' else '386'
319330
if cpu_type.startswith('armv') and cpu_type.endswith('l'):
331+
if get_cipd_os() == 'netbsd':
332+
return cpu_type
320333
# 32-bit ARM: Standardize on ARM v6 baseline.
321334
return 'armv6l'
322335
if cpu_type == 'evbarm': # NetBSD's name for ARM, both 32 and 64-bit

appengine/swarming/swarming_bot/api/os_utilities_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ def test_get_cipd_architecture(self):
8181
self.mock(os_utilities, 'get_cpu_bitness', lambda: bitness)
8282
self.assertEqual(os_utilities.get_cipd_architecture(), expected)
8383

84+
def test_get_cipd_architecture_netbsd(self):
85+
cases = [
86+
('amd64', 'x86_64', 'amd64'),
87+
('evbarm', 'aarch64', 'arm64'),
88+
('evbarm', 'earmv6hf', 'armv6l'),
89+
('evbarm', 'earmv7hf', 'armv7l'),
90+
]
91+
for machine, processor, expected in cases:
92+
self.mock(sys, 'platform', 'netbsd10')
93+
self.mock(platform, 'machine', lambda: machine)
94+
self.mock(platform, 'processor', lambda: processor)
95+
self.assertEqual(os_utilities.get_cipd_architecture(), expected)
96+
8497
def test_get_os_values(self):
8598
cases = [
8699
('openbsd7', '7.2', ['openbsd', 'openbsd-7', 'openbsd-7.2']),

0 commit comments

Comments
 (0)