feat: add runtime_executable adapter for foreign_cc binaries#1539
Draft
jsun-splunk wants to merge 3 commits into
Draft
feat: add runtime_executable adapter for foreign_cc binaries#1539jsun-splunk wants to merge 3 commits into
jsun-splunk wants to merge 3 commits into
Conversation
6d453cb to
981f69e
Compare
981f69e to
8f3823c
Compare
8d2f0ce to
0b389f0
Compare
Add opt-in runtime library search directory derivation for foreign_cc
outputs. This lets foreign-built binaries and shared libraries resolve
shared libraries from `deps`, `dynamic_deps`, and this rule's own declared
shared-library outputs without relying on loader environment variables such
as `LD_LIBRARY_PATH`.
Public attrs:
- `runtime_library_search_directories`
- `additional_dynamic_runtime_library_search_origins`
- `additional_executable_runtime_library_search_origins`
Example:
```python
configure_make(
name = "python",
out_binaries = ["python3.10"],
out_shared_libs = ["libpython3.10.so"],
runtime_library_search_directories = "enabled",
additional_dynamic_runtime_library_search_origins = [
"lib/python3.10/lib-dynload",
],
deps = [":openssl"],
)
```
`runtime_library_search_directories` accepts `auto`, `enabled`, and
`disabled`. The global build setting defaults to `disabled`, so existing
targets keep the previous behavior unless a target opts in or the build
setting is enabled.
Default origins are derived from declared output `File.short_path` values.
Shared-library link actions use declared shared-library output directories.
Executable link actions use declared binary output directories. Additional
origins are install-tree-relative paths joined under this rule's INSTALLDIR.
The implementation derives dependency origins from `LibraryToLink` dynamic
libraries and adds Bazel `_solib` sibling search paths for solib symlink
layouts. Runtime search derivation is skipped for Windows C++ toolchains.
Wire the runtime search path flags as common implementation flags.
However, support is limited to `cmake`, `configure_make`, `make` and
`meson`. `Ninja` and `boost` support is currently disabled.
Add unit coverage for enablement, default origins, additional origins,
self-output search paths, `_solib` paths, deduplication, and global
build-setting resolution. Add integration coverage for runtime
dependency chains and self-contained output bundles.
0b389f0 to
dfb5dcd
Compare
Introduce a `runtime_executable` rule for turning selected foreign_cc binary outputs into executable Bazel targets. This cannot live directly on the existing foreign_cc rules because foreign_cc outputs are not always expected to contain a binary, so those rules cannot always expose an executable. The adapted executable may require `runtime_library_search_directories = "enabled"` on the producing foreign_cc target when it depends directly or transitively on foreign_cc-produced shared libraries. `runtime_executable` is a more Bazel-native version of `runnable_binary` because it exposes the executable through `DefaultInfo.files_to_run` for downstream consumers. The API is intentionally kept similar to `runnable_binary`. For now, it cannot completely replace `runnable_binary` because `runtime_library_search_directories` defaults to `"disabled"` to minimize blast radius while these features mature.
dfb5dcd to
2ff317b
Compare
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.
Introduce a
runtime_executablerule for turning selected foreign_cc binary outputs into executable Bazel targets. This cannot live directly on the existing foreign_cc rules because foreign_cc outputs are not always expected to contain a binary, so those rules cannot always expose an executable.The adapted executable may require
runtime_library_search_directories = "enabled"on the producing foreign_cc target when it depends directly or transitively on foreign_cc-produced shared libraries.runtime_executableis a more Bazel-native version ofrunnable_binarybecause it exposes the executable throughDefaultInfo.files_to_runfor downstream consumers. The API is intentionally kept similar torunnable_binary. For now, it cannot completely replacerunnable_binarybecauseruntime_library_search_directoriesdefaults to"disabled"to minimize blast radius while these features mature.