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

Some portability improvements from trying to build with Visual Studio 2017 #12150

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mgroeber9110
Copy link
Contributor

I tried getting llama.cpp to build on a machine that only had Visual Studio 2017 installed. In trying to get my build to work came across a few things that look like potential obstacles for portability, so I am proposing them as a patch, even if Visual Studio 2017 is probably not a major target in itself.

Here is a summary of the changes:

  • Replaced remaining instances of restrict keyword by GGML_RESTRICT macro
  • For MSVC versions that do not activate the C11 or C17 standards, use __restrict keyword instead of restrict in plain C mode (this is the only change that is really useful only for VS 2017)
  • Added include <algorithm> for std::min and std::max (as per https://en.cppreference.com/w/cpp/algorithm/min)
  • Added include <cctype> for std::toupper and std::tolower (as per https://en.cppreference.com/w/cpp/string/byte/tolower)
  • Moved _USE_MATH_DEFINES to the top of the source file to ensure including M_PI regardless of which header it is in

For completeness, I was eventually able to build and run successfully with Visual Studio 2017, but only after commenting out the check using codecvt_utf8<char32_t> in fs_validate_filename(), as this specialization is not available in the runtime library of VS 2017. Fixing this would probably need implementing a different type of check for non-standard UTF-8 encodings, so this would only be worthwhile if support of VS 2017 is desired.

@github-actions github-actions bot added examples ggml changes relating to the ggml tensor library for machine learning labels Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples ggml changes relating to the ggml tensor library for machine learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants