claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Claude Code Architecture Mismatch on Apple Silicon Macs

Open chatgpt-copypasta opened this issue 5 months ago • 7 comments

ISSUE

Claude Code's execution environment runs under Rosetta 2 (x86_64 emulation) on Apple Silicon Macs, causing architecture detection mismatches between the user's native ARM64 environment and Claude's x86_64 environment. This leads to incorrect build configurations, wrong library paths, and compilation failures when Claude executes commands on behalf of users.

EXPECTED BEHAVIOR

Claude Code should run natively as ARM64 on Apple Silicon Macs, matching the user's architecture and ensuring consistent behavior across all executed commands.

STEPS TO REPRODUCE

Environment:

  • macOS 15.5 (Sequoia)
  • Apple M4 MacBook Pro (14 CPU cores, 24GB RAM)
  • Claude Code CLI (latest version)
  • Native ARM64 terminal environment

Demonstration of Architecture Mismatch:

User's Terminal (Native ARM64):

$ uname -m
arm64

$ arch
arm64

$ sysctl -n hw.optional.arm64
1

$ sysctl -n sysctl.proc_translated
0

Claude Code's Execution Environment (Rosetta x86_64):

# When Claude executes the same commands
$ uname -m
x86_64

$ arch
i386

$ sysctl -n hw.optional.arm64
1

$ sysctl -n sysctl.proc_translated
1

IMPACT AND CONSEQUENCES

  1. Build System Detection Issues When building LLVM with CMake, the architecture mismatch causes incorrect host triple detection:

What Claude sees:

-DLLVM_HOST_TRIPLE=x86_64-apple-darwin24.5.0

What should be detected:

-DLLVM_HOST_TRIPLE=arm64-apple-darwin24.5.0
  1. Library Path Contamination The x86_64 environment causes build tools to find Intel libraries instead of ARM64 ones:
# Claude's environment finds x86_64 libraries
-I/usr/local/opt/gmp/include -I/usr/local/Cellar/isl/0.27/include

# Should find ARM64 libraries
-I/opt/homebrew/include

Resulting build errors:

ld: warning: ignoring file '/usr/local/lib/libzstd.dylib': found architecture 'x86_64', required architecture 'arm64'
  1. Compiler Runtime Build Failures The architecture mismatch causes compiler-rt configuration to fail:
CMake Error at /path/to/llvm-project/compiler-rt/cmake/Modules/CompilerRTUtils.cmake:399 (string):
  string sub-command REPLACE requires at least four arguments.

VERIFICATION

The issue can be verified by checking process translation status:

# Check if running under Rosetta
if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null) == "1" ]]; then
    echo "Running under Rosetta 2 (x86_64 emulation)"
else
    echo "Running natively"
fi

WORKAROUNDS

  1. Force ARM64 Execution in Scripts Add architecture detection to build scripts:
#!/usr/bin/env bash
# Force ARM64 execution if we're running under Rosetta
if [[ $(arch) == "i386" ]] && [[ $(uname -m) == "arm64" ]]; then
    echo "🔄 Re-launching under native ARM64 (currently in Rosetta mode)..."
    exec arch -arm64 "$0" "$@"
fi
  1. Explicit Architecture Commands Prefix commands with arch -arm64:
arch -arm64 cmake ...
arch -arm64 ninja ...
  1. Environment Variable Overrides Force correct paths and architectures:
export CMAKE_OSX_ARCHITECTURES=arm64
export LIBRARY_PATH="/opt/homebrew/lib:${LIBRARY_PATH:-}"
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
export CMAKE_IGNORE_PATH="/usr/local;/usr/local/lib;/usr/local/include"

SYSTEM INFORMATION

macOS: 15.6 (24A335)
Xcode: 16.4
Command Line Tools: 16.0.0.0.1.1725547130
Homebrew: 4.4.10 (ARM64 at /opt/homebrew)

EXPECTED RESOLUTION

Claude Code's backend infrastructure should:

  1. Detect Apple Silicon hardware and run natively as ARM64
  2. Not require Rosetta 2 emulation on ARM64 Macs
  3. Match the user's architecture when executing commands
  4. Properly detect and use ARM64 Homebrew paths (/opt/homebrew)

ADDITIONAL CONTEXT

This issue affects any build process that relies on architecture detection, including:

  • LLVM/Clang builds
  • Firefox compilation
  • Any CMake-based project
  • Projects using pkg-config
  • Homebrew package installations

The architecture mismatch is particularly problematic for users building performance-critical software that needs to take advantage of Apple Silicon optimizations (M1, M2, M3, M4 specific features).

chatgpt-copypasta avatar Jul 30 '25 03:07 chatgpt-copypasta

Can't confirm this as a Claude Code issue. macOS 15.5, MacBook Pro M1 Max. You sure it's not your node build or something that forces Claude Code into x86 architecture?

> can you run uname -m for me please?

✻ Thinking…

  The user is asking me to run the uname -m command, which displays the machine hardware architecture. This is a
  simple system information command.

⏺ Bash(uname -m)
  ⎿  arm64

✻ Thinking…

  The user's machine is running on ARM64 architecture, which is common for Apple Silicon Macs.

Helmi avatar Jul 30 '25 15:07 Helmi

No issue here.

M4 MBP 15.5 (24F74)

⏺ Bash(uname -m) ⎿  arm64

moofone avatar Jul 30 '25 15:07 moofone

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 03 '25 10:12 github-actions[bot]

I'm having this issue too.

I have a feeling it's because I used Time Machine to data from my old Intel Mac onto my new M4 Pro.

Does anybody have any solution to this?

patrickswirl avatar Dec 08 '25 18:12 patrickswirl

This happened to me recently as well. uname -m arm64

ratpH1nk avatar Dec 18 '25 15:12 ratpH1nk