aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Greg Estren <gregce@google.com>2016-05-11 02:18:35 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-05-11 10:24:13 +0000
commitf4aecbb1a72baf0e7bc728c07dc0724c604b1f9c (patch)
tree5268c532fb77706d78e37f084cddc2fd621c31c9 /src/main/java/com/google/devtools/build
parent67db65757828195f2d85fdc19becf3e8cdb86699 (diff)
Dynamic configurations: have HostTransition just clone the
original options if they're already from the host. This fixes an obscure incompatibility between Bazel's flag invocation policy infrastructure and multiple host configurations. In short, when multiple host configurations are possible, policy settings may not get consistently applied. Bazel invocation policies: https://github.com/bazelbuild/bazel/blo[]d24e2b69789ea54762ab034fdafc205cdcecea5/src/main/protobuf/invocation_policy.proto -- MOS_MIGRATED_REVID=122014371
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/HostTransition.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/HostTransition.java b/src/main/java/com/google/devtools/build/lib/analysis/config/HostTransition.java
index 207b2f9915..2ea6a2fd2e 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/HostTransition.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/HostTransition.java
@@ -23,7 +23,25 @@ public final class HostTransition implements PatchTransition {
@Override
public BuildOptions apply(BuildOptions options) {
- return options.createHostOptions(false);
+ if (options.get(BuildConfiguration.Options.class).isHost) {
+ // If the input already comes from the host configuration, just return the existing values.
+ //
+ // We don't do this just for convenience: if an
+ // {@link com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.InvocationPolicy}
+ // overrides option defaults, {@link FragmentOptions#getHost} won't honor that policy. That's
+ // because it uses its own options parser that's not aware of the policy. This can create
+ // problems for, e.g., {@link JavaOptions#getHost}, which promotes --host_foo flags to
+ // --foo flags. That works the first time you do it (since both of the original values
+ // were policy-processed). But not subsequent times.
+ //
+ // There are various ways to solve this problem (pass the policy to host options computation,
+ // manually set host.hostFoo = original.hostFoo). But those raise larger questions about the
+ // nature of host/target relationships, so for the time being this is a straightforward
+ // and practical fix.
+ return options.clone();
+ } else {
+ return options.createHostOptions(false);
+ }
}
@Override