From 7144545e023a73bae8a13118f2092d7a91843660 Mon Sep 17 00:00:00 2001 From: dozyio Date: Mon, 8 Dec 2025 12:19:34 +0000 Subject: [PATCH] add macos setup script --- README.md | 18 ++++++++++++++- scripts/script-macos.sh | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100755 scripts/script-macos.sh diff --git a/README.md b/README.md index bba08bd..3c10fd1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,23 @@ It enables black-box execution of any RISC-V program, allowing developers to wri ## Building Phantom -We provide a setup script at [setup.sh](./scripts/setup.sh) to build Phantom and required dependencies from scratch on a fresh Debian/Ubuntu machine. +We provide setup scripts to build Phantom and required dependencies from scratch: +- **Ubuntu/Debian**: [setup.sh](./scripts/setup.sh) +- **macOS**: [setup-macos.sh](./scripts/setup-macos.sh) + +### macOS Setup Notes + +On macOS, this project requires `rustup` (not Homebrew Rust) to add the `riscv32i-unknown-none-elf` target needed for compiling guest programs. If you have Rust installed via Homebrew, please uninstall it first: + +```bash +brew uninstall rust rust-analyzer +``` + +Then run the macOS setup script: + +```bash +./scripts/setup-macos.sh +``` ## How to use Phantom diff --git a/scripts/script-macos.sh b/scripts/script-macos.sh new file mode 100755 index 0000000..b411cec --- /dev/null +++ b/scripts/script-macos.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -e + +echo "Setting up Phantom on macOS..." + +# Check if Homebrew is installed +if ! command -v brew &>/dev/null; then + echo "Homebrew not found. Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +# Install system dependencies +echo "Installing system dependencies via Homebrew..." +brew install cmake pkg-config fontconfig m4 + +# Check if rustup is already installed +if command -v rustup &>/dev/null; then + echo "rustup is already installed." +else + # Check if Homebrew Rust is installed + if brew list rust &>/dev/null 2>&1; then + echo "WARNING: Homebrew Rust detected. This project requires rustup." + echo "Please uninstall Homebrew Rust first:" + echo " brew uninstall rust rust-analyzer" + echo "Then re-run this script." + exit 1 + fi + + # Install Rust via rustup + echo "Installing Rust via rustup..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source "$HOME/.cargo/env" +fi + +# Set compiler version to nightly +echo "Setting Rust toolchain to nightly..." +rustup default nightly + +# Add RISC-V target (required for compiling guest programs) +echo "Adding RISC-V target..." +rustup target add riscv32i-unknown-none-elf + +# Clone repo and build +echo "Adding RISC-V target..." +git clone https://github.com/phantomzone-org/phantom.git && cd phantom && cargo build + +# Run template example +cd compiler-tests/template/ +PHANTOM_THREADS=$(sysctl -n hw.ncpu) PHANTOM_DEBUG=false PHANTOM_VERBOSE_TIMINGS=true cargo run --release