Skip to content

ggml : revert to -lm linking instead of find_library - #22355

Merged
ggerganov merged 4 commits into
ggml-org:masterfrom
angt:ggml-revert-to-lm-linking-instead-of-find_library
Apr 28, 2026
Merged

ggerganov merged 4 commits into
ggml-org:masterfrom
angt:ggml-revert-to-lm-linking-instead-of-find_library

Conversation

@angt

@angt angt commented Apr 25, 2026

Copy link
Copy Markdown
Member

Overview

find_library(MATH_LIBRARY m) was introduced recently, but it breaks CUDA compilation with GGML_STATIC. I could not find any valid use case where we would prefer find_library over the standard -lm approach.

This commit is also meant to start a discussion if there is a valid reason to keep find_library(MATH_LIBRARY m), we should clarify what problem it was solving and find an alternative fix that does not break CUDA with GGML_STATIC.

Additional information

Found with installama.sh: https://github.com/angt/installama.sh/actions/runs/24885620138/job/72864816848

Requirements

`find_library(MATH_LIBRARY m)` was introduced recently, but it breaks
CUDA compilation with GGML_STATIC. I could not find any valid use case
where we would prefer `find_library` over the standard `-lm` approach.

This commit is also meant to start a discussion if there is a valid
reason to keep `find_library(MATH_LIBRARY m)`, we should clarify what
problem it was solving and find an alternative fix that does not break
CUDA with GGML_STATIC.

Signed-off-by: Adrien Gallouët <[email protected]>
@angt

angt commented Apr 25, 2026

Copy link
Copy Markdown
Member Author

ok: #22237, im going to dig that

@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Apr 25, 2026
@ggerganov

Copy link
Copy Markdown
Member

Some of the builds are failing

@angt
angt force-pushed the ggml-revert-to-lm-linking-instead-of-find_library branch from 54cc6ea to d1792ae Compare April 27, 2026 08:05
@angt

angt commented Apr 27, 2026

Copy link
Copy Markdown
Member Author

Some of the builds are failing

Fixed, we need to fallback for NOT WIN32 AND NOT DEFINED ENV{ONEAPI_ROOT} and not OR used in the current code.

@ggerganov
ggerganov merged commit d530d6e into ggml-org:master Apr 28, 2026
45 of 46 checks passed
IntelNav pushed a commit to IntelNav/llama.cpp that referenced this pull request Apr 29, 2026
* ggml : revert to -lm linking instead of find_library

`find_library(MATH_LIBRARY m)` was introduced recently, but it breaks
CUDA compilation with GGML_STATIC. I could not find any valid use case
where we would prefer `find_library` over the standard `-lm` approach.

This commit is also meant to start a discussion if there is a valid
reason to keep `find_library(MATH_LIBRARY m)`, we should clarify what
problem it was solving and find an alternative fix that does not break
CUDA with GGML_STATIC.

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : use MATH_LIBRARY only if defined

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : fix initial broken condition

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : always respect MATH_LIBRARY when defined

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
baramofme pushed a commit to baramofme/llama-cpp-turboquant that referenced this pull request May 23, 2026
* ggml : revert to -lm linking instead of find_library

`find_library(MATH_LIBRARY m)` was introduced recently, but it breaks
CUDA compilation with GGML_STATIC. I could not find any valid use case
where we would prefer `find_library` over the standard `-lm` approach.

This commit is also meant to start a discussion if there is a valid
reason to keep `find_library(MATH_LIBRARY m)`, we should clarify what
problem it was solving and find an alternative fix that does not break
CUDA with GGML_STATIC.

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : use MATH_LIBRARY only if defined

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : fix initial broken condition

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : always respect MATH_LIBRARY when defined

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
MrLordCat referenced this pull request in MrLordCat/llama.cpp-rdna-lab Jul 16, 2026
* ggml : revert to -lm linking instead of find_library

`find_library(MATH_LIBRARY m)` was introduced recently, but it breaks
CUDA compilation with GGML_STATIC. I could not find any valid use case
where we would prefer `find_library` over the standard `-lm` approach.

This commit is also meant to start a discussion if there is a valid
reason to keep `find_library(MATH_LIBRARY m)`, we should clarify what
problem it was solving and find an alternative fix that does not break
CUDA with GGML_STATIC.

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : use MATH_LIBRARY only if defined

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : fix initial broken condition

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : always respect MATH_LIBRARY when defined

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
* ggml : revert to -lm linking instead of find_library

`find_library(MATH_LIBRARY m)` was introduced recently, but it breaks
CUDA compilation with GGML_STATIC. I could not find any valid use case
where we would prefer `find_library` over the standard `-lm` approach.

This commit is also meant to start a discussion if there is a valid
reason to keep `find_library(MATH_LIBRARY m)`, we should clarify what
problem it was solving and find an alternative fix that does not break
CUDA with GGML_STATIC.

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : use MATH_LIBRARY only if defined

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : fix initial broken condition

Signed-off-by: Adrien Gallouët <[email protected]>

* ggml : always respect MATH_LIBRARY when defined

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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