Skip to content

Commit

Permalink
[swarming] Use armv7l for most 32-bit ARM on NetBSD
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bsiegert authored and LUCI CQ committed Oct 22, 2024
1 parent 6f04345 commit d8d38ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions appengine/swarming/swarming_bot/api/os_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ def get_cpu_type():
# platform.machine() returns the aix machine ID (uname -m), which is
# not useful. Modern AIX only supports powerpc64.
return 'ppc64'
elif sys.platform.startswith('netbsd') and platform.machine() == 'evbarm':
# NetBSD has multiple ARM sub-platforms.
processor = platform.processor().lower()
if processor == 'aarch64':
return 'arm64'
# The following are not quite accurate, since there are also big-endian
# variants. E.g. earmv7hfeb is ARMv7, hardware FPU, big-endian.
if processor.startswith('earmv6'):
return 'armv6l'
if processor.startswith('earmv'):
return 'armv7l'
machine = platform.machine().lower()
if machine in ('amd64', 'x86_64', 'i386', 'i686', 'i86pc'):
return 'x86'
Expand Down Expand Up @@ -317,6 +328,8 @@ def get_cipd_architecture():
if cpu_type == 'x86':
return 'amd64' if get_cpu_bitness() == '64' else '386'
if cpu_type.startswith('armv') and cpu_type.endswith('l'):
if get_cipd_os() == 'netbsd':
return cpu_type
# 32-bit ARM: Standardize on ARM v6 baseline.
return 'armv6l'
if cpu_type == 'evbarm': # NetBSD's name for ARM, both 32 and 64-bit
Expand Down
13 changes: 13 additions & 0 deletions appengine/swarming/swarming_bot/api/os_utilities_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ def test_get_cipd_architecture(self):
self.mock(os_utilities, 'get_cpu_bitness', lambda: bitness)
self.assertEqual(os_utilities.get_cipd_architecture(), expected)

def test_get_cipd_architecture_netbsd(self):
cases = [
('amd64', 'x86_64', 'amd64'),
('evbarm', 'aarch64', 'arm64'),
('evbarm', 'earmv6hf', 'armv6l'),
('evbarm', 'earmv7hf', 'armv7l'),
]
for machine, processor, expected in cases:
self.mock(sys, 'platform', 'netbsd10')
self.mock(platform, 'machine', lambda: machine)
self.mock(platform, 'processor', lambda: processor)
self.assertEqual(os_utilities.get_cipd_architecture(), expected)

def test_get_os_values(self):
cases = [
('openbsd7', '7.2', ['openbsd', 'openbsd-7', 'openbsd-7.2']),
Expand Down

0 comments on commit d8d38ee

Please sign in to comment.