#2690·folly

MemsetBenchmark.cpp: .align 64 is invalid on macOS x86_64 (Apple assembler interprets as 2^64)

Author: levonkCreated Sep 8, 2026Updated Sep 8, 2026

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 large

This 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.

diff
-  __asm__ volatile(".align 64\n");
+  __asm__ volatile(".balign 64\n");

Acceptance criteria

  • MemsetBenchmark.cpp compiles on macOS x86_64 (Intel)
  • MemsetBenchmark.cpp compiles unchanged on Linux x86_64
  • MemsetBenchmark.cpp compiles unchanged on macOS aarch64 (Apple Silicon)
  • No behavioral change — the alignment directive still aligns to 64 bytes

Related

  • #2533 — Related issue about MemsetBenchmark.cpp on MSVC (__builtin_clzl not found), different line and platform but same file