treewide: remove build_static_transition
We now build everything statically on Linux. This means we don't need
the build_static_transition anymore, as it has become a no-op.
Change-Id: Id6b978daf09bf3e8e252d00da3795909d7ce3b75
Reviewed-on: https://review.monogon.dev/c/monogon/+/4414
Tested-by: Jenkins CI
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
diff --git a/osbase/build/def.bzl b/osbase/build/def.bzl
deleted file mode 100644
index 7b5f231..0000000
--- a/osbase/build/def.bzl
+++ /dev/null
@@ -1,93 +0,0 @@
-load("@bazel_skylib//lib:paths.bzl", "paths")
-
-def _build_static_transition_impl(_settings, _attr):
- """
- Transition that enables static build of Go and C binaries.
- """
- return {
- "@io_bazel_rules_go//go/config:static": True,
- "@toolchain_cc_mngn//buildmode:static": True,
- }
-
-build_static_transition = transition(
- implementation = _build_static_transition_impl,
- inputs = [],
- outputs = [
- "@io_bazel_rules_go//go/config:static",
- "@toolchain_cc_mngn//buildmode:static",
- ],
-)
-
-def forward_impl(ctx):
- # We can't pass DefaultInfo through as-is, since Bazel forbids executable
- # if it's a file declared in a different target. To emulate that, symlink
- # to the original executable, if there is one.
- default_info = ctx.attr.dep[DefaultInfo]
- new_executable = None
- original_executable = default_info.files_to_run.executable
- runfiles = default_info.default_runfiles
- if original_executable:
- # In order for the symlink to have the same basename as the original
- # executable (important in the case of proto plugins), put it in a
- # subdirectory named after the label to prevent collisions.
- new_executable = ctx.actions.declare_file(paths.join(ctx.label.name, original_executable.basename))
- ctx.actions.symlink(
- output = new_executable,
- target_file = original_executable,
- is_executable = True,
- )
- runfiles = runfiles.merge(ctx.runfiles([new_executable]))
-
- return [DefaultInfo(
- files = default_info.files,
- runfiles = runfiles,
- executable = new_executable,
- )]
-
-build_static_target = rule(
- cfg = build_static_transition,
- implementation = forward_impl,
- attrs = {
- "dep": attr.label(mandatory = True),
- },
- doc = """Applies build_static_transition to a target.""",
-)
-
-_new_settings = {
- # This list should be expanded with any configuration options that end
- # up reaching this rule with different values across different build
- # graph paths, but that do not actually influence the kernel build.
- # Force-setting them to a stable value forces the build configuration
- # to a stable hash.
- # See the transition's comment block for more information.
- "@io_bazel_rules_go//go/config:static": False,
- "@toolchain_cc_mngn//buildmode:static": True,
-}
-
-def _ignore_unused_configuration_impl(_settings, _attr):
- return _new_settings
-
-# Transition to flip all known-unimportant but varying configuration options to
-# a known, stable value.
-# This is to prevent Bazel from creating extra configurations for possible
-# combinations of options in case the linux_image rule is pulled through build
-# graph fragments that have different options set.
-#
-# Ideally, Bazel would let us mark in a list that we only care about some set
-# of options (or at least let us mark those that we explicitly don't care
-# about, instead of manually setting them to some value). However, this doesn't
-# seem to be possible, thus this transition is a bit of a hack.
-ignore_unused_configuration = transition(
- implementation = _ignore_unused_configuration_impl,
- inputs = [],
- outputs = list(_new_settings.keys()),
-)
-
-ignore_unused_configuration_target = rule(
- cfg = ignore_unused_configuration,
- implementation = forward_impl,
- attrs = {
- "dep": attr.label(mandatory = True),
- },
- doc = """Applies ignore_unused_configuration transition to a target.""",
-)
diff --git a/osbase/build/mkcpio/def.bzl b/osbase/build/mkcpio/def.bzl
index b917506..0dc46fa 100644
--- a/osbase/build/mkcpio/def.bzl
+++ b/osbase/build/mkcpio/def.bzl
@@ -1,4 +1,3 @@
-load("//osbase/build:def.bzl", "build_static_transition")
load("//osbase/build/fsspec:def.bzl", "FSSpecInfo", "fsspec_core_impl")
def _node_initramfs_impl(ctx):
@@ -10,8 +9,6 @@
return [DefaultInfo(runfiles = ctx.runfiles(files = [initramfs]), files = depset([initramfs]))]
node_initramfs = rule(
- # Attach static transition to ensure all binaries added to the initramfs are static binaries.
- cfg = build_static_transition,
implementation = _node_initramfs_impl,
doc = """
Build a node initramfs. The initramfs will contain a basic /dev directory and all the files specified by the
diff --git a/osbase/build/mkerofs/def.bzl b/osbase/build/mkerofs/def.bzl
index 0be0568..2b2f422 100644
--- a/osbase/build/mkerofs/def.bzl
+++ b/osbase/build/mkerofs/def.bzl
@@ -1,4 +1,3 @@
-load("//osbase/build:def.bzl", "build_static_transition")
load("//osbase/build/fsspec:def.bzl", "FSSpecInfo", "fsspec_core_impl")
def _erofs_image_impl(ctx):
@@ -10,8 +9,6 @@
return [DefaultInfo(files = depset([fs_out]))]
erofs_image = rule(
- # Attach static transition to ensure all binaries added to the EROFS are static binaries.
- cfg = build_static_transition,
implementation = _erofs_image_impl,
doc = """
Build an EROFS. All files specified in files and all specified symlinks will be contained.
diff --git a/osbase/build/mkpayload/def.bzl b/osbase/build/mkpayload/def.bzl
index 287f94d..51f2ff1 100644
--- a/osbase/build/mkpayload/def.bzl
+++ b/osbase/build/mkpayload/def.bzl
@@ -6,7 +6,6 @@
load("@rules_cc//cc:action_names.bzl", "OBJ_COPY_ACTION_NAME")
load("@rules_cc//cc:find_cc_toolchain.bzl", "CC_TOOLCHAIN_ATTRS", "find_cpp_toolchain", "use_cc_toolchain")
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
-load("//osbase/build:def.bzl", "build_static_transition")
load("//osbase/build/mkverity:def.bzl", "VerityInfo")
def _efi_unified_kernel_image_impl(ctx):
@@ -80,7 +79,6 @@
return [DefaultInfo(files = depset([image]), runfiles = ctx.runfiles(files = [image]))]
efi_unified_kernel_image = rule(
- cfg = build_static_transition,
implementation = _efi_unified_kernel_image_impl,
attrs = {
"kernel": attr.label(
diff --git a/osbase/build/mkverity/def.bzl b/osbase/build/mkverity/def.bzl
index bb5b8a4..417c883 100644
--- a/osbase/build/mkverity/def.bzl
+++ b/osbase/build/mkverity/def.bzl
@@ -1,5 +1,3 @@
-load("//osbase/build:def.bzl", "build_static_transition")
-
# VerityInfo is emitted by verity_image, and contains a file enclosing a
# singular dm-verity target table.
VerityInfo = provider(
@@ -48,7 +46,6 @@
]
verity_image = rule(
- cfg = build_static_transition,
implementation = _verity_image_impl,
doc = """
Build a dm-verity target image by appending Verity metadata to the source
diff --git a/osbase/test/ktest/ktest.bzl b/osbase/test/ktest/ktest.bzl
index 5fc93e8..96ea31f 100644
--- a/osbase/test/ktest/ktest.bzl
+++ b/osbase/test/ktest/ktest.bzl
@@ -18,7 +18,6 @@
Ktest provides a macro to run tests under a normal Metropolis node kernel
"""
-load("//osbase/build:def.bzl", "build_static_transition")
load("//osbase/build/fsspec:def.bzl", "FSSpecInfo", "fsspec_core_impl")
_KTEST_SCRIPT = """
@@ -31,7 +30,7 @@
initramfs_name = ctx.label.name + ".cpio.zst"
initramfs = ctx.actions.declare_file(initramfs_name)
- fsspec_core_impl(ctx, ctx.executable._mkcpio, initramfs, [("/init", ctx.attr._ktest_init[0]), ("/tester", ctx.attr.tester[0])], [ctx.attr._earlydev])
+ fsspec_core_impl(ctx, ctx.executable._mkcpio, initramfs, [("/init", ctx.attr._ktest_init), ("/tester", ctx.attr.tester)], [ctx.attr._earlydev])
script_file = ctx.actions.declare_file(ctx.label.name + ".sh")
@@ -46,7 +45,7 @@
is_executable = True,
)
- runfiles = ctx.runfiles(files = [ctx.file._ktest, initramfs, ctx.file.kernel, ctx.file.tester])
+ runfiles = ctx.runfiles(files = [ctx.file._ktest, initramfs, ctx.file.kernel])
runfiles = runfiles.merge(ctx.attr._ktest[DefaultInfo].default_runfiles)
return [DefaultInfo(
@@ -64,8 +63,7 @@
mandatory = True,
executable = True,
allow_single_file = True,
- # Runs inside the given kernel, needs to be build for Linux/static
- cfg = build_static_transition,
+ cfg = "target",
),
"files": attr.string_keyed_label_dict(
allow_files = True,
@@ -73,8 +71,6 @@
Dictionary of Labels to String, placing a given Label's output file in the initramfs at the location
specified by the String value. The specified labels must only have a single output.
""",
- # Attach static transition to ensure all binaries added to the initramfs are static binaries.
- cfg = build_static_transition,
),
"symlinks": attr.string_dict(
default = {},
@@ -92,7 +88,6 @@
""",
providers = [FSSpecInfo],
allow_files = True,
- cfg = build_static_transition,
),
"kernel": attr.label(
default = Label("//osbase/test/ktest:linux-testing"),
@@ -110,7 +105,7 @@
),
"_ktest_init": attr.label(
default = Label("//osbase/test/ktest/init"),
- cfg = build_static_transition,
+ cfg = "target",
executable = True,
allow_single_file = True,
),