Skip to content

Commit

Permalink
Bazel: disable link_extra_lib when building bootloader (#1854)
Browse files Browse the repository at this point in the history
Fixes #1853
  • Loading branch information
cramertj authored Aug 22, 2024
1 parent 9b16c79 commit 7dc10d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bazel/util/transition.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,18 @@ rp2040_bootloader_binary = declare_transtion(
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
"_link_extra_libs": attr.label(default = "//bazel:empty_cc_lib"),
},
flag_overrides = {
# We don't want --custom_malloc to ever apply to the bootloader, so
# always explicitly override it here.
"//command_line_option:custom_malloc": "_malloc",

# Platforms will commonly depend on bootloader components in every
# binary via `link_extra_libs`, so we must drop these deps when
# building the bootloader binaries themselves in order to avoid a
# circular dependency.
"@bazel_tools//tools/cpp:link_extra_libs": "_link_extra_libs",
},
)

Expand Down
5 changes: 5 additions & 0 deletions src/rp2040/boot_stage2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ cc_binary(
"-Wl,--entry=_stage2_boot",
"-T$(location boot_stage2.ld)",
],
# Platforms will commonly depend on bootloader components in every
# binary via `link_extra_libs`, so we must drop these deps when
# building the bootloader binaries themselves in order to avoid a
# circular dependency.
link_extra_lib = "//bazel:empty_cc_lib",
# this does nothing if someone passes --custom_malloc, so the
# rp2040_bootloader_binary transition forcibly clobbers --custom_malloc.
malloc = "//bazel:empty_cc_lib",
Expand Down
5 changes: 5 additions & 0 deletions src/rp2350/boot_stage2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ cc_binary(
copts = ["-fPIC"],
# Incompatible with section garbage collection.
features = ["-gc_sections"],
# Platforms will commonly depend on bootloader components in every
# binary via `link_extra_libs`, so we must drop these deps when
# building the bootloader binaries themselves in order to avoid a
# circular dependency.
link_extra_lib = "//bazel:empty_cc_lib",
linkopts = [
"-Wl,--no-gc-sections",
"-nostartfiles",
Expand Down

0 comments on commit 7dc10d7

Please sign in to comment.