|
| 1 | +# build-std |
| 2 | + |
| 3 | +| Metadata | | |
| 4 | +| :-- | :-- | |
| 5 | +| Point of contact | @davidtwco | |
| 6 | +| Teams | <!-- TEAMS WITH ASKS --> | |
| 7 | +| Task owners | <!-- TASK OWNERS --> | |
| 8 | +| Status | Proposed | |
| 9 | +| Zulip channel | N/A | |
| 10 | +| Tracking issue | [rust-lang/rust-project-goals#274] | |
| 11 | + |
| 12 | +## Summary |
| 13 | + |
| 14 | +Over the next six months, we will continue our efforts to write an RFC for a |
| 15 | +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 |
| 17 | +is only suitable for 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 |
| 22 | +re-build the standard library, this is useful for a variety of reasons: |
| 23 | + |
| 24 | +- Building the standard library for targets which do not ship with a |
| 25 | + pre-compiled standard library. |
| 26 | +- Optimising the standard library for known hardware, such as with non-baseline |
| 27 | + target features or options which optimise for code size. This is a common use |
| 28 | + case for embedded developers. |
| 29 | +- Re-building the standard library with different configuration options (e.g. |
| 30 | + changing the optimisation level, using flags which change the ABI, or which |
| 31 | + add additional exploit mitigations). |
| 32 | +- Re-building the standard library with different `cfg`s (e.g. disabling |
| 33 | + `backtrace` in std), to the extent that such configurations are supported by |
| 34 | + the standard library. |
| 35 | +- Stabilisation of various compiler flags which change the ABI, add additional |
| 36 | + exploit mitigations (such as `-Zsanitizers=cfi` or `-Zbranch-protection`), or |
| 37 | + which otherwise only make sense to use when the entire program is compiled |
| 38 | + with the flag (including std) is blocked on these being unable to be used |
| 39 | + properly without being able to rebuild std. |
| 40 | + |
| 41 | +These features are more useful for some subsets of the Rust community, such as |
| 42 | +embedded developers where optimising for size can be more important and where |
| 43 | +the targets often don't ship with a pre-compiled std. |
| 44 | + |
| 45 | +The fifty-thousand foot view of the work involved in this feature is: |
| 46 | + |
| 47 | +- Having the standard library sources readily available that match the compiler. |
| 48 | +- Being able to build those sources without using a nightly toolchain, which has |
| 49 | + many possible solutions. |
| 50 | +- Having a blessed way to build at least `core` without Cargo, which some users |
| 51 | + like Rust for Linux would like. |
| 52 | + - This would be optional but may be a side-effect of whatever mechanism for |
| 53 | + build-std the MVP RFC eventually proposes. |
| 54 | +- Being able to tell the compiler to use the resulting prebuilt standard library |
| 55 | + sources instead of the built-in standard library, in a standard way. |
| 56 | +- Integrating all of the above into Cargo. |
| 57 | +- Making sure all of this works for targets that don't have a pre-built std. |
| 58 | + |
| 59 | +Rust for Linux and some other projects have a requirement to build core |
| 60 | +themselves without Cargo (ideally using the same stable compiler they use for |
| 61 | +the rest of their project), which is a shared requirement with build-std, as |
| 62 | +whatever mechanism these projects end up using could be re-used by the |
| 63 | +implementation of build-std and vice-versa. |
| 64 | + |
| 65 | +### The status quo |
| 66 | + |
| 67 | +build-std is currently an unstable feature in Cargo which hasn't seen much |
| 68 | +development or progress since its initial development in 2019/2020. There are a |
| 69 | +variety of issues in the [wg-cargo-std-aware][wg-cargo-std-aware] repository |
| 70 | +which vary from concrete bugs in the current experimental implementation to |
| 71 | +vague "investigate and think about this" issues, which make the feature |
| 72 | +difficult to make progress on. |
| 73 | + |
| 74 | +Some of the work required for this exists in the current perma-unstable |
| 75 | +`-Zbuild-std` implementation, which may be re-used if appropriate. |
| 76 | + |
| 77 | +In 2025H1, the goal owners established a regular sync meeting with liasons from |
| 78 | +the library, compiler and Cargo teams which have been successful in creating a |
| 79 | +draft RFC that continues to be iterated on and refined before being shared with |
| 80 | +the broader project. |
| 81 | + |
| 82 | +[wg-cargo-std-aware]: https://github.com/rust-lang/wg-cargo-std-aware |
| 83 | + |
| 84 | +### The next 6 months |
| 85 | + |
| 86 | +There are two primary objectives of this goal in its first six months: |
| 87 | + |
| 88 | +- Continue to refine and draft a complete RFC for build-std, including a |
| 89 | + detailed history of the feature and surrounding discussions going back to its |
| 90 | + origins in 2015. |
| 91 | +- Next, after and conditional on acceptance of the RFC, proceed with its |
| 92 | + implementation. |
| 93 | + |
| 94 | +As part of the goal, the goal owners will regularly be in contact with representatives from |
| 95 | +relevant teams in our regular sync call established during the 2025H1 goal period, and will commit |
| 96 | +to posting updates on our progress on a monthly basis. |
| 97 | + |
| 98 | +### The "shiny future" we are working towards |
| 99 | + |
| 100 | +After the approval and implementation of the MVP RFC, there will naturally be |
| 101 | +follow-up use cases which can be designed and implemented to complete the |
| 102 | +build-std feature. |
| 103 | + |
| 104 | +## Design axioms |
| 105 | + |
| 106 | +- Enabling build-std without changing any compilation options or configuration |
| 107 | + should produce an equivalent library to that distributed by the project. |
| 108 | +- Avoid precluding future extensions to build-std. |
| 109 | +- build-std should allow std/alloc/core to be treated more like other |
| 110 | + dependencies than currently. |
| 111 | + - This represents a general move away from treating std/alloc/core as a |
| 112 | + special case. |
| 113 | + |
| 114 | +## Ownership and team asks |
| 115 | + |
| 116 | +| Task | Owner(s) or team(s) | Notes | |
| 117 | +| ---------------------------- | ------------------------------------- | ------------------------------------------------------------------- | |
| 118 | +| Discussion and moral support | ![Team][] [cargo], [libs], [compiler] | @ehuss, @joshtriplett and @wesleywiser already regularly contribute | |
| 119 | +| Author RFC | @davidtwco, @adamgemmell | Continue draft produced in 2025H1 | |
| 120 | +| Design meeting | ![Team][] [cargo], [libs], [compiler] | Review initial RFC draft | |
| 121 | +| RFC decision | ![Team][] [cargo], [libs], [compiler] | Decide to approve RFC. | |
| 122 | +| Implementation | @davidtwco, @adamgemmell | | |
| 123 | +| Standard reviews | ![Team][] [cargo], [libs], [compiler] | | |
| 124 | + |
| 125 | +### Definitions |
| 126 | + |
| 127 | +Definitions for terms used above: |
| 128 | + |
| 129 | +* *Discussion and moral support* is the lowest level offering, basically |
| 130 | + committing the team to nothing but good vibes and general support for this |
| 131 | + endeavor. |
| 132 | +* *Author RFC* and *Implementation* means actually writing the code, document, |
| 133 | + whatever. |
| 134 | +* *Design meeting* means holding a synchronous meeting to review a proposal and |
| 135 | + provide feedback (no decision expected). |
| 136 | +* *RFC decisions* means reviewing an RFC and deciding whether to accept. |
| 137 | +* *Org decisions* means reaching a decision on an organizational or policy |
| 138 | + matter. |
| 139 | +* *Secondary review* of an RFC means that the team is "tangentially" involved in |
| 140 | + the RFC and should be expected to briefly review. |
| 141 | +* *Stabilizations* means reviewing a stabilization and report and deciding |
| 142 | + whether to stabilize. |
| 143 | +* *Standard reviews* refers to reviews for PRs against the repository; these PRs |
| 144 | + are not expected to be unduly large or complicated. |
| 145 | +* *Prioritized nominations* refers to prioritized lang-team response to |
| 146 | + nominated issues, with the expectation that there will be *some* response from |
| 147 | + the next weekly triage meeting. |
| 148 | +* *Dedicated review* means identifying an individual (or group of individuals) |
| 149 | + who will review the changes, as they're expected to require significant |
| 150 | + context. |
| 151 | +* Other kinds of decisions: |
| 152 | + * [Lang team experiments][experiment] are used to add nightly features that |
| 153 | + do not yet have an RFC. They are limited to trusted contributors and are |
| 154 | + used to resolve design details such that an RFC can be written. |
| 155 | + * Compiler [Major Change Proposal (MCP)][mcp] is used to propose a 'larger |
| 156 | + than average' change and get feedback from the compiler team. |
| 157 | + * Library [API Change Proposal (ACP)][acp] describes a change to the |
| 158 | + standard library. |
| 159 | + |
| 160 | +[experiment]: https://lang-team.rust-lang.org/how_to/experiment.html |
| 161 | +[mcp]: https://forge.rust-lang.org/compiler/mcp.html |
| 162 | +[acp]: https://std-dev-guide.rust-lang.org/development/feature-lifecycle.html |
| 163 | + |
| 164 | +## Frequently asked questions |
| 165 | + |
| 166 | +None yet. |
0 commit comments