aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / libc / CONTRIBUTING.md
| 1 | # Contributing to `libc` |
| 2 | |
| 3 | Welcome! If you are reading this document, it means you are interested in |
| 4 | contributing 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 |
| 9 | development of the upcoming v1.0 release, and should be the target of all pull |
| 10 | requests. `libc-0.2` is for updates to the currently released version. |
| 11 | |
| 12 | If a pull request to `main` is a good candidate for inclusion in an `0.2.x` |
| 13 | release, include `@rustbot label stable-nominated` in a comment to propose this. |
| 14 | Almost everything should be included in stable, unless it involves breaking |
| 15 | changes. |
| 16 | |
| 17 | Once a `stable-nominated` PR targeting `main` has merged, it can be cherry |
| 18 | picked to the `libc-0.2` branch. A maintainer will likely do these cherry picks |
| 19 | in a batch before a release, so there is no need for any action as a PR author. |
| 20 | |
| 21 | When 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 |
| 23 | start-sha^..end-sha` if a range of commits is needed). `git` will automatically |
| 24 | add the "cherry picked from commit" note, but try to add a backport note so the |
| 25 | original 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 | |
| 34 | Cherry pick PRs can then target `libc-0.2`. |
| 35 | |
| 36 | See the [tracking issue](https://github.com/rust-lang/libc/issues/3248) for |
| 37 | details. |
| 38 | |
| 39 | ## Adding an API |
| 40 | |
| 41 | Want to use an API which currently isn't bound in `libc`? It's quite easy to add |
| 42 | one! |
| 43 | |
| 44 | If you are adding API for a header that doesn't already have some bindings, |
| 45 | create a new file in the appropriate location in `src/new`. These modules should |
| 46 | approximately match source trees: try to follow the patterns that are there but |
| 47 | don't hesitate to ask maintainers if guidance is needed. |
| 48 | |
| 49 | If 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 |
| 52 | represents a single platform, and adding API at a given level will make it |
| 53 | available on all children. |
| 54 | |
| 55 | We are currently in a reorganization process, moving from the hierarchial |
| 56 | structure to the source-mapped structure in `src/new`. |
| 57 | |
| 58 | New items (i.e. functions, constants etc.) should also be added to the symbol |
| 59 | list(s) found in the `libc-test/semver` directory. These lists track of what |
| 60 | API is public in the libc crate and ensures they remain available between |
| 61 | changes to the crate. If the new symbol(s) are available on all supported Unixes |
| 62 | it should be added to `unix.txt` list[^1], otherwise they should be added to the |
| 63 | OS-specific list(s). |
| 64 | |
| 65 | With that in mind, the steps for adding a new API are: |
| 66 | |
| 67 | 1. Determine where to add your API. |
| 68 | 2. Add the API, including adding new symbol(s) to the semver lists. |
| 69 | 3. Send a PR to this repo. |
| 70 | 4. Wait for CI to pass, fixing errors. |
| 71 | 5. 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 | |
| 78 | There are a few relevant tests in `libc`: |
| 79 | |
| 80 | 1. `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. |
| 85 | 2. 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.) |
| 88 | 3. `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 | |
| 95 | When you submit a PR, please follow these guidelines to give your PR the best |
| 96 | chance of being accepted: |
| 97 | |
| 98 | 1. All new API should be added to `libc-test/semver`, which makes sure it |
| 99 | doesn't get removed in the future. |
| 100 | 2. All changes *must* have permalink to headers in commit messages. See |
| 101 | [Source links](#source-links) below for more details. |
| 102 | 3. 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 | ``` |
| 109 | 5. 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 | |
| 115 | Please include permalinks to headers in commit messages for all API changes. |
| 116 | Common 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 | |
| 127 | After navigating to the relevant file and selecting relevant lines, get a |
| 128 | permalink. On GitHub this is available by clicking the triple dots and |
| 129 | selecting "copy permalink", and on the Android and Fuchsia source viewers |
| 130 | this is available via l-r (links->commit). |
| 131 | |
| 132 | If 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 |
| 135 | are preferred because they become part of history.) |
| 136 | |
| 137 | ## Breaking change policy |
| 138 | |
| 139 | See `src/lib.rs` for details. |
| 140 | |
| 141 | ## Supported target policy |
| 142 | |
| 143 | When Rust removes a support for a target, the libc crate also may remove the |
| 144 | support at any time. MSRV may be different for different targets. |
| 145 | |
| 146 | ## Releasing change to crates.io |
| 147 | |
| 148 | This repository uses [release-plz] to handle releases. Once your pull request |
| 149 | has been merged, a maintainer needs to create the changelog and merge a PR |
| 150 | bumping the version. This will automatically publish to crates.io! |
| 151 | |
| 152 | [release-plz]: https://github.com/MarcoIeni/release-plz |