Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build script for Microsoft Visual Studio #4

Closed
wants to merge 2 commits into from

Conversation

PeterReid
Copy link

For Windows users, this batch file builds sd.exe using Visual Studio's cl.exe. Most of the file is dedicated to checking the environment and reporting errors nicely. Specifically, it will explain what to do if cl.exe is missing or for the wrong architecture.

@leejet
Copy link
Owner

leejet commented Aug 15, 2023

Thanks for your contribution. However, I believe CMake works well as a build tool on Windows. For instance, it automatically detects the compiler, eliminating the need to open the Developer CMD or add the cl.exe directory to the PATH. It can define macros through command-line parameters to utilize certain GGML features, such as OPENBLAS. Additionally, GGML's CMake files have pre-defined macros and compiler parameters, including those related to AVX. Achieving a similar effect through a build script would require a significant amount of work.

@vxiiduu
Copy link

vxiiduu commented Aug 21, 2023

For Windows users, this batch file builds sd.exe using Visual Studio's cl.exe. Most of the file is dedicated to checking the environment and reporting errors nicely. Specifically, it will explain what to do if cl.exe is missing or for the wrong architecture.

Thanks for this. I don't have CMAKE on my computer, so I'll be using this script instead.

@Green-Sky
Copy link
Contributor

iirc, visual studio ships with cmake and ninja. are you on some very old version?

@vxiiduu
Copy link

vxiiduu commented Aug 22, 2023

iirc, visual studio ships with cmake and ninja. are you on some very old version?

i just didnt install cmake or any of that linux tools

@bitRAKE
Copy link

bitRAKE commented Aug 23, 2023

How to get cmake to produce the optimal compiler options? I've not been sufficiently motivated to learn cmake, yet.

As for Visual Studio - I like to use \GL:

cl.exe /arch:AVX2 /fp:fast /Ox /EHsc /GL /I. /I ggml\include\ggml /I ggml\include examples\main.cpp stable-diffusion.cpp ggml\src\ggml.c /link /out:build\sd.vs.exe

... and for clang, I do:

clang.exe -march=native -ffast-math -O3 -fno-exceptions -flto -I. -Iggml/include/ggml -Iggml/include examples/main.cpp stable-diffusion.cpp ggml/src/ggml.c -fuse-ld=lld -o build/sd.clang.exe

@leejet leejet closed this Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants