blob: 66644b472d56b74930ef7952b9015410a0e51271 [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.
26 "@io_bazel_rules_go//go/config:pure": False,
27 "@io_bazel_rules_go//go/config:static": False,
28
29 # Note: this toolchain is not actually used to perform the build.
30 "//command_line_option:platforms": "//build/platforms:linux_amd64_static",
31}
32
33def _ignore_unused_configuration_impl(_settings, _attr):
34 return _new_settings
35
36# Transition to flip all known-unimportant but varying configuration options to
37# a known, stable value.
38# This is to prevent Bazel from creating extra configurations for possible
39# combinations of options in case the linux_image rule is pulled through build
40# graph fragments that have different options set.
41#
42# Ideally, Bazel would let us mark in a list that we only care about some set
43# of options (or at least let us mark those that we explicitly don't care
44# about, instead of manually setting them to some value). However, this doesn't
45# seem to be possible, thus this transition is a bit of a hack.
46ignore_unused_configuration = transition(
47 implementation = _ignore_unused_configuration_impl,
48 inputs = [],
49 outputs = list(_new_settings.keys()),
50)