From 7e12863696a2b25d8f76f45e7740d20122855142 Mon Sep 17 00:00:00 2001 From: hlopko Date: Mon, 17 Jun 2019 02:58:10 -0700 Subject: [PATCH] Automated rollback of commit 332379ad6f8c49b0e087b504d73d3483c529e399. *** Reason for rollback *** Broke Bazel downstream: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1039#72cf19a2-072a-4ca1-ace2-37c458ef8420 Fixes https://github.com/bazelbuild/bazel/issues/8645. *** Original change description *** Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/bazelbuild/bazel/issues/8622 Tracking issue: https://github.com/bazelbuild/bazel/issues/6516 RELNOTES: Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See https://github.com/bazelbuild/bazel/issues/8622 f... *** PiperOrigin-RevId: 253544711 --- scripts/bootstrap/compile.sh | 3 - site/docs/platforms.md | 29 ++- site/docs/toolchains.md | 24 +-- .../lib/analysis/config/CoreOptions.java | 12 -- .../LocalConfigPlatformFunction.java | 20 +-- .../lib/rules/config/ConfigRuleClasses.java | 2 +- .../rules/platform/ConstraintSettingRule.java | 2 +- .../rules/platform/ConstraintValueRule.java | 2 +- .../lib/rules/platform/PlatformRule.java | 16 +- .../lib/analysis/mock/BazelAnalysisMock.java | 21 --- .../LocalConfigPlatformFunctionTest.java | 24 +-- src/test/shell/bazel/platforms_test.sh | 7 - .../integration/discard_graph_edges_test.sh | 2 +- src/test/shell/testenv.sh | 2 +- tools/cpp/BUILD | 52 +++--- tools/cpp/BUILD.static.freebsd | 14 +- tools/cpp/BUILD.toolchains.tpl | 4 +- tools/cpp/BUILD.windows.tpl | 28 +-- tools/osx/crosstool/BUILD.toolchains | 4 +- tools/osx/crosstool/osx_archs.bzl | 26 +-- tools/platforms/BUILD | 153 +++++----------- tools/platforms/BUILD.tools | 167 +++++------------- ...ble_use_platforms_repo_for_constraints.bzl | 25 --- 23 files changed, 223 insertions(+), 416 deletions(-) delete mode 100644 tools/platforms/fail_with_incompatible_use_platforms_repo_for_constraints.bzl diff --git a/scripts/bootstrap/compile.sh b/scripts/bootstrap/compile.sh index 8a52f141cbdf51..90782f93e33414 100755 --- a/scripts/bootstrap/compile.sh +++ b/scripts/bootstrap/compile.sh @@ -273,9 +273,6 @@ EOF # Set up @bazel_tools//platforms properly mkdir -p ${BAZEL_TOOLS_REPO}/platforms cp tools/platforms/BUILD.tools ${BAZEL_TOOLS_REPO}/platforms/BUILD - link_file \ - "${PWD}/tools/platforms/fail_with_incompatible_use_platforms_repo_for_constraints.bzl" \ - "${BAZEL_TOOLS_REPO}/platforms/fail_with_incompatible_use_platforms_repo_for_constraints.bzl" # Overwrite tools.WORKSPACE, this is only for the bootstrap binary chmod u+w "${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE" diff --git a/site/docs/platforms.md b/site/docs/platforms.md index 777a6eb978367f..4c3079e2b59e52 100644 --- a/site/docs/platforms.md +++ b/site/docs/platforms.md @@ -88,36 +88,35 @@ glibc version of 2.25. (See below for more on Bazel's built-in constraints.) platform( name = "linux_x86", constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:x86_64", ":glibc_2_25", ], ) ``` Note that it is an error for a platform to specify more than one value of the -same constraint setting, such as `@platforms//cpu:x86_64` and -`@platforms//cpu:arm` for `@platforms//cpu:cpu`. +same constraint setting, such as `@bazel_tools//platforms:x86_64` and +`@bazel_tools//platforms:arm` for `@bazel_tools//platforms:cpu`. ## Built-in constraints and platforms Bazel ships with constraint definitions for the most popular CPU architectures -and operating systems. These are all located in the repository -`@platforms`. This repository is developed at -[github.com/bazelbuild/platforms](https://github.com/bazelbuild/platforms): +and operating systems. These are all located in the package +`@bazel_tools//platforms`: -* `//cpu:cpu` for the CPU architecture, with values `//cpu:x86_32`, - `//cpu:x86_64`, `//cpu:ppc`, `//cpu:arm`, `//cpu:s390x` -* `//os:os` for the operating system, with values `//os:android`, - `//os:freebsd`, `//os:ios`, `//os:linux`, `//os:osx`, `//os:windows` +* `:cpu` for the CPU architecture, with values `:x86_32`, `:x86_64`, `:ppc`, + `:arm`, `:s390x` +* `:os` for the operating system, with values `:android`, `:freebsd`, `:ios`, + `:linux`, `:osx`, `:windows` There are also the following special platform definitions: -* `@bazel_tools//platforms:host_platform` - represents the CPU and operating - system for the host environment +* `:host_platform` - represents the CPU and operating system for the host + environment -* `@bazel_tools//platforms:target_platform` - represents the CPU and operating - system for the target environment +* `:target_platform` - represents the CPU and operating system for the target + environment The CPU values used by these two platforms can be specified with the `--host_cpu` and `--cpu` flags. diff --git a/site/docs/toolchains.md b/site/docs/toolchains.md index 747af158947de6..998f623ba96b84 100644 --- a/site/docs/toolchains.md +++ b/site/docs/toolchains.md @@ -104,14 +104,14 @@ We can improve on this solution by using `select` to choose the `compiler` config_setting( name = "on_linux", constraint_values = [ - "@platforms//os:linux", + "@bazel_tools//platforms:linux", ], ) config_setting( name = "on_windows", constraint_values = [ - "@platforms//os:windows", + "@bazel_tools//platforms:windows", ], ) @@ -276,12 +276,12 @@ appropriate for a given platform. toolchain( name = "barc_linux_toolchain", exec_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:x86_64", ], target_compatible_with = [ - "@platforms//os:linux", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:x86_64", ], toolchain = ":barc_linux", toolchain_type = ":toolchain_type", @@ -290,12 +290,12 @@ toolchain( toolchain( name = "barc_windows_toolchain", exec_compatible_with = [ - "@platforms//os:windows", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:windows", + "@bazel_tools//platforms:x86_64", ], target_compatible_with = [ - "@platforms//os:windows", - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:windows", + "@bazel_tools//platforms:x86_64", ], toolchain = ":barc_windows", toolchain_type = ":toolchain_type", @@ -336,7 +336,7 @@ toolchain will be selected based on the target and execution platforms. platform( name = "my_target_platform", constraint_values = [ - "@platforms//os:linux", + "@bazel_tools//platforms:linux", ], ) @@ -351,7 +351,7 @@ bazel build //my_pkg:my_bar_binary --platforms=//my_pkg:my_target_platform ``` Bazel will see that `//my_pkg:my_bar_binary` is being built with a platform that -has `@platforms//os:linux` and therefore resolve the +has `@bazel_tools//platforms:linux` and therefore resolve the `//bar_tools:toolchain_type` reference to `//bar_tools:barc_linux_toolchain`. This will end up building `//bar_tools:barc_linux` but not `//barc_tools:barc_windows`. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java index 61b9d947bdd1ec..c03f9ed49555e3 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java @@ -68,18 +68,6 @@ public class CoreOptions extends FragmentOptions implements Cloneable { help = "If true, the genfiles directory is folded into the bin directory.") public boolean mergeGenfilesDirectory; - @Option( - name = "incompatible_use_platforms_repo_for_constraints", - defaultValue = "false", - documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS, - effectTags = {OptionEffectTag.AFFECTS_OUTPUTS}, - metadataTags = { - OptionMetadataTag.INCOMPATIBLE_CHANGE, - OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES - }, - help = "If true, constraint settings from @bazel_tools are removed.") - public boolean usePlatformsRepoForConstraints; - @Option( name = "define", converter = Converters.AssignmentConverter.class, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java index 35379910d63f31..1209c5d3fc94f2 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java @@ -81,17 +81,17 @@ public RepositoryDirectoryValue.Builder fetch( static String cpuToConstraint(CPU cpu) { switch (cpu) { case X86_32: - return "@platforms//cpu:x86_32"; + return "@bazel_tools//platforms:x86_32"; case X86_64: - return "@platforms//cpu:x86_64"; + return "@bazel_tools//platforms:x86_64"; case PPC: - return "@platforms//cpu:ppc"; + return "@bazel_tools//platforms:ppc"; case ARM: - return "@platforms//cpu:arm"; + return "@bazel_tools//platforms:arm"; case AARCH64: - return "@platforms//cpu:aarch64"; + return "@bazel_tools//platforms:aarch64"; case S390X: - return "@platforms//cpu:s390x"; + return "@bazel_tools//platforms:s390x"; default: // Unknown, so skip it. return null; @@ -102,13 +102,13 @@ static String cpuToConstraint(CPU cpu) { static String osToConstraint(OS os) { switch (os) { case DARWIN: - return "@platforms//os:osx"; + return "@bazel_tools//platforms:osx"; case FREEBSD: - return "@platforms//os:freebsd"; + return "@bazel_tools//platforms:freebsd"; case LINUX: - return "@platforms//os:linux"; + return "@bazel_tools//platforms:linux"; case WINDOWS: - return "@platforms//os:windows"; + return "@bazel_tools//platforms:windows"; default: // Unknown, so skip it. return null; diff --git a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java index 25aedb6e0a203f..7522324fc94949 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java @@ -327,7 +327,7 @@ Matches an expected configuration state (expressed as Bazel flags or platform co config_setting( name = "64bit_glibc_2_25", constraint_values = [ - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:x86_64", "//example:glibc_2_25", ] ) diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java index e9416be459cc6e..511619a1b6fcab 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java @@ -67,7 +67,7 @@ public RuleDefinition.Metadata getMetadata() {

Each constraint_setting has an extensible set of associated constraint_values. Usually these are defined in the same package, but sometimes a different package will introduce new values for an existing setting. For instance, the predefined -setting @platforms//cpu:cpu can be extended with a custom value in order to +setting @bazel_tools//platforms:cpu can be extended with a custom value in order to define a platform targeting an obscure cpu architecture. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java index 2ca844a86277e6..43ccf342c7401b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java @@ -67,7 +67,7 @@ public Metadata getMetadata() {

 constraint_value(
     name = "mips",
-    constraint_setting = "@platforms//cpu:cpu",
+    constraint_setting = "@bazel_tools//platforms:cpu",
 )
 
diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java index bafdb7b0e7e9b4..c54d05a0aeccf1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java @@ -49,7 +49,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)

Each constraint_value in this list must be for a different constraint_setting. For example, you cannot define a platform that requires the - cpu architecture to be both @platforms//cpu:x86_64 and + cpu architecture to be both @bazel_tools//platforms:x86_64 and @bazel_tools//platforms:arm. */ .add( @@ -130,8 +130,8 @@ public Metadata getMetadata() { platform( name = "linux_arm", constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:arm", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:arm", ], ) @@ -177,8 +177,8 @@ public Metadata getMetadata() { platform( name = "parent", constraint_values = [ - "@platforms//os:linux", - "@platforms//cpu:arm", + "@bazel_tools//platforms:linux", + "@bazel_tools//platforms:arm", ], remote_execution_properties = """ parent properties @@ -188,7 +188,7 @@ public Metadata getMetadata() { name = "child_a", parents = [":parent"], constraint_values = [ - "@platforms//cpu:x86_64", + "@bazel_tools//platforms:x86_64", ], remote_execution_properties = """ child a properties @@ -210,8 +210,8 @@ public Metadata getMetadata() {