Uh oh!
There was an error while loading. Please reload this page.
forked from torvalds/linux
- Notifications
You must be signed in to change notification settings - Fork 494
Custom alloc, using stable Rust compilers, and more#402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
405c9a1
rust: import `alloc`
ojeda 33f31ce
rust: alloc: remove `BTreeMap` and `BTreeSet`
ojeda 4b9f221
rust: alloc: remove `BinaryHeap`
ojeda 37d9455
rust: alloc: remove `VecDeque`
ojeda 771912e
rust: alloc: remote `LinkedList`
ojeda 2a4f8f9
rust: alloc: remove `task` module
ojeda 45dde9f
rust: alloc: remove parts of `vec`
ojeda e7ac457
rust: alloc: remove `tests.rs` files
ojeda db747ba
rust: alloc: add SPDX License Identifiers
ojeda 085cf66
rust: macros: hide docs for `module!` public statics/fns
ojeda 26a4431
rust: kernel: add docs for macro stub
ojeda edd7ad5
rust: kernel: clean beta Clippy `needless_borrow` warnings
ojeda e415c34
rust: macros: clean beta Clippy `needless_borrow` warnings
ojeda 1f1b619
rust: compile in bootstrapping mode
ojeda 38a10b4
rust: compile `alloc` from the in-tree sources
ojeda b4a8689
rust: alloc: disable several `new()`s, `pin()`s, `default()`s, etc.
ojeda af999c4
rust: alloc: fix unused import `from_fn` warning
ojeda 487d757
rust: alloc: add some `try_*` methods we need
ojeda 3fd100b
rust: kernel: use the new `try_*` methods
ojeda 90f1659
android: binder: use the new `try_*` methods
ojeda 622b593
rust: alloc: enable `no_global_oom_handling`
ojeda 023ccfc
rustfmt: do not use unstable features
ojeda b4d81aa
scripts: update `rust-analyzer` for local `alloc`
ojeda ceb8b67
docs: rust: update with new required versions
ojeda a9c675d
ci: call `rustfmtcheck` with the environment
ojeda 3bb8661
ci: use beta release
ojeda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -23,13 +23,13 @@ at the time of writing, they are likely to not be recent enough. | ||
| rustc | ||
| ***** | ||
| A recent *nightly* Rust toolchain (with, at least, ``rustc``) is required, | ||
| e.g. ``nightly-2021-05-29``. Our goal is to use a stable toolchain as soon | ||
| as possible, but for the moment we depend on a handful of nightly features. | ||
| A particular version (`1.54.0-beta.1`) of the Rust compiler is required. | ||
ojeda marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Newer versions may or may not work because, for the moment, we depend on | ||
| some unstable Rust features. | ||
| If you are using ``rustup``, run:: | ||
| rustup default nightly-2021-05-29 | ||
| rustup default beta-2021-06-23 | ||
| Otherwise, fetch a standalone installer or install ``rustup`` from: | ||
| @@ -125,16 +125,30 @@ the component manually:: | ||
| The standalone installers also come with ``clippy``. | ||
| cargo | ||
| ***** | ||
| ``cargo`` is the Rust native build system. It is currently required to run | ||
| the tests (``rusttest`` target) since we use it to build a custom standard | ||
| library that contains the facilities provided by our custom ``alloc``. | ||
| If you are using ``rustup``, all the profiles already install the tool, | ||
| so you should be good to go. The standalone installers also include ``cargo``. | ||
| rustdoc | ||
| ******* | ||
| If you install the ``rustdoc`` tool, then you will be able to generate pretty | ||
| HTML documentation for Rust code, including for the libraries (crates) inside | ||
| ``rust/`` that are used by the rest of the kernel (for details, please see | ||
| :ref:`Documentation/rust/docs.rst <rust_docs>`). | ||
| ``rustdoc`` is the documentation tool for Rust. It generates pretty HTML | ||
| documentation for Rust code (for details, please see | ||
| :ref:`Documentation/rust/docs.rst <rust_docs>`. | ||
| ``rustdoc`` is also able to test the examples provided in documented Rust code | ||
| (called doctests or documentation tests). We use this feature, thus ``rustdoc`` | ||
| is required to run the tests (``rusttest`` target). | ||
| If you are using ``rustup``, all the profiles already install the tool, | ||
| so you should be good to go. The standalone installers also come with ``rustdoc``. | ||
| so you should be good to go. The standalone installers also include ``rustdoc``. | ||
| rust-analyzer | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -460,9 +460,12 @@ READELF = $(CROSS_COMPILE)readelf | ||
| STRIP = $(CROSS_COMPILE)strip | ||
| endif | ||
| RUSTC = rustc | ||
| RUSTC_BOOTSTRAP = 1 | ||
ojeda marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| RUSTDOC = rustdoc | ||
| RUSTFMT = rustfmt | ||
| CLIPPY_DRIVER = clippy-driver | ||
| BINDGEN = bindgen | ||
| CARGO = cargo | ||
| PAHOLE = pahole | ||
| RESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfids | ||
| LEX = flex | ||
| @@ -524,7 +527,7 @@ KBUILD_RUSTCFLAGS := --emit=dep-info,obj,metadata --edition=2018 \ | ||
| -Cpanic=abort -Cembed-bitcode=n -Clto=n -Crpath=n \ | ||
| -Cforce-unwind-tables=n -Ccodegen-units=1 \ | ||
| -Zbinary_dep_depinfo=y -Zsymbol-mangling-version=v0 \ | ||
| -D unsafe_op_in_unsafe_fn | ||
| -Dunsafe_op_in_unsafe_fn -Wmissing_docs | ||
| KBUILD_AFLAGS_KERNEL := | ||
| KBUILD_CFLAGS_KERNEL := | ||
| KBUILD_RUSTCFLAGS_KERNEL := | ||
| @@ -542,13 +545,13 @@ else | ||
| RUSTC_OR_CLIPPY_QUIET := RUSTC | ||
| RUSTC_OR_CLIPPY = $(RUSTC) | ||
| endif | ||
| export RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY | ||
| ifdef RUST_LIB_SRC | ||
| export RUST_LIB_SRC | ||
| endif | ||
| export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC RUSTC BINDGEN | ||
| export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC | ||
| export RUSTC RUSTC_BOOTSTRAP RUSTDOC RUSTFMT RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY BINDGEN CARGO | ||
| export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL | ||
| export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX | ||
| export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD | ||
| @@ -1596,7 +1599,7 @@ endif # CONFIG_MODULES | ||
| # Directories & files removed with 'make clean' | ||
| CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ | ||
| modules.builtin modules.builtin.modinfo modules.nsdeps \ | ||
| compile_commands.json .thinlto-cache | ||
| compile_commands.json .thinlto-cache rust/test rust/doc | ||
| # Directories & files removed with 'make mrproper' | ||
| MRPROPER_FILES += include/config include/generated \ | ||
| @@ -1726,7 +1729,7 @@ help: | ||
| @echo ' rustdoc - Generate Rust documentation' | ||
| @echo ' (requires kernel .config)' | ||
| @echo ' rusttest - Runs the Rust tests' | ||
| @echo ' (requires kernel .config)' | ||
| @echo ' (requires kernel .config; downloads external repos)' | ||
| @echo ' rust-analyzer - Generate rust-project.json rust-analyzer support file' | ||
| @echo ' (requires kernel .config)' | ||
| @echo '' | ||
| @@ -1820,11 +1823,21 @@ rusttest: prepare0 | ||
| # Formatting targets | ||
| PHONY += rustfmt rustfmtcheck | ||
| # We skip `rust/alloc` since we want to minimize the diff w.r.t. upstream. | ||
| # | ||
| # We match using absolute paths since `find` does not resolve them | ||
| # when matching, which is a problem when e.g. `srctree` is `..`. | ||
| # We `grep` afterwards in order to remove the directory entry itself. | ||
| rustfmt: | ||
| find $(srctree) -type f -name '*.rs' | xargs $(RUSTFMT) | ||
| rustfmtcheck: | ||
| find $(srctree) -type f -name '*.rs' | xargs $(RUSTFMT) --check | ||
| $(Q)find $(abs_srctree) -type f -name '*.rs' \ | ||
| -o -path $(abs_srctree)/rust/alloc -prune \ | ||
| -o -path $(abs_objtree)/rust/test -prune \ | ||
| | grep -Fv $(abs_srctree)/rust/alloc \ | ||
| | grep -Fv $(abs_objtree)/rust/test \ | ||
| | xargs $(RUSTFMT) $(rustfmt_flags) | ||
| rustfmtcheck: rustfmt_flags = --check | ||
| rustfmtcheck: rustfmt | ||
| # IDE support targets | ||
| PHONY += rust-analyzer | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.