build: disable soname to reduce binary size#2177
Open
Bing-su wants to merge 1 commit intoabetlen:mainfrom
Open
build: disable soname to reduce binary size#2177Bing-su wants to merge 1 commit intoabetlen:mainfrom
Bing-su wants to merge 1 commit intoabetlen:mainfrom
Conversation
Bing-su
commented
Apr 9, 2026
Comment on lines
+46
to
+47
| RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} | ||
| LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} |
Author
There was a problem hiding this comment.
If these two settings were not configured, an issue arose where the library referenced files under the bin/ folder that did not exist.
❯ readelf -d dist/llama_cpp_python-0.3.20-py3-none-linux_x86_64/llama_cpp/lib/libggml.so
Dynamic section at offset 0xbd98 contains 29 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [bin/libggml-cpu.so]
0x0000000000000001 (NEEDED) Shared library: [bin/libggml-base.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN]
❯ readelf -d dist/llama_cpp_python-0.3.20-py3-none-linux_x86_64/llama_cpp/lib/libllama.so
Dynamic section at offset 0x2dc128 contains 31 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [bin/libggml.so]
0x0000000000000001 (NEEDED) Shared library: [bin/libggml-base.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2]
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN]So I overrode the settings in llama-cpp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disable soname to reduce binary size.
As explained in pep-778, wheel files currently do not handle symbolic links (it replaces the symbolic link with the original file). This causes the llama-cpp-python wheel file to become larger than the original.
By setting the NO_SONAME flag to prevent the creation of symbolic links, it resolves this issue.
https://github.com/Bing-su/llama-cpp-python/actions/runs/24200306300
Please also check the built files.
wheels-ubuntu-22.04.zip
wheels-windows-2022.zip
wheels-macos-15.zip