Skip to content

feat(link): add additional_linker_inputs and link_output_dirs attrs#2

Merged
Silvia-weka merged 1 commit into
masterfrom
feat/additional-link-outputs
May 28, 2026
Merged

feat(link): add additional_linker_inputs and link_output_dirs attrs#2
Silvia-weka merged 1 commit into
masterfrom
feat/additional-link-outputs

Conversation

@Silvia-weka

Copy link
Copy Markdown
Collaborator

Two new attributes on runnable_attrs (d_binary, d_test):

additional_linker_inputs: label_list of files to make visible to the
link action's sandbox. Matches cc_library.additional_linker_inputs.
Already-supported use case: linker scripts referenced via
$(execpath ...) in linkopts. Now also: linker wrapper scripts
invoked via --ld-path=, and tools the wrapper itself spawns.

link_output_dirs: string_list of TreeArtifact directory names the
link action will produce in addition to the executable. Declared
in link_action via ctx.actions.declare_directory and (on the
cc_common.link path) passed to cc_common.link's additional_outputs,
so a linker wrapper can populate them and downstream rules can
consume them via DefaultInfo.files / a custom provider.

Plumbing:

  • link_action now returns a struct(executable, additional_outputs). binary.bzl and test.bzl unpack and surface additional_outputs via DefaultInfo.files.
  • link_with_d_action takes additional_outputs as a parameter and declares them on the action; LDC itself doesn't see them, they're purely for downstream consumption.
  • linkopts now go through ctx.expand_location in compilation_action (against additional_linker_inputs), matching cc_library.linkopts semantics. The expanded form propagates via DInfo.linker_flags; link_action no longer adds ctx.attr.linkopts a second time (was a pre-existing double-add masked by the lack of expansion).

Two new attributes on runnable_attrs (d_binary, d_test):

  additional_linker_inputs: label_list of files to make visible to the
    link action's sandbox. Matches cc_library.additional_linker_inputs.
    Already-supported use case: linker scripts referenced via
    $(execpath ...) in linkopts. Now also: linker wrapper scripts
    invoked via --ld-path=, and tools the wrapper itself spawns.

  link_output_dirs: string_list of TreeArtifact directory names the
    link action will produce in addition to the executable. Declared
    in link_action via ctx.actions.declare_directory and (on the
    cc_common.link path) passed to cc_common.link's additional_outputs,
    so a linker wrapper can populate them and downstream rules can
    consume them via DefaultInfo.files / a custom provider.

Plumbing:
  - link_action now returns a struct(executable, additional_outputs).
    binary.bzl and test.bzl unpack and surface additional_outputs via
    DefaultInfo.files.
  - link_with_d_action takes additional_outputs as a parameter and
    declares them on the action; LDC itself doesn't see them, they're
    purely for downstream consumption.
  - linkopts now go through ctx.expand_location in compilation_action
    (against additional_linker_inputs), matching cc_library.linkopts
    semantics. The expanded form propagates via DInfo.linker_flags;
    link_action no longer adds ctx.attr.linkopts a second time
    (was a pre-existing double-add masked by the lack of expansion).
@Silvia-weka Silvia-weka merged commit a0bbcfc into master May 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant