Skip to content

Commit

Permalink
🗂️ Add support for version scripts (#246)
Browse files Browse the repository at this point in the history
Only used when building shared objects.
  • Loading branch information
aaronmondal authored May 29, 2024
1 parent c4c768a commit 3ee8095
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/reference/defs.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TODO
<a href="#ll_library-compile_string_flags">compile_string_flags</a>, <a href="#ll_library-defines">defines</a>, <a href="#ll_library-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_library-emit">emit</a>, <a href="#ll_library-experimental_device_intrinsics">experimental_device_intrinsics</a>,
<a href="#ll_library-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_library-exposed_defines">exposed_defines</a>, <a href="#ll_library-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_library-exposed_includes">exposed_includes</a>,
<a href="#ll_library-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_library-includes">includes</a>, <a href="#ll_library-interfaces">interfaces</a>, <a href="#ll_library-sanitize">sanitize</a>, <a href="#ll_library-shared_object_link_flags">shared_object_link_flags</a>,
<a href="#ll_library-shared_object_link_string_flags">shared_object_link_string_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>)</code></pre>
<a href="#ll_library-shared_object_link_string_flags">shared_object_link_string_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>, <a href="#ll_library-version_script">version_script</a>)</code></pre>
Creates a static archive.

Example:
Expand Down Expand Up @@ -138,6 +138,7 @@ Example:
| <a id="ll_library-shared_object_link_flags"></a>`shared_object_link_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the linker when emitting shared objects.<br><br>Used if `emit` includes `"shared_object"`. |
| <a id="ll_library-shared_object_link_string_flags"></a>`shared_object_link_string_flags` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Flags for the linker when emitting shared objects in the form of `string_flag`s.<br><br>See `compile_string_flags` for semantics.<br><br>Used if `emit` includes `"shared_object"`. |
| <a id="ll_library-toolchain_configuration"></a>`toolchain_configuration` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>"@rules_ll//ll:current_ll_toolchain_configuration"</code>.<br><br> TODO |
| <a id="ll_library-version_script"></a>`version_script` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> Optional version script used during shared object linking.<br><br>Used if `emit` includes `"shared_object"`. |


<a id="ll_test"></a>
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/ll.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Example:
<a href="#ll_library-compile_string_flags">compile_string_flags</a>, <a href="#ll_library-defines">defines</a>, <a href="#ll_library-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_library-emit">emit</a>, <a href="#ll_library-experimental_device_intrinsics">experimental_device_intrinsics</a>,
<a href="#ll_library-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_library-exposed_defines">exposed_defines</a>, <a href="#ll_library-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_library-exposed_includes">exposed_includes</a>,
<a href="#ll_library-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_library-includes">includes</a>, <a href="#ll_library-interfaces">interfaces</a>, <a href="#ll_library-sanitize">sanitize</a>, <a href="#ll_library-shared_object_link_flags">shared_object_link_flags</a>,
<a href="#ll_library-shared_object_link_string_flags">shared_object_link_string_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>)</code></pre>
<a href="#ll_library-shared_object_link_string_flags">shared_object_link_string_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>, <a href="#ll_library-version_script">version_script</a>)</code></pre>
Creates a static archive.

Example:
Expand Down Expand Up @@ -98,6 +98,7 @@ Example:
| <a id="ll_library-shared_object_link_flags"></a>`shared_object_link_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the linker when emitting shared objects.<br><br>Used if `emit` includes `"shared_object"`. |
| <a id="ll_library-shared_object_link_string_flags"></a>`shared_object_link_string_flags` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Flags for the linker when emitting shared objects in the form of `string_flag`s.<br><br>See `compile_string_flags` for semantics.<br><br>Used if `emit` includes `"shared_object"`. |
| <a id="ll_library-toolchain_configuration"></a>`toolchain_configuration` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>"@rules_ll//ll:current_ll_toolchain_configuration"</code>.<br><br> TODO |
| <a id="ll_library-version_script"></a>`version_script` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> Optional version script used during shared object linking.<br><br>Used if `emit` includes `"shared_object"`. |


<a id="ll_test"></a>
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/defs.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TODO
<a href="#ll_library-compile_string_flags">compile_string_flags</a>, <a href="#ll_library-defines">defines</a>, <a href="#ll_library-depends_on_llvm">depends_on_llvm</a>, <a href="#ll_library-emit">emit</a>, <a href="#ll_library-experimental_device_intrinsics">experimental_device_intrinsics</a>,
<a href="#ll_library-exposed_angled_includes">exposed_angled_includes</a>, <a href="#ll_library-exposed_defines">exposed_defines</a>, <a href="#ll_library-exposed_hdrs">exposed_hdrs</a>, <a href="#ll_library-exposed_includes">exposed_includes</a>,
<a href="#ll_library-exposed_interfaces">exposed_interfaces</a>, <a href="#ll_library-includes">includes</a>, <a href="#ll_library-interfaces">interfaces</a>, <a href="#ll_library-sanitize">sanitize</a>, <a href="#ll_library-shared_object_link_flags">shared_object_link_flags</a>,
<a href="#ll_library-shared_object_link_string_flags">shared_object_link_string_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>)</code></pre>
<a href="#ll_library-shared_object_link_string_flags">shared_object_link_string_flags</a>, <a href="#ll_library-toolchain_configuration">toolchain_configuration</a>, <a href="#ll_library-version_script">version_script</a>)</code></pre>
Creates a static archive.

Example:
Expand Down Expand Up @@ -138,6 +138,7 @@ Example:
| <a id="ll_library-shared_object_link_flags"></a>`shared_object_link_flags` | <code>List of strings</code>, optional, defaults to <code>[]</code>.<br><br> Flags for the linker when emitting shared objects.<br><br>Used if `emit` includes `"shared_object"`. |
| <a id="ll_library-shared_object_link_string_flags"></a>`shared_object_link_string_flags` | <code><a href="https://bazel.build/concepts/labels">List of labels</a></code>, optional, defaults to <code>[]</code>.<br><br> Flags for the linker when emitting shared objects in the form of `string_flag`s.<br><br>See `compile_string_flags` for semantics.<br><br>Used if `emit` includes `"shared_object"`. |
| <a id="ll_library-toolchain_configuration"></a>`toolchain_configuration` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>"@rules_ll//ll:current_ll_toolchain_configuration"</code>.<br><br> TODO |
| <a id="ll_library-version_script"></a>`version_script` | <code><a href="https://bazel.build/concepts/labels">Label</a></code>, optional, defaults to <code>None</code>.<br><br> Optional version script used during shared object linking.<br><br>Used if `emit` includes `"shared_object"`. |


<a id="ll_test"></a>
Expand Down
4 changes: 4 additions & 0 deletions ll/args.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,12 @@ def link_executable_args(ctx, in_files, out_file, mode):
args.add_all(flags[BuildSettingInfo].value.split(":"))
elif mode == "shared_object":
args.add_all(ctx.attr.shared_object_link_flags)

for flags in ctx.attr.shared_object_link_string_flags:
args.add_all(flags[BuildSettingInfo].value.split(":"))

if ctx.file.version_script != None:
args.add(ctx.file.version_script, format = "--version-script=%s")
else:
fail("Invalid linking mode")

Expand Down
7 changes: 7 additions & 0 deletions ll/attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ LIBRARY_ATTRS = {
Used if `emit` includes `"shared_object"`.
""",
),
"version_script": attr.label(
doc = """Optional version script used during shared object linking.
Used if `emit` includes `"shared_object"`.
""",
allow_single_file = True,
),
}

BINARY_ATTRS = {
Expand Down
3 changes: 3 additions & 0 deletions ll/inputs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def link_shared_object_inputs(ctx, in_files):
in_files +
ctx.files.data +
ctx.files.deps +
(
[ctx.file.version_script] if ctx.file.version_script != None else []
) +
toolchain.compiler_runtime +
toolchain.cpp_abilib +
toolchain.cpp_stdlib +
Expand Down

0 comments on commit 3ee8095

Please sign in to comment.