MemsetBenchmark.cpp: .align 64 is invalid on macOS x86_64 (Apple assembler interprets as 2^64)
Summary
folly/test/MemsetBenchmark.cpp uses inline assembly with the .align 64 directive, which is invalid on macOS x86_64. The Apple assembler interprets .align N as "align to 2^N bytes" (power-of-2 exponent), while Linux GAS interprets it as "align to N bytes" directly. So .align 64 on macOS attempts to align to 2^64 bytes, which fails.
Motivation
This causes build failures on macOS x86_64 (Intel Macs) when folly's test targets are compiled. The error manifests as:
folly/test/MemsetBenchmark.cpp:44:20: error: invalid alignment value
44 | __asm__ volatile(".align 64\n");
| ^
<inline asm>:1:9: note: instantiated into assembly here
1 | .align 64
| ^
error: cannot encode offset of relocations; object file too largeThis affects any downstream consumer that builds folly with tests enabled on macOS x86_64 — for example, Nixpkgs' watchman derivation, which depends on folly and builds its test targets.
Apple Silicon (aarch64) is unaffected because the offending code is guarded by #if !defined(__aarch64__).
Proposed solution
Replace .align 64 with .balign 64. The .balign directive unambiguously means "align to N bytes" on both GAS (Linux) and the Apple assembler (macOS). This is a drop-in replacement that preserves the exact original intent (64-byte cache-line alignment) on every platform, with no behavioral change on Linux.
- __asm__ volatile(".align 64\n");
+ __asm__ volatile(".balign 64\n");Acceptance criteria
-
MemsetBenchmark.cppcompiles on macOS x86_64 (Intel) -
MemsetBenchmark.cppcompiles unchanged on Linux x86_64 -
MemsetBenchmark.cppcompiles unchanged on macOS aarch64 (Apple Silicon) - No behavioral change — the alignment directive still aligns to 64 bytes
Related
- #2533 — Related issue about
MemsetBenchmark.cppon MSVC (__builtin_clzlnot found), different line and platform but same file
Source: facebook/folly