Bazel: disable link_extra_lib when building bootloader (#1854)

Fixes #1853
This commit is contained in:
Taylor Cramer 2024-08-22 09:56:51 -07:00 committed by GitHub
parent 9b16c797b4
commit 7dc10d7aad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View file

@ -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",
},
)

View file

@ -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",

View file

@ -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",