Skip to content

Commit 61bf88b

Browse files
authored
Merge pull request #158 from davidtwco/build-std
Propose build-std as a 2025H1 goal
2 parents 8531567 + bd4aa37 commit 61bf88b

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

src/2025h1/build-std.md

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# build-std
2+
3+
| Metadata | |
4+
| -------- | ---------------- |
5+
| Owner(s) | Rust team at Arm |
6+
| Teams | [cargo] |
7+
| Status | Proposed |
8+
9+
*Arm's Rust team is @davidtwco, @adamgemmell, @jacobbramley, @JamieCunliffe and @Jamesbarford. This
10+
goal will be primarily worked on by @adamgemmell, but @davidtwco can always be contacted for
11+
updates.*
12+
13+
## Summary
14+
15+
Write an RFC for a minimum viable product (MVP) of build-std which has the potential to be
16+
stabilised once implemented (as opposed to the currently implemented MVP which is only suitable for
17+
experimentation and testing), and then implement it.
18+
19+
## Motivation
20+
21+
build-std is a well-known unstable feature in Cargo which enables Cargo to re-build the standard
22+
library, this is useful for a variety of reasons:
23+
24+
- Building the standard library for targets which do not ship with a pre-compiled standard library.
25+
- Optimising the standard library for known hardware, such as with non-baseline target features
26+
or options which optimise for code size. This is a common use case for embedded developers.
27+
- Re-building the standard library with different configuration options (e.g. changing the
28+
optimisation level, using flags which change the ABI, or which add additional exploit
29+
mitigations).
30+
- Re-building the standard library with different `cfg`s (e.g. disabling `backtrace` in std), to
31+
the extent that such configurations are supported by the standard library.
32+
- Stabilisation of various compiler flags which change the ABI, add additional exploit
33+
mitigations (such as `-Zsanitizers=cfi` or `-Zbranch-protection`), or which otherwise only make
34+
sense to use when the entire program is compiled with the flag (including std) is blocked on
35+
these being unable to be used properly without being able to rebuild std.
36+
37+
These features are more useful for some subsets of the Rust community, such as embedded developers
38+
where optimising for size can be more important and where the targets often don't ship with a
39+
pre-compiled std.
40+
41+
The fifty-thousand foot view of the work involved in this feature is:
42+
43+
- Having the standard library sources readily available that match the compiler.
44+
- Being able to build those sources without using a nightly toolchain, which has many
45+
possible solutions.
46+
- Having a blessed way to build at least `core` without Cargo, which some users like
47+
Rust for Linux would like.
48+
- This would be optional but may be a side-effect of whatever mechanism for build-std
49+
the MVP RFC eventually proposes.
50+
- Being able to tell the compiler to use the resulting prebuilt standard library sources
51+
instead of the built-in standard library, in a standard way.
52+
- Integrating all of the above into Cargo.
53+
- Making sure all of this works for targets that don't have a pre-built std.
54+
55+
Rust for Linux and some other projects have a requirement to build core themselves without Cargo
56+
(ideally using the same stable compiler they use for the rest of their project), which is a shared
57+
requirement with build-std, as whatever mechanism these projects end up using could be re-used by
58+
the implementation of build-std and vice-versa.
59+
60+
### The status quo
61+
62+
build-std is currently an unstable feature in Cargo which hasn't seen much development or progress
63+
since its initial development in 2019/2020. There are a variety of issues in the
64+
[wg-cargo-std-aware][wg-cargo-std-aware] repository which vary from concrete bugs in the current
65+
experimental implementation to vague "investigate and think about this" issues, which make the
66+
feature difficult to make progress on.
67+
68+
Some of the work required for this exists in the current perma-unstable `-Zbuild-std`
69+
implementation, which may be re-used if appropriate.
70+
71+
Prior to the submission of this goal, this goal has been discussed with the cargo team and
72+
leads of the compiler and library teams, ensuring that this goal's owners have liaisons from
73+
stakeholder teams and the support of the primary teams involved in the design and
74+
implementation.
75+
76+
[wg-cargo-std-aware]: https://github.com/rust-lang/wg-cargo-std-aware
77+
78+
### The next 6 months
79+
80+
There are two primary objectives of this goal in its first six months:
81+
82+
- Firstly, we will write an MVP RFC that will limit the scope of the feature and make it easier
83+
to make progress on build-std.
84+
85+
It is intended that this RFC will summarize all of the previous discussion, use cases and
86+
feedback on build-std. In this documenting of the current state of build-std, this RFC
87+
will be well-positioned to propose which use cases should and should not be resolved by
88+
build-std (for the final feature, not just this MVP). For example, this RFC will decide
89+
whether patching or modifying std is a supported use case for build-std.
90+
91+
For those use cases solved by build-std, the RFC will select a subset for the new MVP of
92+
build-std. It is intended that this MVP be sufficiently useful and complete that it could
93+
be stabilised. The design of the MVP will be forward-compatible with all of the other use
94+
cases that build-std is intended to solve.
95+
96+
It is hoped that this RFC should demonstrate a thorough understanding of the design space
97+
of build-std and give the responsible upstream teams confidence in our ownership of this
98+
feature, and enabling those teams to make a fully informed decision on any proposals made.
99+
100+
- Next, after and conditional on acceptance of this RFC, we will proceed with its
101+
implementation.
102+
103+
### The "shiny future" we are working towards
104+
105+
After the approval and implementation of the MVP RFC, there will naturally be follow-up use cases
106+
which can be designed and implemented to complete the build-std feature.
107+
108+
## Design axioms
109+
110+
- Enabling build-std without changing any compilation options or configuration should produce an
111+
equivalent library to that distributed by the project.
112+
- Avoid precluding future extensions to build-std.
113+
- build-std should allow std/alloc/core to be treated more like other dependencies than currently.
114+
- This represents a general move away from treating std/alloc/core as a special case.
115+
116+
## Ownership and team asks
117+
118+
| Subgoal | Owner(s) or team(s) | Notes |
119+
| ---------------------------------------------- | -------------------- | ----- |
120+
| Discussion and moral support | ![Team][] [cargo] | |
121+
| Stabilise MVP of build-std | @adamgemmell | |
122+
| ↳ Author RFC | @adamgemmell | |
123+
| ↳ Implementation | @adamgemmell | |
124+
| ↳ Standard reviews | ![Team][] [cargo] | |
125+
126+
### Definitions
127+
128+
Definitions for terms used above:
129+
130+
* *Discussion and moral support* is the lowest level offering, basically committing the team to nothing but good vibes and general support for this endeavor.
131+
* *Author RFC* and *Implementation* means actually writing the code, document, whatever.
132+
* *Design meeting* means holding a synchronous meeting to review a proposal and provide feedback (no decision expected).
133+
* *RFC decisions* means reviewing an RFC and deciding whether to accept.
134+
* *Org decisions* means reaching a decision on an organizational or policy matter.
135+
* *Secondary review* of an RFC means that the team is "tangentially" involved in the RFC and should be expected to briefly review.
136+
* *Stabilizations* means reviewing a stabilization and report and deciding whether to stabilize.
137+
* *Standard reviews* refers to reviews for PRs against the repository; these PRs are not expected to be unduly large or complicated.
138+
* *Prioritized nominations* refers to prioritized lang-team response to nominated issues, with the expectation that there will be *some* response from the next weekly triage meeting.
139+
* *Dedicated review* means identifying an individual (or group of individuals) who will review the changes, as they're expected to require significant context.
140+
* Other kinds of decisions:
141+
* [Lang team experiments](https://lang-team.rust-lang.org/how_to/experiment.html) are used to add nightly features that do not yet have an RFC. They are limited to trusted contributors and are used to resolve design details such that an RFC can be written.
142+
* Compiler [Major Change Proposal (MCP)](https://forge.rust-lang.org/compiler/mcp.html) is used to propose a 'larger than average' change and get feedback from the compiler team.
143+
* Library [API Change Proposal (ACP)](https://std-dev-guide.rust-lang.org/development/feature-lifecycle.html) describes a change to the standard library.
144+
145+
## Frequently asked questions
146+
147+
None yet.

0 commit comments

Comments
 (0)