-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Nix: Build shared library #1067
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
Conversation
I can't test whether this works on Darwin, but it can build libllama.so. I did try building via CMake with -DBUILD_SHARED_LIBS=ON, but it did not work and I could not make it work.
Whoops! I didn't notice this at first because I'm not on Darwin. Can somebody test this, please?
We should really investigate how to build the shared library via cmake and not merge this PR as is |
Sure, whatever works for you. I'm going to keep using this change locally. Feel free to add more commits, close this PR and open another one, etc. |
on macOS using |
Nice! On Linux, this builds If you can figure out how to unbreak the Linux build, then I happily agree with your CMake plan. |
Maybe symbols need to be exported on Linux similarly to Windows (#1100)? What error do you see when building examples? |
Like it's not being linked with |
Does this help? diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11ebe9e..ba5904f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -81,6 +81,7 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED true)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
+set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} m)
if (NOT MSVC)
if (LLAMA_SANITIZE_THREAD) |
I tried it, and the build is still broken with the same error in the same place. I double-checked. |
I couldn't get CMake to cooperate, so I ended up using the plain Makefile instead. I've tested the shared library as well as
llama
andembedding
binaries. I already have this flake as an input in a personal repository, and this change works for me when integrated.I do need an aarch64 Darwin user to verify that the
CFLAGS
work properly. @niklaskorz, does this work for you?See also NixOS/nixpkgs#225058, since I know that it's controversial to have a flake.