MemsetBenchmark.cpp: .align 64 is invalid on macOS x86_64 (Apple assembler interprets as 2^64)
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 90/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- build-system
Research direction
Open folly/test/MemsetBenchmark.cpp and inspect the inline assembly around the .align 64 directive, especially its non-aarch64 guard. Replace the directive as proposed, then build the folly test target on the relevant platforms; done means macOS x86_64 compiles while Linux x86_64 and macOS aarch64 retain 64-byte alignment.
Written by the indexing model from the issue text.
Description
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.
- __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
- Dominant language
- C++
- Stars
- 30.5k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from facebook/folly
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 Half a day Newbie friendliness 78/100
-
build break - references to the nonexistent EDFThreadPoolExecutorBenchmark.cpp and PartialTest.cpp Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·