Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions examples/bzlmod/custom/toolchain/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ arm_none_eabi_toolchain(
],
)

# this dummy is used to test that transitive deps are included
cc_library(
name = "start_dep",
srcs = ["dummy.c"],
)

# always linked in with the toolchain below
cc_library(
name = "start",
srcs = ["start.c"],
additional_linker_inputs = ["link.ld"],
linkopts = ["-T $(location :link.ld)"],
deps = [":start_dep"],
)

# Cortex-M4 toolchain that always links `:start`
Expand Down
1 change: 1 addition & 0 deletions examples/bzlmod/custom/toolchain/dummy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void dummy() {}
13 changes: 13 additions & 0 deletions toolchain/transitions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@ _toolchain_transition = transition(
)

def _toolchain_transition_library_impl(ctx):
to_list = lambda x: [x] if x else []

default_info = ctx.attr.src[DefaultInfo]
cc_info = ctx.attr.src[CcInfo]

linker_input_files = []

# We need to recreate default_info since not all files are propagated with
# the transition. Specifically, the following are known to not propagate:
# * additional_linker_inputs (e.g. linker scripts)
# * deps (i.e. other libraries this one depends on)
for linker_input in cc_info.linking_context.linker_inputs.to_list():
linker_input_files.extend(linker_input.additional_inputs)

for lib in linker_input.libraries:
linker_input_files.extend(to_list(lib.static_library))
# I'm not sure if these below are needed
linker_input_files.extend(to_list(lib.pic_static_library))
linker_input_files.extend(to_list(lib.dynamic_library))

return [
DefaultInfo(
files = depset(
Expand Down
Loading