Files
hakorune/docs/development/roadmap/phases/phase-11/LLVM_SETUP_WINDOWS.md
Moe Charm fff9749f47 📚 Reorganize CLAUDE.md: slim down from 916 to 395 lines with proper doc links
- Keep essential information within 500 lines (now 395 lines)
- Maintain important syntax examples and development principles
- Move detailed information to appropriate docs files:
  - Development practices → docs/guides/development-practices.md
  - Testing guide → docs/guides/testing-guide.md
  - Claude issues → docs/tools/claude-issues.md
- Add proper links to all referenced documentation
- Balance between minimal entry point and practical usability
2025-08-31 06:22:48 +09:00

5.0 KiB
Raw Blame History

LLVM 18 Windows セットアップガイド

Date: 2025-08-31 Platform: Windows

📦 インストール方法

方法1: 公式インストーラー(推奨)

  1. LLVM公式サイトからダウンロード

  2. インストーラー実行

    • 管理者権限で実行
    • インストール先: C:\Program Files\LLVM (デフォルト推奨)
    • 重要: "Add LLVM to the system PATH" にチェック!
  3. 環境変数設定

    # PowerShell管理者権限で実行
    [Environment]::SetEnvironmentVariable("LLVM_SYS_180_PREFIX", "C:\Program Files\LLVM", "User")
    

方法2: Chocolateyパッケージマネージャー

# 管理者権限のPowerShellで実行
# Chocolateyインストール未インストールの場合
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# LLVM 18インストール
choco install llvm --version=18.1.8

# 環境変数設定
[Environment]::SetEnvironmentVariable("LLVM_SYS_180_PREFIX", "C:\ProgramData\chocolatey\lib\llvm\tools", "User")

方法3: wingetWindows Package Manager

# PowerShellで実行
winget install LLVM.LLVM --version 18.1.8

# 環境変数設定(インストール先確認後)
[Environment]::SetEnvironmentVariable("LLVM_SYS_180_PREFIX", "C:\Program Files\LLVM", "User")

🔧 環境変数設定GUI経由

  1. システムのプロパティを開く

    • Win + X → システム → システムの詳細設定
    • または「sysdm.cpl」を実行
  2. 環境変数を設定

    • 「環境変数」ボタンをクリック
    • ユーザー環境変数で「新規」
    • 変数名: LLVM_SYS_180_PREFIX
    • 変数値: C:\Program Files\LLVM
  3. PATH確認

    • C:\Program Files\LLVM\bin がPATHに含まれていることを確認

インストール確認

# PowerShellで実行
# LLVMバージョン確認
llvm-config --version

# 環境変数確認
echo $env:LLVM_SYS_180_PREFIX

# または cmd.exe で
echo %LLVM_SYS_180_PREFIX%

🚀 Visual Studio依存関係

WindowsでLLVMを使う場合、Visual Studioのビルドツールが必要

Visual Studio Build Tools最小構成

# wingetでインストール
winget install Microsoft.VisualStudio.2022.BuildTools

# または直接ダウンロード
# https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022

必要なコンポーネント:

  • MSVC v143 - VS 2022 C++ x64/x86 ビルドツール
  • Windows 11 SDKまたは Windows 10 SDK

🔨 Rustプロジェクトでの使用

  1. Cargo.tomlに追加
[dependencies]
inkwell = { version = "0.5", features = ["llvm18-0"] }

[features]
llvm = ["inkwell"]
  1. ビルド実行
# PowerShellで実行
$env:LLVM_SYS_180_PREFIX="C:\Program Files\LLVM"
cargo build --features llvm

# または永続的に設定後
cargo build --features llvm

⚠️ トラブルシューティング

問題: "llvm-config not found"

# PATHに追加されているか確認
$env:Path -split ';' | Select-String "LLVM"

# 手動でPATHに追加
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\LLVM\bin", "User")
  • Visual Studio Build Toolsがインストールされているか確認
  • 必要に応じて再起動

問題: バージョン不一致

# インストール済みLLVMを確認
llvm-config --version

# 古いバージョンをアンインストール
# コントロールパネル → プログラムと機能 → LLVM

🎯 クイックセットアップ(コピペ用)

# 管理者権限のPowerShellで実行
# 1. Chocolateyインストール未インストールの場合
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# 2. LLVM 18インストール
choco install llvm --version=18.1.8 -y

# 3. 環境変数設定
[Environment]::SetEnvironmentVariable("LLVM_SYS_180_PREFIX", "C:\ProgramData\chocolatey\lib\llvm\tools", "User")

# 4. 新しいPowerShellウィンドウを開いて確認
llvm-config --version
echo $env:LLVM_SYS_180_PREFIX

📋 関連リンク