interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / CONTRIBUTING.md

152 lines · 6452 bytes Raw Blame History Rendered
1# Contributing to `libc`
2
3Welcome! If you are reading this document, it means you are interested in
4contributing to the `libc` crate.
5
6## v1.0 Roadmap
7
8`libc` has two active branches: `main` and `libc-0.2`. `main` is for active
9development of the upcoming v1.0 release, and should be the target of all pull
10requests. `libc-0.2` is for updates to the currently released version.
11
12If a pull request to `main` is a good candidate for inclusion in an `0.2.x`
13release, include `@rustbot label stable-nominated` in a comment to propose this.
14Almost everything should be included in stable, unless it involves breaking
15changes.
16
17Once a `stable-nominated` PR targeting `main` has merged, it can be cherry
18picked to the `libc-0.2` branch. A maintainer will likely do these cherry picks
19in a batch before a release, so there is no need for any action as a PR author.
20
21When cherry picking, run the following after branching from `libc-0.2`:
22`git cherry-pick -xe commit-sha-on-main` (or `git cherry-pick -xe
23start-sha^..end-sha` if a range of commits is needed). `git` will automatically
24add the "cherry picked from commit" note, but try to add a backport note so the
25original PR gets crosslinked:
26
27```
28# ... original commit message ...
29
30(backport <https://github.com/rust-lang/libc/pull/1234>) # add manually
31(cherry picked from commit 104b6a4ae31c726814c36318dc718470cc96e167) # added by git
32```
33
34Cherry pick PRs can then target `libc-0.2`.
35
36See the [tracking issue](https://github.com/rust-lang/libc/issues/3248) for
37details.
38
39## Adding an API
40
41Want to use an API which currently isn't bound in `libc`? It's quite easy to add
42one!
43
44If you are adding API for a header that doesn't already have some bindings,
45create a new file in the appropriate location in `src/new`. These modules should
46approximately match source trees: try to follow the patterns that are there but
47don't hesitate to ask maintainers if guidance is needed.
48
49If some bindings for the relevant header has already been added outside of
50`src/new`, it is fine to extend what already exists. Everything outside of
51`src/new` uses a hierarchial structure: a single path from root to a leaf node
52represents a single platform, and adding API at a given level will make it
53available on all children.
54
55We are currently in a reorganization process, moving from the hierarchial
56structure to the source-mapped structure in `src/new`.
57
58New items (i.e. functions, constants etc.) should also be added to the symbol
59list(s) found in the `libc-test/semver` directory. These lists track of what
60API is public in the libc crate and ensures they remain available between
61changes to the crate. If the new symbol(s) are available on all supported Unixes
62it should be added to `unix.txt` list[^1], otherwise they should be added to the
63OS-specific list(s).
64
65With that in mind, the steps for adding a new API are:
66
671. Determine where to add your API.
682. Add the API, including adding new symbol(s) to the semver lists.
693. Send a PR to this repo.
704. Wait for CI to pass, fixing errors.
715. Wait for a merge!
72
73[^1]: Note that this list has nothing to do with any Unix or Posix standard,
74 it's just a list shared among all OSs that declare `#[cfg(unix)]`.
75
76## Test before you commit
77
78There are a few relevant tests in `libc`:
79
801. `libc-test` is the main test suite. This can be run locally with `cargo test
81 --workspace`.
82
83 If needed, the `skip_*()` functions in `libc-test/build.rs` can be used to
84 skip testing specific API.
852. Style checker and formatter, located at [`./ci/style.py`][style-py]. Running
86 this also invokes the code formatter. (This also formats code within macros,
87 which `cargo fmt` won't do.)
883. `ci/verify-build.py`, which checks the build on a wide range of targets.
89 Typically there is no need to run this locally.
90
91[style-py]: https://github.com/rust-lang/libc/blob/main/ci/style.py
92
93## Submitting a Pull Request
94
95When you submit a PR, please follow these guidelines to give your PR the best
96chance of being accepted:
97
981. All new API should be added to `libc-test/semver`, which makes sure it
99 doesn't get removed in the future.
1002. All changes *must* have permalink to headers in commit messages. See
101 [Source links](#source-links) below for more details.
1023. For any constants that are expected to change, e.g. `*LAST` or `*MAX`, try to
103 add the following doc comment:
104
105 ```rust
106 /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
107 /// for details.
108 ```
1095. Run tests locally, following the directions at
110 [Test before you commit](test-before-you-commit). This is especially relevant
111 for platforms that aren't tested on CI.
112
113### Source links
114
115Please include permalinks to headers in commit messages for all API changes.
116Common sources include:
117
118* Linux uapi: https://github.com/torvalds/linux/tree/master/include/uapi
119* Glibc: https://sourceware.org/git/?p=glibc.git;a=tree
120* Musl: https://github.com/kraj/musl (original is https://git.musl-libc.org/cgit/musl/tree/)
121* Apple XNU: https://github.com/apple-oss-distributions/xnu, libc https://github.com/apple-oss-distributions/Libc/tree/main/include
122* Android: https://cs.android.com/android/platform/superproject/main
123* FreeBSD: https://github.com/freebsd/freebsd-src/tree/main/lib/libc
124* Illumos: https://github.com/illumos/illumos-gate/tree/master/usr/src/lib/libc
125* Fuchsia: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/
126
127After navigating to the relevant file and selecting relevant lines, get a
128permalink. On GitHub this is available by clicking the triple dots and
129selecting "copy permalink", and on the Android and Fuchsia source viewers
130this is available via l-r (links->commit).
131
132If sources are closed, link to documentation or paste relevant C declarations.
133
134(Including this information in the PR description is fine too, commit messages
135are preferred because they become part of history.)
136
137## Breaking change policy
138
139See `src/lib.rs` for details.
140
141## Supported target policy
142
143When Rust removes a support for a target, the libc crate also may remove the
144support at any time. MSRV may be different for different targets.
145
146## Releasing change to crates.io
147
148This repository uses [release-plz] to handle releases. Once your pull request
149has been merged, a maintainer needs to create the changelog and merge a PR
150bumping the version. This will automatically publish to crates.io!
151
152[release-plz]: https://github.com/MarcoIeni/release-plz