Skip to content

Make llama.cpp CURL dependency optional when building from source#3822

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
Fizza-Mukhtar:fix/llama-build-curl
Jan 4, 2026
Merged

Make llama.cpp CURL dependency optional when building from source#3822
danielhanchen merged 3 commits into
unslothai:mainfrom
Fizza-Mukhtar:fix/llama-build-curl

Conversation

@Fizza-Mukhtar

Copy link
Copy Markdown
Contributor

Fixes build failures when libcurl is unavailable by conditionally
disabling -DLLAMA_CURL during llama.cpp CMake builds. This matches
upstream CMake guidance and prevents crashes in Docker / minimal
Linux environments while preserving CURL support when available.

Fixes #3453

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Fizza-Mukhtar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the build process for llama.cpp within the unsloth project by making the CURL dependency optional. It introduces a mechanism to detect the availability of the curl utility and dynamically configure the llama.cpp CMake build flag (-DLLAMA_CURL). This ensures that llama.cpp can be successfully built even in environments lacking libcurl, thereby improving compatibility and preventing build failures, while still enabling CURL support when it is present.

Highlights

  • Conditional CURL Dependency: The llama.cpp build process now dynamically checks for the presence of the curl executable and sets the DLLAMA_CURL CMake flag accordingly, making the dependency optional.
  • Improved Build Robustness: This change prevents build failures in environments where libcurl might not be installed, such as Docker or minimal Linux setups, by conditionally disabling CURL support.
  • Upstream Alignment: The modification aligns the llama.cpp build configuration with upstream CMake guidance, ensuring better compatibility and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request aims to make the llama.cpp CURL dependency optional, which is a great improvement for build robustness. The overall approach is correct, but there are two critical issues in the implementation where f-string formatting is missing for command strings. This will cause the build to fail because the CURL_FLAG variable is not interpolated. I've added comments with suggestions to fix these bugs. With these fixes, the PR should be good to merge.

Comment thread unsloth/save.py Outdated
# Instead use CMAKE
commands = [
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF -DLLAMA_CURL=ON",
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

This string should be an f-string to correctly interpolate the CURL_FLAG variable. As it is, the literal string {CURL_FLAG} will be passed to the cmake command, which will cause a build failure.

Suggested change
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",
f"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",

Comment thread unsloth/save.py Outdated
# Instead use CMAKE
commands = [
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF -DLLAMA_CURL=ON",
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

Similar to a previous part of the code, this string needs to be an f-string to interpolate the CURL_FLAG variable. Without the f prefix, the command will receive the literal string {CURL_FLAG}, causing the build to fail.

Suggested change
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",
f"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread unsloth/save.py Outdated
# Instead use CMAKE
commands = [
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF -DLLAMA_CURL=ON",
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Format CURL_FLAG before passing to cmake

When the make build fails and try_execute falls back to CMake, this command passes the literal string {CURL_FLAG} to cmake because it isn’t an f-string. That means CMake receives an unrecognized argument instead of -DLLAMA_CURL=ON/OFF, so the fallback build can fail regardless of curl availability. This regression only shows up in the CMake fallback path.

Useful? React with 👍 / 👎.

Comment thread unsloth/save.py Outdated
# Instead use CMAKE
commands = [
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF -DLLAMA_CURL=ON",
"cmake llama.cpp -B llama.cpp/build -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF {CURL_FLAG}",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Format CURL_FLAG before passing to cmake

In the blocking install path’s CMake fallback, {CURL_FLAG} is not interpolated (string is missing the f prefix). As a result, the literal placeholder is passed to CMake and the fallback build can fail even when it’s supposed to disable curl. This only affects environments where the make build fails and the CMake path is used.

Useful? React with 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

Thanks this works!

@danielhanchen danielhanchen merged commit fad1525 into unslothai:main Jan 4, 2026
1 check passed
@Fizza-Mukhtar Fizza-Mukhtar deleted the fix/llama-build-curl branch January 4, 2026 13:23
abiswas-realadvice pushed a commit to abiswas-realadvice/unsloth that referenced this pull request May 14, 2026
…curl

Make llama.cpp CURL dependency optional when building from source
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.

[Bug] Error when loading model from local path: 'GptOssTopKRouter' has no attribute 'weight'

2 participants