-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Crash when defining a Starlark transition involving platforms #8936
Copy link
Copy link
Closed
Labels
P1I'll work on this now. (Assignee required)I'll work on this now. (Assignee required)team-Configurabilityplatforms, toolchains, cquery, select(), config transitionsplatforms, toolchains, cquery, select(), config transitions
Description
I'm trying to create a Starlark split transition that changes the current platform based on a flag. Code:
touch WORKSPACE
cat >rules.bzl <<EOF
def _my_flag_impl(ctx):
return [config_common.FeatureFlagInfo(value = ctx.build_setting_value)]
my_flag = rule(
implementation = _my_flag_impl,
build_setting = config.string_list(flag = True),
)
def _my_transition_impl(inputs, outputs):
result = {}
for platform in inputs["//:my_flag"]:
result[platform] = {"//command_line_option:platforms": [platform]}
return result
_my_transition = transition(
implementation = _my_transition_impl,
inputs = ["//:my_flag"],
outputs = [
"//command_line_option:platforms",
],
)
def _my_rule_impl(ctx):
return []
my_rule = rule(
implementation = _my_rule_impl,
attrs = {
"deps": attr.label_list(
cfg = _my_transition,
),
"_whitelist_function_transition": attr.label(
default = "@bazel_tools//tools/whitelists/function_transition_whitelist",
),
},
)
EOF
cat > BUILD <<EOF
load(":rules.bzl", "my_flag", "my_rule")
my_flag(
name = "my_flag",
build_setting_default = [],
)
cc_binary(
name = "bin",
srcs = ["bin.cc"],
)
my_rule(
name = "my_rule",
deps = [":bin"],
)
EOF
bazel build --//:my_flag=//:foo,//:bar :my_rule
The result is a big ugly crash. The relevant part of the stack trace is:
java.lang.ClassCastException: class java.lang.String cannot be cast to class com.google.devtools.build.lib.cmdline.Label (java.lang.String is in module java.base of loader 'bootstrap'; com.google.devtools.build.lib.cmdline.Label is in unnamed module of loader 'app')
at com.google.devtools.build.lib.skyframe.PlatformMappingValue.computeMapping(PlatformMappingValue.java:218)
at com.google.devtools.build.lib.skyframe.PlatformMappingValue.lambda$map$0(PlatformMappingValue.java:191)
at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4875)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2276)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2154)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2044)
at com.google.common.cache.LocalCache.get(LocalCache.java:3951)
at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4870)
at com.google.devtools.build.lib.skyframe.PlatformMappingValue.map(PlatformMappingValue.java:191)
at com.google.devtools.build.lib.skyframe.BuildConfigurationValue.keyWithPlatformMapping(BuildConfigurationValue.java:68)
at com.google.devtools.build.lib.analysis.config.ConfigurationResolver.resolveConfigurations(ConfigurationResolver.java:302)
at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.computeDependencies(ConfiguredTargetFunction.java:584)
at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:317)
at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:451)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1I'll work on this now. (Assignee required)I'll work on this now. (Assignee required)team-Configurabilityplatforms, toolchains, cquery, select(), config transitionsplatforms, toolchains, cquery, select(), config transitions