Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't it's nice to ask users to uninstall rust


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

Expand Down
50 changes: 50 additions & 0 deletions scripts/script-macos.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, phantom detect no. of cores and uses them. So setting sysctl -n hw.ncpu is not required