xref: /aosp_15_r20/external/bazelbuild-rules_rust/COMPATIBILITY.md (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan# `rules_rust` backwards compatibility policy
2*d4726bddSHONG Yifan
3*d4726bddSHONG YifanThis document defines the backwards compatibility policy for rules_rust and
4*d4726bddSHONG Yifandefines the process for making compatibility breaking changes. Any exception to
5*d4726bddSHONG Yifanthis process will have to be thoroughly discussed and there will have to be a
6*d4726bddSHONG Yifanconsensus between maintainers that the exception should be granted.
7*d4726bddSHONG Yifan
8*d4726bddSHONG Yifan## What is a compatibility breaking change?
9*d4726bddSHONG Yifan
10*d4726bddSHONG YifanA backwards compatible change has the property that a build that is green,
11*d4726bddSHONG Yifancorrect, is using stable APIs of `rules_rust`, and is using a supported version
12*d4726bddSHONG Yifanof Bazel before the change is still green and correct after the change. In
13*d4726bddSHONG Yifanpractice it means that users should not have to modify their project source
14*d4726bddSHONG Yifanfiles, their `BUILD` files, their `bzl` files, their `rust_toolchain`
15*d4726bddSHONG Yifandefinitions, their platform definitions, or their build settings.
16*d4726bddSHONG Yifan
17*d4726bddSHONG YifanA backwards compatible release has the property that it only contains backward
18*d4726bddSHONG Yifancompatible changes.
19*d4726bddSHONG Yifan
20*d4726bddSHONG Yifan`rules_rust` follow [SemVer 2.0.0](https://semver.org/). `rules_rust` promise
21*d4726bddSHONG Yifanthat all minor version number and patch version number releases only contain
22*d4726bddSHONG Yifanbackwards compatible changes.
23*d4726bddSHONG Yifan
24*d4726bddSHONG Yifan`rules_rust` don't make any guarantees about compatibility between a released
25*d4726bddSHONG Yifanversion and the state of the `rules_rust` at HEAD.
26*d4726bddSHONG Yifan
27*d4726bddSHONG YifanBackwards incompatible changes will have to follow a process in order to be
28*d4726bddSHONG Yifanreleased. Users will be given at least one release where the old behavior is
29*d4726bddSHONG Yifanstill present but deprecated to allow smooth migration of their project to the
30*d4726bddSHONG Yifannew behavior.
31*d4726bddSHONG Yifan
32*d4726bddSHONG Yifan### Compatibility before 1.0
33*d4726bddSHONG Yifan
34*d4726bddSHONG YifanAll minor version number releases before version 1.0 can be backwards incompatible.
35*d4726bddSHONG YifanBackwards incompatible changes still have to follow the the process, but minimum
36*d4726bddSHONG Yifantime for migration is reduced to 2 weeks.
37*d4726bddSHONG Yifan
38*d4726bddSHONG Yifan## What Bazel versions are supported?
39*d4726bddSHONG Yifan
40*d4726bddSHONG Yifan`rules_rust` support the current Bazel LTS at the time of a `rules_rust`
41*d4726bddSHONG Yifanrelease.
42*d4726bddSHONG Yifan
43*d4726bddSHONG YifanSupport for the current Bazel rolling release is on the best effort basis. If
44*d4726bddSHONG Yifanthe CI build of `rules_rust` against the current Bazel rolling release is green,
45*d4726bddSHONG Yifanit has to stay green. If the build is already red (because the new Bazel rolling
46*d4726bddSHONG Yifanrelease had incompatible changes that broke `rules_rust`), it is acceptable to
47*d4726bddSHONG Yifanmerge PRs leaving the build red as long as the reason for failure remains the
48*d4726bddSHONG Yifansame. We hope red CI with the current rolling release will be rare.
49*d4726bddSHONG Yifan
50*d4726bddSHONG Yifan`rules_rust` don't promise all new `rules_rust` features available to the
51*d4726bddSHONG Yifancurrent Bazel rolling release to be be available to the current Bazel LTS
52*d4726bddSHONG Yifanrelease (because Bazel compatibility policy doesn't allow us to make that
53*d4726bddSHONG Yifanpromise, and some new features of `rules_rust` require new Bazel features that
54*d4726bddSHONG Yifanare only available in Bazel rolling releases). `rules_rust` will aim that new
55*d4726bddSHONG Yifanfeatures available to the current Bazel rolling release will be available to the
56*d4726bddSHONG Yifannext Bazel LTS release at latest.
57*d4726bddSHONG Yifan
58*d4726bddSHONG YifanWhenever there is a new Bazel LTS release, all releases of `rules_rust` will maintain
59*d4726bddSHONG Yifansupport for the older LTS version for at least 3 months unless Bazel doesn't allow this.
60*d4726bddSHONG Yifan
61*d4726bddSHONG Yifan## What host platforms are supported?
62*d4726bddSHONG Yifan
63*d4726bddSHONG YifanPlatforms subject to backwards compatibility policy are
64*d4726bddSHONG Yifan`x86_64-unknown-linux-gnu` and `x86_64-apple-darwin` (platforms supported by `rules_rust`).
65*d4726bddSHONG YifanProcess for moving a best effort platform to a supported platform is consensus-based.
66*d4726bddSHONG Yifan
67*d4726bddSHONG Yifan## What are the stable APIs of `rules_rust`?
68*d4726bddSHONG Yifan
69*d4726bddSHONG Yifan`//rust:defs.bzl` is subject to the backwards compatibility policy. That means
70*d4726bddSHONG Yifanthat anything directly accessible from this file is considered stable.
71*d4726bddSHONG Yifan
72*d4726bddSHONG Yifan`//rust/private/…` is not subject to the backwards compatibility policy. Content
73*d4726bddSHONG Yifanof this package is an implementation detail.
74*d4726bddSHONG Yifan
75*d4726bddSHONG Yifan`//cargo:defs.bzl` is subject to the backwards compatibility policy.
76*d4726bddSHONG Yifan
77*d4726bddSHONG Yifan`//cargo`, `//util`, `//tools`, `//test`, `//examples`, `//bindgen`, `//proto`,
78*d4726bddSHONG Yifan`//wasm_bindgen` and any packages not mentioned by this document are by default
79*d4726bddSHONG Yifannot subject to the backwards compatibility policy.
80*d4726bddSHONG Yifan
81*d4726bddSHONG YifanExperimental build settings are not subject to the backward compatibility
82*d4726bddSHONG Yifanpolicy. They should be added to `//rust:experimental.bzl`.
83*d4726bddSHONG Yifan
84*d4726bddSHONG YifanIncompatible build settings are subject to the backward compatibility policy,
85*d4726bddSHONG Yifanmeaning the behavior of the flag cannot change in a backwards incompatible way.
86*d4726bddSHONG YifanThey should be added to `//rust:incompatible.bzl`.
87*d4726bddSHONG Yifan
88*d4726bddSHONG YifanBug fixes are not a breaking change by default. We'll use Common Sense (and we
89*d4726bddSHONG Yifanwill pull in more maintainers and the community to discuss) if we see a certain
90*d4726bddSHONG Yifanbug fix is controversial. Incompatible changes to
91*d4726bddSHONG Yifan`//cargo:defs.bzl` that make `cargo_build_script` more accurately
92*d4726bddSHONG Yifanfollow cargo's behaviour are considered bug fixes.
93*d4726bddSHONG Yifan
94*d4726bddSHONG Yifan## How to make a backwards incompatible change?
95*d4726bddSHONG Yifan
96*d4726bddSHONG Yifan1. Create a GitHub issue (example:
97*d4726bddSHONG Yifan[Split rust_library into smaller rules#591](https://github.com/bazelbuild/rules_rust/issues/591)).
98*d4726bddSHONG Yifan2. Describe the change, motivation for the change, provide migration
99*d4726bddSHONG Yifaninstructions/tooling.
100*d4726bddSHONG Yifan3. Add a build setting into `//rust:incompatible.bzl` that removes the old
101*d4726bddSHONG Yifanbehavior (whenever possible) or changes the current behavior (when just
102*d4726bddSHONG Yifanremoving the old behavior is not possible). Ideally, users should not need to
103*d4726bddSHONG Yifanmanually flip incompatible flags.
104*d4726bddSHONG Yifan4. Mention the link to the GitHub issue in error messages. Do not add a
105*d4726bddSHONG Yifandeprecation warning (warnings make the deprecation visible to every user
106*d4726bddSHONG Yifanbuilding a project, not only to the maintainers of the project or the rules).
107*d4726bddSHONG Yifan5. Mention the issue in the `CHANGELOG` file.
108*d4726bddSHONG Yifan6. Give the community 3 months from the first release mentioning the issue until
109*d4726bddSHONG Yifanthe flag flip to migrate.
110