Skip to content

Build your windows binaries with Clang and not MSVC. #534

@BadisG

Description

@BadisG

Hello,

Your windows binaries releases have probably been built with MSVC and I think there's a better way to do it.

Expected Behavior

I have a Intel® Core™ i7-10700K and the builds are supposed to recognize those architectures: [AVX | AVX2 | FMA | SSE3 | F16C]

Current Behavior

Windows (MSVC build)

system_info: n_threads = 14 / 16 | AVX = 1 | AVX2 = 1 | AVX512 = 0 | FMA = 0 | 
NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 0 | VSX = 0 |

It misses the FMA, SSE3 and the F16C architectures.

Fix with Clang

If you build with Clang you'll get all the architectures right:

Windows (Clang build)

system_info: n_threads = 14 / 16 | AVX = 1 | AVX2 = 1 | AVX512 = 0 | FMA = 1 | 
NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | VSX = 0 |

How to build with Clang

  1. Install Clang
    To do this, you have to install something called LLVM
    I downloaded LLVM-16.0.0-win64.exe but it could be LLVM-16.0.0-win32.exe for people that has Windows 32 bit.
    During the install, Choose "Add LLVM to the system PATH for all users"

After the installation you can verify if you have clang installed on your computer by running clang --version on your cmd
Normally you'll get something like this

C:\Users\Utilisateur>clang --version
clang version 16.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
  1. Install chocolate (that's necessary to install Ninja (which is necessary to build with clang 😵 ))
    To do that, open powershell as an administrator and run this command:
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'))
  1. Install Ninja
    Open powershell as an administrator and run this command:
choco install ninja
  1. Build with clang
    run your cmd on the llama.cpp repository and run those commands
cmake -G "Ninja" -S . -B Windows-build/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake --build Windows-build/ --config Release

You'll get your exe here:

.\Windows-build\bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildCompilation issuesenhancementNew feature or requeststalewindowsIssues specific to Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions