Skip to content

Commit 4485e63

Browse files
hlopkoirengrig
authored andcommitted
Automated rollback of commit 332379a.
*** Reason for rollback *** Broke Bazel downstream: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1039#72cf19a2-072a-4ca1-ace2-37c458ef8420 Fixes bazelbuild#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: bazelbuild#8622 Tracking issue: bazelbuild#6516 RELNOTES: Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See bazelbuild#8622 f... *** PiperOrigin-RevId: 253544711
1 parent e192491 commit 4485e63

23 files changed

+223
-416
lines changed

scripts/bootstrap/compile.sh

-3
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,6 @@ EOF
273273
# Set up @bazel_tools//platforms properly
274274
mkdir -p ${BAZEL_TOOLS_REPO}/platforms
275275
cp tools/platforms/BUILD.tools ${BAZEL_TOOLS_REPO}/platforms/BUILD
276-
link_file \
277-
"${PWD}/tools/platforms/fail_with_incompatible_use_platforms_repo_for_constraints.bzl" \
278-
"${BAZEL_TOOLS_REPO}/platforms/fail_with_incompatible_use_platforms_repo_for_constraints.bzl"
279276

280277
# Overwrite tools.WORKSPACE, this is only for the bootstrap binary
281278
chmod u+w "${OUTPUT_DIR}/classes/com/google/devtools/build/lib/bazel/rules/tools.WORKSPACE"

site/docs/platforms.md

+14-15
Original file line numberDiff line numberDiff line change
@@ -88,36 +88,35 @@ glibc version of 2.25. (See below for more on Bazel's built-in constraints.)
8888
platform(
8989
name = "linux_x86",
9090
constraint_values = [
91-
"@platforms//os:linux",
92-
"@platforms//cpu:x86_64",
91+
"@bazel_tools//platforms:linux",
92+
"@bazel_tools//platforms:x86_64",
9393
":glibc_2_25",
9494
],
9595
)
9696
```
9797

9898
Note that it is an error for a platform to specify more than one value of the
99-
same constraint setting, such as `@platforms//cpu:x86_64` and
100-
`@platforms//cpu:arm` for `@platforms//cpu:cpu`.
99+
same constraint setting, such as `@bazel_tools//platforms:x86_64` and
100+
`@bazel_tools//platforms:arm` for `@bazel_tools//platforms:cpu`.
101101

102102
## Built-in constraints and platforms
103103

104104
Bazel ships with constraint definitions for the most popular CPU architectures
105-
and operating systems. These are all located in the repository
106-
`@platforms`. This repository is developed at
107-
[github.com/bazelbuild/platforms](https://github.com/bazelbuild/platforms):
105+
and operating systems. These are all located in the package
106+
`@bazel_tools//platforms`:
108107

109-
* `//cpu:cpu` for the CPU architecture, with values `//cpu:x86_32`,
110-
`//cpu:x86_64`, `//cpu:ppc`, `//cpu:arm`, `//cpu:s390x`
111-
* `//os:os` for the operating system, with values `//os:android`,
112-
`//os:freebsd`, `//os:ios`, `//os:linux`, `//os:osx`, `//os:windows`
108+
* `:cpu` for the CPU architecture, with values `:x86_32`, `:x86_64`, `:ppc`,
109+
`:arm`, `:s390x`
110+
* `:os` for the operating system, with values `:android`, `:freebsd`, `:ios`,
111+
`:linux`, `:osx`, `:windows`
113112

114113
There are also the following special platform definitions:
115114

116-
* `@bazel_tools//platforms:host_platform` - represents the CPU and operating
117-
system for the host environment
115+
* `:host_platform` - represents the CPU and operating system for the host
116+
environment
118117

119-
* `@bazel_tools//platforms:target_platform` - represents the CPU and operating
120-
system for the target environment
118+
* `:target_platform` - represents the CPU and operating system for the target
119+
environment
121120

122121
The CPU values used by these two platforms can be specified with the
123122
`--host_cpu` and `--cpu` flags.

site/docs/toolchains.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ We can improve on this solution by using `select` to choose the `compiler`
104104
config_setting(
105105
name = "on_linux",
106106
constraint_values = [
107-
"@platforms//os:linux",
107+
"@bazel_tools//platforms:linux",
108108
],
109109
)
110110

111111
config_setting(
112112
name = "on_windows",
113113
constraint_values = [
114-
"@platforms//os:windows",
114+
"@bazel_tools//platforms:windows",
115115
],
116116
)
117117

@@ -276,12 +276,12 @@ appropriate for a given platform.
276276
toolchain(
277277
name = "barc_linux_toolchain",
278278
exec_compatible_with = [
279-
"@platforms//os:linux",
280-
"@platforms//cpu:x86_64",
279+
"@bazel_tools//platforms:linux",
280+
"@bazel_tools//platforms:x86_64",
281281
],
282282
target_compatible_with = [
283-
"@platforms//os:linux",
284-
"@platforms//cpu:x86_64",
283+
"@bazel_tools//platforms:linux",
284+
"@bazel_tools//platforms:x86_64",
285285
],
286286
toolchain = ":barc_linux",
287287
toolchain_type = ":toolchain_type",
@@ -290,12 +290,12 @@ toolchain(
290290
toolchain(
291291
name = "barc_windows_toolchain",
292292
exec_compatible_with = [
293-
"@platforms//os:windows",
294-
"@platforms//cpu:x86_64",
293+
"@bazel_tools//platforms:windows",
294+
"@bazel_tools//platforms:x86_64",
295295
],
296296
target_compatible_with = [
297-
"@platforms//os:windows",
298-
"@platforms//cpu:x86_64",
297+
"@bazel_tools//platforms:windows",
298+
"@bazel_tools//platforms:x86_64",
299299
],
300300
toolchain = ":barc_windows",
301301
toolchain_type = ":toolchain_type",
@@ -336,7 +336,7 @@ toolchain will be selected based on the target and execution platforms.
336336
platform(
337337
name = "my_target_platform",
338338
constraint_values = [
339-
"@platforms//os:linux",
339+
"@bazel_tools//platforms:linux",
340340
],
341341
)
342342

@@ -351,7 +351,7 @@ bazel build //my_pkg:my_bar_binary --platforms=//my_pkg:my_target_platform
351351
```
352352

353353
Bazel will see that `//my_pkg:my_bar_binary` is being built with a platform that
354-
has `@platforms//os:linux` and therefore resolve the
354+
has `@bazel_tools//platforms:linux` and therefore resolve the
355355
`//bar_tools:toolchain_type` reference to `//bar_tools:barc_linux_toolchain`.
356356
This will end up building `//bar_tools:barc_linux` but not
357357
`//barc_tools:barc_windows`.

src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java

-12
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ public class CoreOptions extends FragmentOptions implements Cloneable {
6868
help = "If true, the genfiles directory is folded into the bin directory.")
6969
public boolean mergeGenfilesDirectory;
7070

71-
@Option(
72-
name = "incompatible_use_platforms_repo_for_constraints",
73-
defaultValue = "false",
74-
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
75-
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
76-
metadataTags = {
77-
OptionMetadataTag.INCOMPATIBLE_CHANGE,
78-
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
79-
},
80-
help = "If true, constraint settings from @bazel_tools are removed.")
81-
public boolean usePlatformsRepoForConstraints;
82-
8371
@Option(
8472
name = "define",
8573
converter = Converters.AssignmentConverter.class,

src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ public RepositoryDirectoryValue.Builder fetch(
8181
static String cpuToConstraint(CPU cpu) {
8282
switch (cpu) {
8383
case X86_32:
84-
return "@platforms//cpu:x86_32";
84+
return "@bazel_tools//platforms:x86_32";
8585
case X86_64:
86-
return "@platforms//cpu:x86_64";
86+
return "@bazel_tools//platforms:x86_64";
8787
case PPC:
88-
return "@platforms//cpu:ppc";
88+
return "@bazel_tools//platforms:ppc";
8989
case ARM:
90-
return "@platforms//cpu:arm";
90+
return "@bazel_tools//platforms:arm";
9191
case AARCH64:
92-
return "@platforms//cpu:aarch64";
92+
return "@bazel_tools//platforms:aarch64";
9393
case S390X:
94-
return "@platforms//cpu:s390x";
94+
return "@bazel_tools//platforms:s390x";
9595
default:
9696
// Unknown, so skip it.
9797
return null;
@@ -102,13 +102,13 @@ static String cpuToConstraint(CPU cpu) {
102102
static String osToConstraint(OS os) {
103103
switch (os) {
104104
case DARWIN:
105-
return "@platforms//os:osx";
105+
return "@bazel_tools//platforms:osx";
106106
case FREEBSD:
107-
return "@platforms//os:freebsd";
107+
return "@bazel_tools//platforms:freebsd";
108108
case LINUX:
109-
return "@platforms//os:linux";
109+
return "@bazel_tools//platforms:linux";
110110
case WINDOWS:
111-
return "@platforms//os:windows";
111+
return "@bazel_tools//platforms:windows";
112112
default:
113113
// Unknown, so skip it.
114114
return null;

src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ Matches an expected configuration state (expressed as Bazel flags or platform co
327327
config_setting(
328328
name = "64bit_glibc_2_25",
329329
constraint_values = [
330-
"@platforms//cpu:x86_64",
330+
"@bazel_tools//platforms:x86_64",
331331
"//example:glibc_2_25",
332332
]
333333
)

src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public RuleDefinition.Metadata getMetadata() {
6767
<p>Each <code>constraint_setting</code> has an extensible set of associated
6868
<code>constraint_value</code>s. Usually these are defined in the same package, but sometimes a
6969
different package will introduce new values for an existing setting. For instance, the predefined
70-
setting <code>@platforms//cpu:cpu</code> can be extended with a custom value in order to
70+
setting <code>@bazel_tools//platforms:cpu</code> can be extended with a custom value in order to
7171
define a platform targeting an obscure cpu architecture.
7272
7373
<!-- #END_BLAZE_RULE -->*/

src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public Metadata getMetadata() {
6767
<pre class="code">
6868
constraint_value(
6969
name = "mips",
70-
constraint_setting = "@platforms//cpu:cpu",
70+
constraint_setting = "@bazel_tools//platforms:cpu",
7171
)
7272
</pre>
7373

src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
4949
5050
<p>Each <code>constraint_value</code> in this list must be for a different
5151
<code>constraint_setting</code>. For example, you cannot define a platform that requires the
52-
cpu architecture to be both <code>@platforms//cpu:x86_64</code> and
52+
cpu architecture to be both <code>@bazel_tools//platforms:x86_64</code> and
5353
<code>@bazel_tools//platforms:arm</code>.
5454
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
5555
.add(
@@ -130,8 +130,8 @@ public Metadata getMetadata() {
130130
platform(
131131
name = "linux_arm",
132132
constraint_values = [
133-
"@platforms//os:linux",
134-
"@platforms//cpu:arm",
133+
"@bazel_tools//platforms:linux",
134+
"@bazel_tools//platforms:arm",
135135
],
136136
)
137137
</pre>
@@ -177,8 +177,8 @@ public Metadata getMetadata() {
177177
platform(
178178
name = "parent",
179179
constraint_values = [
180-
"@platforms//os:linux",
181-
"@platforms//cpu:arm",
180+
"@bazel_tools//platforms:linux",
181+
"@bazel_tools//platforms:arm",
182182
],
183183
remote_execution_properties = """
184184
parent properties
@@ -188,7 +188,7 @@ public Metadata getMetadata() {
188188
name = "child_a",
189189
parents = [":parent"],
190190
constraint_values = [
191-
"@platforms//cpu:x86_64",
191+
"@bazel_tools//platforms:x86_64",
192192
],
193193
remote_execution_properties = """
194194
child a properties
@@ -210,8 +210,8 @@ public Metadata getMetadata() {
210210
211211
<ul>
212212
<li>
213-
"child_a" has the constraint values "@platforms//os:linux" (inherited from the
214-
parent) and "@platforms//cpu:x86_64" (set directly on the platform). It has the
213+
"child_a" has the constraint values "@bazel_tools//platforms:linux" (inherited from the
214+
parent) and "@bazel_tools//platforms:x86_64" (set directly on the platform). It has the
215215
"remote_execution_properties" set to "child a properties"
216216
</li>
217217
<li>

src/test/java/com/google/devtools/build/lib/analysis/mock/BazelAnalysisMock.java

-21
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,12 @@ private BazelAnalysisMock() {
6767
@Override
6868
public List<String> getWorkspaceContents(MockToolsConfig config) {
6969
String bazelToolWorkspace = config.getPath("/bazel_tools_workspace").getPathString();
70-
String bazelPlatformsWorkspace = config.getPath("/platforms").getPathString();
7170
String localConfigPlatformWorkspace =
7271
config.getPath("/local_config_platform_workspace").getPathString();
7372

7473
return new ArrayList<>(
7574
ImmutableList.of(
7675
"local_repository(name = 'bazel_tools', path = '" + bazelToolWorkspace + "')",
77-
"local_repository(name = 'platforms', path = '" + bazelPlatformsWorkspace + "')",
7876
"local_repository(name = 'local_config_xcode', path = '/local_config_xcode')",
7977
"local_repository(name = 'com_google_protobuf', path = '/protobuf')",
8078
"bind(name = 'android/sdk', actual='@bazel_tools//tools/android:sdk')",
@@ -101,25 +99,6 @@ public void setupMockClient(MockToolsConfig config, List<String> workspaceConten
10199
config.create("/local_config_xcode/WORKSPACE");
102100
config.create("/protobuf/WORKSPACE");
103101
config.overwrite("WORKSPACE", workspaceContents.toArray(new String[workspaceContents.size()]));
104-
config.create("/platforms/WORKSPACE", "workspace(name = 'platforms')");
105-
config.create("/platforms/BUILD");
106-
config.create(
107-
"/platforms/cpu/BUILD",
108-
"constraint_setting(name = 'cpu')",
109-
"constraint_value(name = 'x86_32', constraint_setting = ':cpu')",
110-
"constraint_value(name = 'x86_64', constraint_setting = ':cpu')",
111-
"constraint_value(name = 'ppc', constraint_setting = ':cpu')",
112-
"constraint_value(name = 'arm', constraint_setting = ':cpu')",
113-
"constraint_value(name = 'aarch64', constraint_setting = ':cpu')",
114-
"constraint_value(name = 's390x', constraint_setting = ':cpu')");
115-
116-
config.create(
117-
"/platforms/os/BUILD",
118-
"constraint_setting(name = 'os')",
119-
"constraint_value(name = 'linux', constraint_setting = ':os')",
120-
"constraint_value(name = 'osx', constraint_setting = ':os')",
121-
"constraint_value(name = 'freebsd', constraint_setting = ':os')",
122-
"constraint_value(name = 'windows', constraint_setting = ':os')");
123102
config.create("/bazel_tools_workspace/WORKSPACE", "workspace(name = 'bazel_tools')");
124103
Runfiles runfiles = Runfiles.create();
125104
for (String filename :

src/test/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunctionTest.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public static class CpuConstraintTest {
4545
public static Collection createInputValues() {
4646
return ImmutableList.of(
4747
// CPU value tests.
48-
new Object[] {CPU.X86_64, "@platforms//cpu:x86_64"},
49-
new Object[] {CPU.X86_32, "@platforms//cpu:x86_32"},
50-
new Object[] {CPU.PPC, "@platforms//cpu:ppc"},
51-
new Object[] {CPU.ARM, "@platforms//cpu:arm"},
52-
new Object[] {CPU.AARCH64, "@platforms//cpu:aarch64"},
53-
new Object[] {CPU.S390X, "@platforms//cpu:s390x"});
48+
new Object[] {CPU.X86_64, "@bazel_tools//platforms:x86_64"},
49+
new Object[] {CPU.X86_32, "@bazel_tools//platforms:x86_32"},
50+
new Object[] {CPU.PPC, "@bazel_tools//platforms:ppc"},
51+
new Object[] {CPU.ARM, "@bazel_tools//platforms:arm"},
52+
new Object[] {CPU.AARCH64, "@bazel_tools//platforms:aarch64"},
53+
new Object[] {CPU.S390X, "@bazel_tools//platforms:s390x"});
5454
}
5555

5656
private final CPU testCpu;
@@ -81,10 +81,10 @@ public static class OsConstraintTest {
8181
public static Collection createInputValues() {
8282
return ImmutableList.of(
8383
// OS value tests.
84-
new Object[] {OS.LINUX, "@platforms//os:linux"},
85-
new Object[] {OS.DARWIN, "@platforms//os:osx"},
86-
new Object[] {OS.FREEBSD, "@platforms//os:freebsd"},
87-
new Object[] {OS.WINDOWS, "@platforms//os:windows"});
84+
new Object[] {OS.LINUX, "@bazel_tools//platforms:linux"},
85+
new Object[] {OS.DARWIN, "@bazel_tools//platforms:osx"},
86+
new Object[] {OS.FREEBSD, "@bazel_tools//platforms:freebsd"},
87+
new Object[] {OS.WINDOWS, "@bazel_tools//platforms:windows"});
8888
}
8989

9090
private final OS testOs;
@@ -112,9 +112,9 @@ public void unknownOsConstraint() {
112112
@RunWith(JUnit4.class)
113113
public static class FunctionTest extends BuildViewTestCase {
114114
private static final ConstraintSettingInfo CPU_CONSTRAINT =
115-
ConstraintSettingInfo.create(Label.parseAbsoluteUnchecked("@platforms//cpu:cpu"));
115+
ConstraintSettingInfo.create(Label.parseAbsoluteUnchecked("@bazel_tools//platforms:cpu"));
116116
private static final ConstraintSettingInfo OS_CONSTRAINT =
117-
ConstraintSettingInfo.create(Label.parseAbsoluteUnchecked("@platforms//os:os"));
117+
ConstraintSettingInfo.create(Label.parseAbsoluteUnchecked("@bazel_tools//platforms:os"));
118118

119119
@Test
120120
public void generateConfigRepository() throws Exception {

src/test/shell/bazel/platforms_test.sh

-7
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,5 @@ EOF
7171
fail "Bazel failed to build @platforms"
7272
}
7373

74-
function test_incompatible_use_platforms_repo_for_constraints() {
75-
# We test that a built-in @platforms repository is buildable.
76-
bazel build --incompatible_use_platforms_repo_for_constraints @bazel_tools//platforms:all &> \
77-
$TEST_log && fail "Build passed when we expected an error."
78-
expect_log "Constraints from @bazel_tools//platforms have been removed."
79-
}
80-
8174
run_suite "platform mapping test"
8275

src/test/shell/integration/discard_graph_edges_test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function test_packages_cleared() {
271271
package_count="$(extract_histogram_count "$histo_file" \
272272
'devtools\.build\.lib\..*\.Package$')"
273273
# A few packages aren't cleared.
274-
[[ "$package_count" -le 18 ]] \
274+
[[ "$package_count" -le 17 ]] \
275275
|| fail "package count $package_count too high"
276276
glob_count="$(extract_histogram_count "$histo_file" "GlobValue$")"
277277
[[ "$glob_count" -le 1 ]] \

src/test/shell/testenv.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ toolchain(
408408
name = "py_toolchain",
409409
toolchain = ":py_runtime_pair",
410410
toolchain_type = "@bazel_tools//tools/python:toolchain_type",
411-
target_compatible_with = ["@platforms//os:windows"],
411+
target_compatible_with = ["@bazel_tools//platforms:windows"],
412412
)
413413
EOF
414414
}

0 commit comments

Comments
 (0)