Minimize exported symbols of libtriton#9922
Merged
Merged
Conversation
e9df680 to
fc8d268
Compare
Mogball
approved these changes
Apr 23, 2026
Collaborator
Mogball
left a comment
There was a problem hiding this comment.
The hero we need but don't deserve
When extensions are not enabled, libtriton only needs to export a single symbol `_PyInit_libtriton`. However, currently: 1. On macOS, we export all LLVM symbols since we don't have something like `exclude-libs`. 2. On Linux, despite `exclude-libs` we still export ~100 symbols, mostly from template instantiations. Maintaining an explicit symbol export list ensure the interface is very narrowly scoped, which: 1. Minimizes the chance of symbol conflicts. This is especially a problem on macOS, where we currently export everything, and cpython by default opens libraries with RTLD_GLOBAL (python/cpython#137880). 2. Allows the linker to strip dead code better. 3. Reduces the size of the symbol table. On macOS arm64, this change reduces the size of a stripped libtriton from 133.7 MiB to 113.6 MiB.
fc8d268 to
0c3764e
Compare
This was referenced Apr 27, 2026
abrown
added a commit
to abrown/triton
that referenced
this pull request
May 11, 2026
This change proposes a split into two libraries: - `libtritoncore.so` which would (eventually) contain only Triton code, nothing vendor-specific; all of these symbols are exported - `libtriton.so` which `RPATH`-depends on `libtritoncore.so` and includes all of vendor-specific code with the Python bindings; these symbols are all hidden (see triton-lang#9922).
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.
When extensions are not enabled, libtriton only needs to export a single
symbol
_PyInit_libtriton. However, currently:something like
exclude-libs.exclude-libswe still export ~100 symbols, mostlyfrom template instantiations.
Maintaining an explicit symbol export list ensure the interface is very
narrowly scoped, which:
problem on macOS, where we currently export everything, and cpython
by default opens libraries with RTLD_GLOBAL (Default dlopenflags inconsistent between Linux and macOS python/cpython#137880).
reduces the size of a stripped libtriton from 133.7 MiB to 113.6 MiB.