c/BUILD: add public shared-library target (libLiteRtLm.so / .dylib / .dll)#2155
Open
DenisovAV wants to merge 1 commit intogoogle-ai-edge:mainfrom
Open
c/BUILD: add public shared-library target (libLiteRtLm.so / .dylib / .dll)#2155DenisovAV wants to merge 1 commit intogoogle-ai-edge:mainfrom
DenisovAV wants to merge 1 commit intogoogle-ai-edge:mainfrom
Conversation
Existing c/BUILD only exposes the C API via cc_library, which forces
every cross-language consumer (Dart FFI, Python ctypes, Node N-API,
Rust bindgen, .NET P/Invoke) to either carry a downstream patch that
adds a cc_binary(linkshared=True) target, or pull Bazel and rebuild
LiteRT-LM from source per platform.
Add a new `:LiteRtLm` cc_binary target that produces:
- libLiteRtLm.so on Linux / Android
- libLiteRtLm.dylib on macOS / iOS
- LiteRtLm.dll on Windows
with only `LiteRt*` / `litert_lm_*` symbols exported. Per-platform
export mechanism:
- macOS / iOS: -Wl,-exported_symbol,_LiteRt* / _litert_lm_*
- Linux: --dynamic-list extending the default visibility set with
LiteRt* / litert_lm_* (so plugins that dlsym(RTLD_DEFAULT) keep
working — e.g. WebGPU accelerator auto-registration)
- Windows: native win_def_file attribute pointing at the .def
whitelist (Bazel's MSVC link.exe action owns the linker
invocation, so /DEF: in linkopts gets clobbered)
The other symbols (absl, protobuf, internal helpers) stay hidden so
consumer-side dlopen of LiteRtLm doesn't collide with whatever the
consumer also links.
Closes google-ai-edge#2154.
3 tasks
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.
Summary
Adds a
cc_binary(linkshared=True, name="LiteRtLm")target toc/BUILDthat produces a flat shared library with onlyLiteRt*/litert_lm_*symbols exported. This unblocks every cross-language consumer of LiteRT-LM that wants to ship through a native FFI (Dart, Python, Node, Rust, .NET) without pulling Bazel into their build pipeline.Closes #2154.
What's added
Three files, all under
c/:c/BUILD— new `cc_binary` target named `LiteRtLm`. Bazel adds the platform-specific suffix automatically:Per-platform export mechanism in the `linkopts` select:
What's NOT changed
Test plan
Cross-references
CLA
Will sign Individual CLA before merge if needed; flagging upfront.