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

Open Beginner friendly
#2,690 0 comments 0 reactions 0 assignees View on GitHub

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.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
Dominant language
C++
Stars
30.5k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from facebook/folly

All issues in facebook/folly

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.