blob: 7a6fbd73fb1820c2493de518180ddf4552ae0ca9 [file] [log] [blame]
Tim Windelschmidt156248b2025-01-10 00:27:45 +01001def _build_static_transition_impl(_settings, _attr):
Lorenz Brun5e4fc2d2020-09-22 18:35:15 +02002 """
Jan Schär0fd36f42025-04-29 10:26:03 +00003 Transition that enables static build of Go and C binaries.
Lorenz Brun5e4fc2d2020-09-22 18:35:15 +02004 """
5 return {
6 "@io_bazel_rules_go//go/config:static": True,
Leopoldbc93c2b2023-01-14 13:12:23 +01007 "//command_line_option:platforms": "//build/platforms:linux_amd64_static",
Lorenz Brun5e4fc2d2020-09-22 18:35:15 +02008 }
9
10build_static_transition = transition(
11 implementation = _build_static_transition_impl,
12 inputs = [],
13 outputs = [
14 "@io_bazel_rules_go//go/config:static",
Leopoldbc93c2b2023-01-14 13:12:23 +010015 "//command_line_option:platforms",
Lorenz Brun5e4fc2d2020-09-22 18:35:15 +020016 ],
17)
Tim Windelschmidt08054ca2025-04-04 01:11:56 +020018
19_new_settings = {
20 # This list should be expanded with any configuration options that end
21 # up reaching this rule with different values across different build
22 # graph paths, but that do not actually influence the kernel build.
23 # Force-setting them to a stable value forces the build configuration
24 # to a stable hash.
25 # See the transition's comment block for more information.
Jan Schär8ffa54e2025-04-29 11:33:39 +000026 "@io_bazel_rules_go//go/config:race": False,
Tim Windelschmidt08054ca2025-04-04 01:11:56 +020027 "@io_bazel_rules_go//go/config:pure": False,
28 "@io_bazel_rules_go//go/config:static": False,
29
30 # Note: this toolchain is not actually used to perform the build.
31 "//command_line_option:platforms": "//build/platforms:linux_amd64_static",
32}
33
34def _ignore_unused_configuration_impl(_settings, _attr):
35 return _new_settings
36
37# Transition to flip all known-unimportant but varying configuration options to
38# a known, stable value.
39# This is to prevent Bazel from creating extra configurations for possible
40# combinations of options in case the linux_image rule is pulled through build
41# graph fragments that have different options set.
42#
43# Ideally, Bazel would let us mark in a list that we only care about some set
44# of options (or at least let us mark those that we explicitly don't care
45# about, instead of manually setting them to some value). However, this doesn't
46# seem to be possible, thus this transition is a bit of a hack.
47ignore_unused_configuration = transition(
48 implementation = _ignore_unused_configuration_impl,
49 inputs = [],
50 outputs = list(_new_settings.keys()),
51)