Skip to content

Commit 91eb064

Browse files
angtmeh
authored andcommitted
ggml : revert to -lm linking instead of find_library (ggml-org#22355)
* 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 <angt@huggingface.co> * ggml : use MATH_LIBRARY only if defined Signed-off-by: Adrien Gallouët <angt@huggingface.co> * ggml : fix initial broken condition Signed-off-by: Adrien Gallouët <angt@huggingface.co> * ggml : always respect MATH_LIBRARY when defined Signed-off-by: Adrien Gallouët <angt@huggingface.co> --------- Signed-off-by: Adrien Gallouët <angt@huggingface.co>
1 parent fe3bed5 commit 91eb064

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

ggml/src/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,10 @@ endforeach()
471471

472472
target_link_libraries(ggml-base PRIVATE Threads::Threads)
473473

474-
find_library(MATH_LIBRARY m)
475-
if (MATH_LIBRARY)
476-
if (NOT WIN32 OR NOT DEFINED ENV{ONEAPI_ROOT})
477-
target_link_libraries(ggml-base PRIVATE ${MATH_LIBRARY})
478-
endif()
474+
if (DEFINED MATH_LIBRARY)
475+
target_link_libraries(ggml-base PRIVATE ${MATH_LIBRARY})
476+
elseif (NOT WIN32 AND NOT DEFINED ENV{ONEAPI_ROOT})
477+
target_link_libraries(ggml-base PRIVATE m)
479478
endif()
480479

481480
if (CMAKE_SYSTEM_NAME MATCHES "Android")

0 commit comments

Comments
 (0)