Skip to content

How to compile post-01 on macOS ARM (Apple Silicon) #1417

@arthasyou

Description

@arthasyou

Hi Philipp,

First, thank you so much for the excellent OS development series. I'm currently following the post-01 branch of blog_os, and wanted to report the steps required to successfully build the project on Apple Silicon Macs (ARM64).

Since this platform is increasingly popular among Rust developers, I believe this could help others avoid common pitfalls and build failures.


✅ Environment

  • macOS 14.x (ARM64 / Apple Silicon)
  • Homebrew-installed llvm and ld.lld
  • Rust nightly (rustup update nightly)
  • Using cargo build -Z build-std

🔧 Required Steps for post-01 on macOS ARM

  1. Install prerequisites:
rustup update nightly
rustup component add rust-src --toolchain nightly
brew install llvm
  1. Create target file aarch64-blog_os.json:
{
  "llvm-target": "aarch64-unknown-none",
  "target-endian": "little",
  "target-pointer-width": "64",
  "arch": "aarch64",
  "os": "none",
  "vendor": "unknown",
  "linker-flavor": "ld.lld",
  "linker": "/opt/homebrew/opt/llvm/bin/ld.lld",
  "panic-strategy": "abort",
  "disable-redzone": true,
  "features": "+strict-align",
  "executables": true
}

⚠️ Do NOT include data-layout, or you'll hit a mismatch error when building core with -Z build-std.

  1. Use this command to build:
cargo +nightly build -Z build-std=core --target aarch64-blog_os.json

💡 Suggestion

Would you consider adding a section in the README or a separate guide for macOS ARM builds? I’d be happy to contribute a PR if that’s helpful.

Thanks again for the awesome tutorials!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions