Be more permissive when dealing with rules which have
ExecutionPlatformConstraintsAllowed set to PER_TARGET and also have an
alread-existing exec_compatible_with attribute.

PiperOrigin-RevId: 201238805
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
index 75fd947..fba4c92 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -703,13 +703,6 @@
               "Attribute %s is inherited multiple times in %s ruleclass",
               attrName,
               name);
-          if (attrName.equals("exec_compatible_with")
-              && parent.executionPlatformConstraintsAllowed
-                  == ExecutionPlatformConstraintsAllowed.PER_TARGET) {
-            // This attribute should not be inherited because executionPlatformConstraintsAllowed is
-            // not inherited.
-            continue;
-          }
           attributes.put(attrName, attribute);
         }
 
@@ -762,13 +755,8 @@
       if (type == RuleClassType.PLACEHOLDER) {
         Preconditions.checkNotNull(ruleDefinitionEnvironmentHashCode, this.name);
       }
-      if (executionPlatformConstraintsAllowed == ExecutionPlatformConstraintsAllowed.PER_TARGET) {
-        // Only rules that allow per target execution constraints need this attribute.
-        Preconditions.checkState(
-            !this.attributes.containsKey("exec_compatible_with"),
-            "Rule %s should not already define the attribute \"exec_compatible_with\""
-                + " because executionPlatformConstraintsAllowed is set to PER_TARGET",
-            key);
+      if (executionPlatformConstraintsAllowed == ExecutionPlatformConstraintsAllowed.PER_TARGET
+          && !this.contains("exec_compatible_with")) {
         this.add(
             attr("exec_compatible_with", BuildType.LABEL_LIST)
                 .allowedFileTypes()