mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
Merge tag 'rust-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull Rust updates from Miguel Ojeda:
"Toolchain and infrastructure:
- Add support for 'syn'.
Syn is a parsing library for parsing a stream of Rust tokens into a
syntax tree of Rust source code.
Currently this library is geared toward use in Rust procedural
macros, but contains some APIs that may be useful more generally.
'syn' allows us to greatly simplify writing complex macros such as
'pin-init' (Benno has already prepared the 'syn'-based version). We
will use it in the 'macros' crate too.
'syn' is the most downloaded Rust crate (according to crates.io),
and it is also used by the Rust compiler itself. While the amount
of code is substantial, there should not be many updates needed for
these crates, and even if there are, they should not be too big,
e.g. +7k -3k lines across the 3 crates in the last year.
'syn' requires two smaller dependencies: 'quote' and 'proc-macro2'.
I only modified their code to remove a third dependency
('unicode-ident') and to add the SPDX identifiers. The code can be
easily verified to exactly match upstream with the provided
scripts.
They are all licensed under "Apache-2.0 OR MIT", like the other
vendored 'alloc' crate we had for a while.
Please see the merge commit with the cover letter for more context.
- Allow 'unreachable_pub' and 'clippy::disallowed_names' for
doctests.
Examples (i.e. doctests) may want to do things like show public
items and use names such as 'foo'.
Nevertheless, we still try to keep examples as close to real code
as possible (this is part of why running Clippy on doctests is
important for us, e.g. for safety comments, which userspace Rust
does not support yet but we are stricter).
'kernel' crate:
- Replace our custom 'CStr' type with 'core::ffi::CStr'.
Using the standard library type reduces our custom code footprint,
and we retain needed custom functionality through an extension
trait and a new 'fmt!' macro which replaces the previous 'core'
import.
This started in 6.17 and continued in 6.18, and we finally land the
replacement now. This required quite some stamina from Tamir, who
split the changes in steps to prepare for the flag day change here.
- Replace 'kernel::c_str!' with C string literals.
C string literals were added in Rust 1.77, which produce '&CStr's
(the 'core' one), so now we can write:
c"hi"
instead of:
c_str!("hi")
- Add 'num' module for numerical features.
It includes the 'Integer' trait, implemented for all primitive
integer types.
It also includes the 'Bounded' integer wrapping type: an integer
value that requires only the 'N' least significant bits of the
wrapped type to be encoded:
// An unsigned 8-bit integer, of which only the 4 LSBs are used.
let v = Bounded::<u8, 4>::new::<15>();
assert_eq!(v.get(), 15);
'Bounded' is useful to e.g. enforce guarantees when working with
bitfields that have an arbitrary number of bits.
Values can also be constructed from simple non-constant expressions
or, for more complex ones, validated at runtime.
'Bounded' also comes with comparison and arithmetic operations
(with both their backing type and other 'Bounded's with a
compatible backing type), casts to change the backing type,
extending/shrinking and infallible/fallible conversions from/to
primitives as applicable.
- 'rbtree' module: add immutable cursor ('Cursor').
It enables to use just an immutable tree reference where
appropriate. The existing fully-featured mutable cursor is renamed
to 'CursorMut'.
kallsyms:
- Fix wrong "big" kernel symbol type read from procfs.
'pin-init' crate:
- A couple minor fixes (Benno asked me to pick these patches up for
him this cycle).
Documentation:
- Quick Start guide: add Debian 13 (Trixie).
Debian Stable is now able to build Linux, since Debian 13 (released
2025-08-09) packages Rust 1.85.0, which is recent enough.
We are planning to propose that the minimum supported Rust version
in Linux follows Debian Stable releases, with Debian 13 being the
first one we upgrade to, i.e. Rust 1.85.
MAINTAINERS:
- Add entry for the new 'num' module.
- Remove Alex as Rust maintainer: he hasn't had the time to
contribute for a few years now, so it is a no-op change in
practice.
And a few other cleanups and improvements"
* tag 'rust-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (53 commits)
rust: macros: support `proc-macro2`, `quote` and `syn`
rust: syn: enable support in kbuild
rust: syn: add `README.md`
rust: syn: remove `unicode-ident` dependency
rust: syn: add SPDX License Identifiers
rust: syn: import crate
rust: quote: enable support in kbuild
rust: quote: add `README.md`
rust: quote: add SPDX License Identifiers
rust: quote: import crate
rust: proc-macro2: enable support in kbuild
rust: proc-macro2: add `README.md`
rust: proc-macro2: remove `unicode_ident` dependency
rust: proc-macro2: add SPDX License Identifiers
rust: proc-macro2: import crate
rust: kbuild: support using libraries in `rustc_procmacro`
rust: kbuild: support skipping flags in `rustc_test_library`
rust: kbuild: add proc macro library support
rust: kbuild: simplify `--cfg` handling
rust: kbuild: introduce `core-flags` and `core-skip_flags`
...
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
*.o.*
|
||||
*.patch
|
||||
*.pyc
|
||||
*.rlib
|
||||
*.rmeta
|
||||
*.rpm
|
||||
*.rsi
|
||||
|
||||
@@ -39,8 +39,8 @@ of the box, e.g.::
|
||||
Debian
|
||||
******
|
||||
|
||||
Debian Testing and Debian Unstable (Sid), outside of the freeze period, provide
|
||||
recent Rust releases and thus they should generally work out of the box, e.g.::
|
||||
Debian 13 (Trixie), as well as Testing and Debian Unstable (Sid) provide recent
|
||||
Rust releases and thus they should generally work out of the box, e.g.::
|
||||
|
||||
apt install rustc rust-src bindgen rustfmt rust-clippy
|
||||
|
||||
|
||||
+8
-1
@@ -22524,7 +22524,6 @@ F: tools/verification/
|
||||
|
||||
RUST
|
||||
M: Miguel Ojeda <ojeda@kernel.org>
|
||||
M: Alex Gaynor <alex.gaynor@gmail.com>
|
||||
R: Boqun Feng <boqun.feng@gmail.com>
|
||||
R: Gary Guo <gary@garyguo.net>
|
||||
R: Björn Roy Baron <bjorn3_gh@protonmail.com>
|
||||
@@ -22561,6 +22560,14 @@ T: git https://github.com/Rust-for-Linux/linux.git alloc-next
|
||||
F: rust/kernel/alloc.rs
|
||||
F: rust/kernel/alloc/
|
||||
|
||||
RUST [NUM]
|
||||
M: Alexandre Courbot <acourbot@nvidia.com>
|
||||
R: Yury Norov <yury.norov@gmail.com>
|
||||
L: rust-for-linux@vger.kernel.org
|
||||
S: Maintained
|
||||
F: rust/kernel/num.rs
|
||||
F: rust/kernel/num/
|
||||
|
||||
RUST [PIN-INIT]
|
||||
M: Benno Lossin <lossin@kernel.org>
|
||||
L: rust-for-linux@vger.kernel.org
|
||||
|
||||
@@ -1830,10 +1830,17 @@ rusttest: prepare
|
||||
$(Q)$(MAKE) $(build)=rust $@
|
||||
|
||||
# Formatting targets
|
||||
#
|
||||
# Generated files as well as vendored crates are skipped.
|
||||
PHONY += rustfmt rustfmtcheck
|
||||
|
||||
rustfmt:
|
||||
$(Q)find $(srctree) $(RCS_FIND_IGNORE) \
|
||||
\( \
|
||||
-path $(srctree)/rust/proc-macro2 \
|
||||
-o -path $(srctree)/rust/quote \
|
||||
-o -path $(srctree)/rust/syn \
|
||||
\) -prune -o \
|
||||
-type f -a -name '*.rs' -a ! -name '*generated*' -print \
|
||||
| xargs $(RUSTFMT) $(rustfmt_flags)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
// Copyright (C) 2025 Google LLC.
|
||||
|
||||
use kernel::fmt;
|
||||
use kernel::prelude::*;
|
||||
|
||||
use crate::defs::*;
|
||||
@@ -76,8 +77,8 @@ impl From<kernel::alloc::AllocError> for BinderError {
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Debug for BinderError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
impl fmt::Debug for BinderError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.reply {
|
||||
BR_FAILED_REPLY => match self.source.as_ref() {
|
||||
Some(source) => f
|
||||
|
||||
@@ -331,7 +331,7 @@ impl Process {
|
||||
KVVec::with_capacity(8, GFP_KERNEL).unwrap_or_else(|_err| KVVec::new());
|
||||
|
||||
let mut inner = self.lock_with_nodes();
|
||||
let mut curr = inner.nodes.cursor_front();
|
||||
let mut curr = inner.nodes.cursor_front_mut();
|
||||
while let Some(cursor) = curr {
|
||||
let (key, node) = cursor.current();
|
||||
let key = *key;
|
||||
@@ -345,7 +345,7 @@ impl Process {
|
||||
// Find the node we were looking at and try again. If the set of nodes was changed,
|
||||
// then just proceed to the next node. This is ok because we don't guarantee the
|
||||
// inclusion of nodes that are added or removed in parallel with this operation.
|
||||
curr = inner.nodes.cursor_lower_bound(&key);
|
||||
curr = inner.nodes.cursor_lower_bound_mut(&key);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -623,7 +623,7 @@ impl Process {
|
||||
" ref {}: desc {} {}node {debug_id} s {strong} w {weak}",
|
||||
r.debug_id,
|
||||
r.handle,
|
||||
if dead { "dead " } else { "" },
|
||||
if dead { "dead " } else { "" }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1320,7 +1320,7 @@ impl Process {
|
||||
{
|
||||
while let Some(node) = {
|
||||
let mut lock = self.inner.lock();
|
||||
lock.nodes.cursor_front().map(|c| c.remove_current().1)
|
||||
lock.nodes.cursor_front_mut().map(|c| c.remove_current().1)
|
||||
} {
|
||||
node.to_key_value().1.release();
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ impl<T> TreeRangeAllocator<T> {
|
||||
}
|
||||
|
||||
pub(crate) fn reservation_abort(&mut self, offset: usize) -> Result<FreedRange> {
|
||||
let mut cursor = self.tree.cursor_lower_bound(&offset).ok_or_else(|| {
|
||||
let mut cursor = self.tree.cursor_lower_bound_mut(&offset).ok_or_else(|| {
|
||||
pr_warn!(
|
||||
"EINVAL from range_alloc.reservation_abort - offset: {}",
|
||||
offset
|
||||
|
||||
@@ -61,7 +61,7 @@ impl BinderStats {
|
||||
|
||||
mod strings {
|
||||
use core::str::from_utf8_unchecked;
|
||||
use kernel::str::CStr;
|
||||
use kernel::str::{CStr, CStrExt as _};
|
||||
|
||||
extern "C" {
|
||||
static binder_command_strings: [*const u8; super::BC_COUNT];
|
||||
@@ -72,7 +72,7 @@ mod strings {
|
||||
// SAFETY: Accessing `binder_command_strings` is always safe.
|
||||
let c_str_ptr = unsafe { binder_command_strings[i] };
|
||||
// SAFETY: The `binder_command_strings` array only contains nul-terminated strings.
|
||||
let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes();
|
||||
let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes();
|
||||
// SAFETY: The `binder_command_strings` array only contains strings with ascii-chars.
|
||||
unsafe { from_utf8_unchecked(bytes) }
|
||||
}
|
||||
@@ -81,7 +81,7 @@ mod strings {
|
||||
// SAFETY: Accessing `binder_return_strings` is always safe.
|
||||
let c_str_ptr = unsafe { binder_return_strings[i] };
|
||||
// SAFETY: The `binder_command_strings` array only contains nul-terminated strings.
|
||||
let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes();
|
||||
let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes();
|
||||
// SAFETY: The `binder_command_strings` array only contains strings with ascii-chars.
|
||||
unsafe { from_utf8_unchecked(bytes) }
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
use super::{NullBlkDevice, THIS_MODULE};
|
||||
use core::fmt::{Display, Write};
|
||||
use kernel::{
|
||||
block::mq::gen_disk::{GenDisk, GenDiskBuilder},
|
||||
c_str,
|
||||
configfs::{self, AttributeOperations},
|
||||
configfs_attrs, new_mutex,
|
||||
configfs_attrs,
|
||||
fmt::{self, Write as _},
|
||||
new_mutex,
|
||||
page::PAGE_SIZE,
|
||||
prelude::*,
|
||||
str::{kstrtobool_bytes, CString},
|
||||
@@ -99,8 +100,8 @@ impl TryFrom<u8> for IRQMode {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for IRQMode {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
impl fmt::Display for IRQMode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::None => f.write_str("0")?,
|
||||
Self::Soft => f.write_str("1")?,
|
||||
|
||||
+4
-1
@@ -103,8 +103,11 @@ static char kallsyms_get_symbol_type(unsigned int off)
|
||||
{
|
||||
/*
|
||||
* Get just the first code, look it up in the token table,
|
||||
* and return the first char from this token.
|
||||
* and return the first char from this token. If MSB of length
|
||||
* is 1, it is a "big" symbol, so needs an additional byte.
|
||||
*/
|
||||
if (kallsyms_names[off] & 0x80)
|
||||
off++;
|
||||
return kallsyms_token_table[kallsyms_token_index[kallsyms_names[off + 1]]];
|
||||
}
|
||||
|
||||
|
||||
+132
-15
@@ -27,6 +27,8 @@ endif
|
||||
|
||||
obj-$(CONFIG_RUST) += exports.o
|
||||
|
||||
always-$(CONFIG_RUST) += libproc_macro2.rlib libquote.rlib libsyn.rlib
|
||||
|
||||
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated.rs
|
||||
always-$(CONFIG_RUST_KERNEL_DOCTESTS) += doctests_kernel_generated_kunit.c
|
||||
|
||||
@@ -60,11 +62,61 @@ rustdoc_test_quiet=--test-args -q
|
||||
rustdoc_test_kernel_quiet=>/dev/null
|
||||
endif
|
||||
|
||||
core-cfgs = \
|
||||
--cfg no_fp_fmt_parse
|
||||
cfgs-to-flags = $(patsubst %,--cfg='%',$1)
|
||||
|
||||
core-cfgs := \
|
||||
no_fp_fmt_parse
|
||||
|
||||
core-edition := $(if $(call rustc-min-version,108700),2024,2021)
|
||||
|
||||
core-skip_flags := \
|
||||
--edition=2021 \
|
||||
-Wunreachable_pub \
|
||||
-Wrustdoc::unescaped_backticks
|
||||
|
||||
core-flags := \
|
||||
--edition=$(core-edition) \
|
||||
$(call cfgs-to-flags,$(core-cfgs))
|
||||
|
||||
proc_macro2-cfgs := \
|
||||
feature="proc-macro" \
|
||||
wrap_proc_macro \
|
||||
$(if $(call rustc-min-version,108800),proc_macro_span_file proc_macro_span_location)
|
||||
|
||||
# Stable since Rust 1.79.0: `feature(proc_macro_byte_character,proc_macro_c_str_literals)`.
|
||||
proc_macro2-flags := \
|
||||
--cap-lints=allow \
|
||||
-Zcrate-attr='feature(proc_macro_byte_character,proc_macro_c_str_literals)' \
|
||||
$(call cfgs-to-flags,$(proc_macro2-cfgs))
|
||||
|
||||
quote-cfgs := \
|
||||
feature="proc-macro"
|
||||
|
||||
quote-skip_flags := \
|
||||
--edition=2021
|
||||
|
||||
quote-flags := \
|
||||
--edition=2018 \
|
||||
--cap-lints=allow \
|
||||
--extern proc_macro2 \
|
||||
$(call cfgs-to-flags,$(quote-cfgs))
|
||||
|
||||
# `extra-traits`, `fold` and `visit` may be enabled if needed.
|
||||
syn-cfgs := \
|
||||
feature="clone-impls" \
|
||||
feature="derive" \
|
||||
feature="full" \
|
||||
feature="parsing" \
|
||||
feature="printing" \
|
||||
feature="proc-macro" \
|
||||
feature="visit-mut"
|
||||
|
||||
syn-flags := \
|
||||
--cap-lints=allow \
|
||||
--extern proc_macro2 \
|
||||
--extern quote \
|
||||
$(call cfgs-to-flags,$(syn-cfgs))
|
||||
|
||||
# `rustdoc` did not save the target modifiers, thus workaround for
|
||||
# the time being (https://github.com/rust-lang/rust/issues/144521).
|
||||
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
|
||||
@@ -117,16 +169,33 @@ rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
|
||||
$(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \
|
||||
echo ".logo-container > img { object-fit: contain; }" >> $$f; done
|
||||
|
||||
rustdoc-proc_macro2: private rustdoc_host = yes
|
||||
rustdoc-proc_macro2: private rustc_target_flags = $(proc_macro2-flags)
|
||||
rustdoc-proc_macro2: $(src)/proc-macro2/lib.rs rustdoc-clean FORCE
|
||||
+$(call if_changed,rustdoc)
|
||||
|
||||
rustdoc-quote: private rustdoc_host = yes
|
||||
rustdoc-quote: private rustc_target_flags = $(quote-flags)
|
||||
rustdoc-quote: private skip_flags = $(quote-skip_flags)
|
||||
rustdoc-quote: $(src)/quote/lib.rs rustdoc-clean rustdoc-proc_macro2 FORCE
|
||||
+$(call if_changed,rustdoc)
|
||||
|
||||
rustdoc-syn: private rustdoc_host = yes
|
||||
rustdoc-syn: private rustc_target_flags = $(syn-flags)
|
||||
rustdoc-syn: $(src)/syn/lib.rs rustdoc-clean rustdoc-quote FORCE
|
||||
+$(call if_changed,rustdoc)
|
||||
|
||||
rustdoc-macros: private rustdoc_host = yes
|
||||
rustdoc-macros: private rustc_target_flags = --crate-type proc-macro \
|
||||
--extern proc_macro
|
||||
rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean FORCE
|
||||
--extern proc_macro --extern proc_macro2 --extern quote --extern syn
|
||||
rustdoc-macros: $(src)/macros/lib.rs rustdoc-clean rustdoc-proc_macro2 \
|
||||
rustdoc-quote rustdoc-syn FORCE
|
||||
+$(call if_changed,rustdoc)
|
||||
|
||||
# Starting with Rust 1.82.0, skipping `-Wrustdoc::unescaped_backticks` should
|
||||
# not be needed -- see https://github.com/rust-lang/rust/pull/128307.
|
||||
rustdoc-core: private skip_flags = --edition=2021 -Wrustdoc::unescaped_backticks
|
||||
rustdoc-core: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
|
||||
rustdoc-core: private skip_flags = $(core-skip_flags)
|
||||
rustdoc-core: private rustc_target_flags = $(core-flags)
|
||||
rustdoc-core: $(RUST_LIB_SRC)/core/src/lib.rs rustdoc-clean FORCE
|
||||
+$(call if_changed,rustdoc)
|
||||
|
||||
@@ -170,8 +239,8 @@ rustdoc-clean: FORCE
|
||||
quiet_cmd_rustc_test_library = $(RUSTC_OR_CLIPPY_QUIET) TL $<
|
||||
cmd_rustc_test_library = \
|
||||
OBJTREE=$(abspath $(objtree)) \
|
||||
$(RUSTC_OR_CLIPPY) $(rust_common_flags) \
|
||||
@$(objtree)/include/generated/rustc_cfg $(rustc_target_flags) \
|
||||
$(RUSTC_OR_CLIPPY) $(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
|
||||
@$(objtree)/include/generated/rustc_cfg \
|
||||
--crate-type $(if $(rustc_test_library_proc),proc-macro,rlib) \
|
||||
--out-dir $(objtree)/$(obj)/test --cfg testlib \
|
||||
-L$(objtree)/$(obj)/test \
|
||||
@@ -183,9 +252,24 @@ rusttestlib-build_error: $(src)/build_error.rs FORCE
|
||||
rusttestlib-ffi: $(src)/ffi.rs FORCE
|
||||
+$(call if_changed,rustc_test_library)
|
||||
|
||||
rusttestlib-macros: private rustc_target_flags = --extern proc_macro
|
||||
rusttestlib-proc_macro2: private rustc_target_flags = $(proc_macro2-flags)
|
||||
rusttestlib-proc_macro2: $(src)/proc-macro2/lib.rs FORCE
|
||||
+$(call if_changed,rustc_test_library)
|
||||
|
||||
rusttestlib-quote: private skip_flags = $(quote-skip_flags)
|
||||
rusttestlib-quote: private rustc_target_flags = $(quote-flags)
|
||||
rusttestlib-quote: $(src)/quote/lib.rs rusttestlib-proc_macro2 FORCE
|
||||
+$(call if_changed,rustc_test_library)
|
||||
|
||||
rusttestlib-syn: private rustc_target_flags = $(syn-flags)
|
||||
rusttestlib-syn: $(src)/syn/lib.rs rusttestlib-quote FORCE
|
||||
+$(call if_changed,rustc_test_library)
|
||||
|
||||
rusttestlib-macros: private rustc_target_flags = --extern proc_macro \
|
||||
--extern proc_macro2 --extern quote --extern syn
|
||||
rusttestlib-macros: private rustc_test_library_proc = yes
|
||||
rusttestlib-macros: $(src)/macros/lib.rs FORCE
|
||||
rusttestlib-macros: $(src)/macros/lib.rs \
|
||||
rusttestlib-proc_macro2 rusttestlib-quote rusttestlib-syn FORCE
|
||||
+$(call if_changed,rustc_test_library)
|
||||
|
||||
rusttestlib-pin_init_internal: private rustc_target_flags = --cfg kernel \
|
||||
@@ -266,7 +350,8 @@ quiet_cmd_rustc_test = $(RUSTC_OR_CLIPPY_QUIET) T $<
|
||||
rusttest: rusttest-macros
|
||||
|
||||
rusttest-macros: private rustc_target_flags = --extern proc_macro \
|
||||
--extern macros --extern kernel --extern pin_init
|
||||
--extern macros --extern kernel --extern pin_init \
|
||||
--extern proc_macro2 --extern quote --extern syn
|
||||
rusttest-macros: private rustdoc_test_target_flags = --crate-type proc-macro
|
||||
rusttest-macros: $(src)/macros/lib.rs \
|
||||
rusttestlib-macros rusttestlib-kernel rusttestlib-pin_init FORCE
|
||||
@@ -419,18 +504,47 @@ $(obj)/exports_bindings_generated.h: $(obj)/bindings.o FORCE
|
||||
$(obj)/exports_kernel_generated.h: $(obj)/kernel.o FORCE
|
||||
$(call if_changed,exports)
|
||||
|
||||
quiet_cmd_rustc_procmacrolibrary = $(RUSTC_OR_CLIPPY_QUIET) PL $@
|
||||
cmd_rustc_procmacrolibrary = \
|
||||
$(if $(skip_clippy),$(RUSTC),$(RUSTC_OR_CLIPPY)) \
|
||||
$(filter-out $(skip_flags),$(rust_common_flags) $(rustc_target_flags)) \
|
||||
--emit=dep-info,link --crate-type rlib -O \
|
||||
--out-dir $(objtree)/$(obj) -L$(objtree)/$(obj) \
|
||||
--crate-name $(patsubst lib%.rlib,%,$(notdir $@)) $<; \
|
||||
mv $(objtree)/$(obj)/$(patsubst lib%.rlib,%,$(notdir $@)).d $(depfile); \
|
||||
sed -i '/^\#/d' $(depfile)
|
||||
|
||||
$(obj)/libproc_macro2.rlib: private skip_clippy = 1
|
||||
$(obj)/libproc_macro2.rlib: private rustc_target_flags = $(proc_macro2-flags)
|
||||
$(obj)/libproc_macro2.rlib: $(src)/proc-macro2/lib.rs FORCE
|
||||
+$(call if_changed_dep,rustc_procmacrolibrary)
|
||||
|
||||
$(obj)/libquote.rlib: private skip_clippy = 1
|
||||
$(obj)/libquote.rlib: private skip_flags = $(quote-skip_flags)
|
||||
$(obj)/libquote.rlib: private rustc_target_flags = $(quote-flags)
|
||||
$(obj)/libquote.rlib: $(src)/quote/lib.rs $(obj)/libproc_macro2.rlib FORCE
|
||||
+$(call if_changed_dep,rustc_procmacrolibrary)
|
||||
|
||||
$(obj)/libsyn.rlib: private skip_clippy = 1
|
||||
$(obj)/libsyn.rlib: private rustc_target_flags = $(syn-flags)
|
||||
$(obj)/libsyn.rlib: $(src)/syn/lib.rs $(obj)/libquote.rlib FORCE
|
||||
+$(call if_changed_dep,rustc_procmacrolibrary)
|
||||
|
||||
quiet_cmd_rustc_procmacro = $(RUSTC_OR_CLIPPY_QUIET) P $@
|
||||
cmd_rustc_procmacro = \
|
||||
$(RUSTC_OR_CLIPPY) $(rust_common_flags) $(rustc_target_flags) \
|
||||
-Clinker-flavor=gcc -Clinker=$(HOSTCC) \
|
||||
-Clink-args='$(call escsq,$(KBUILD_PROCMACROLDFLAGS))' \
|
||||
--emit=dep-info=$(depfile) --emit=link=$@ --extern proc_macro \
|
||||
--crate-type proc-macro \
|
||||
--crate-type proc-macro -L$(objtree)/$(obj) \
|
||||
--crate-name $(patsubst lib%.$(libmacros_extension),%,$(notdir $@)) \
|
||||
@$(objtree)/include/generated/rustc_cfg $<
|
||||
|
||||
# Procedural macros can only be used with the `rustc` that compiled it.
|
||||
$(obj)/$(libmacros_name): $(src)/macros/lib.rs FORCE
|
||||
$(obj)/$(libmacros_name): private rustc_target_flags = \
|
||||
--extern proc_macro2 --extern quote --extern syn
|
||||
$(obj)/$(libmacros_name): $(src)/macros/lib.rs $(obj)/libproc_macro2.rlib \
|
||||
$(obj)/libquote.rlib $(obj)/libsyn.rlib FORCE
|
||||
+$(call if_changed_dep,rustc_procmacro)
|
||||
|
||||
$(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel
|
||||
@@ -453,6 +567,9 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
|
||||
rust-analyzer:
|
||||
$(Q)MAKEFLAGS= $(srctree)/scripts/generate_rust_analyzer.py \
|
||||
--cfgs='core=$(core-cfgs)' $(core-edition) \
|
||||
--cfgs='proc_macro2=$(proc_macro2-cfgs)' \
|
||||
--cfgs='quote=$(quote-cfgs)' \
|
||||
--cfgs='syn=$(syn-cfgs)' \
|
||||
$(realpath $(srctree)) $(realpath $(objtree)) \
|
||||
$(rustc_sysroot) $(RUST_LIB_SRC) $(if $(KBUILD_EXTMOD),$(srcroot)) \
|
||||
> rust-project.json
|
||||
@@ -508,9 +625,9 @@ $(obj)/helpers/helpers.o: $(src)/helpers/helpers.c $(recordmcount_source) FORCE
|
||||
$(obj)/exports.o: private skip_gendwarfksyms = 1
|
||||
|
||||
$(obj)/core.o: private skip_clippy = 1
|
||||
$(obj)/core.o: private skip_flags = --edition=2021 -Wunreachable_pub
|
||||
$(obj)/core.o: private skip_flags = $(core-skip_flags)
|
||||
$(obj)/core.o: private rustc_objcopy = $(foreach sym,$(redirect-intrinsics),--redefine-sym $(sym)=__rust$(sym))
|
||||
$(obj)/core.o: private rustc_target_flags = --edition=$(core-edition) $(core-cfgs)
|
||||
$(obj)/core.o: private rustc_target_flags = $(core-flags)
|
||||
$(obj)/core.o: $(RUST_LIB_SRC)/core/src/lib.rs \
|
||||
$(wildcard $(objtree)/include/config/RUSTC_VERSION_TEXT) FORCE
|
||||
+$(call if_changed_rule,rustc_library)
|
||||
|
||||
@@ -46,3 +46,5 @@ alias! {
|
||||
}
|
||||
|
||||
pub use core::ffi::c_void;
|
||||
|
||||
pub use core::ffi::CStr;
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
//! Errors for the [`Vec`] type.
|
||||
|
||||
use kernel::fmt::{self, Debug, Formatter};
|
||||
use kernel::fmt;
|
||||
use kernel::prelude::*;
|
||||
|
||||
/// Error type for [`Vec::push_within_capacity`].
|
||||
pub struct PushError<T>(pub T);
|
||||
|
||||
impl<T> Debug for PushError<T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
impl<T> fmt::Debug for PushError<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Not enough capacity")
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ impl<T> From<PushError<T>> for Error {
|
||||
/// Error type for [`Vec::remove`].
|
||||
pub struct RemoveError;
|
||||
|
||||
impl Debug for RemoveError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
impl fmt::Debug for RemoveError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Index out of bounds")
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,8 @@ pub enum InsertError<T> {
|
||||
OutOfCapacity(T),
|
||||
}
|
||||
|
||||
impl<T> Debug for InsertError<T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
impl<T> fmt::Debug for InsertError<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
InsertError::IndexOutOfBounds(_) => write!(f, "Index out of bounds"),
|
||||
InsertError::OutOfCapacity(_) => write!(f, "Not enough capacity"),
|
||||
|
||||
+2
-2
@@ -136,7 +136,7 @@ mod common_clk {
|
||||
///
|
||||
/// [`clk_get`]: https://docs.kernel.org/core-api/kernel-api.html#c.clk_get
|
||||
pub fn get(dev: &Device, name: Option<&CStr>) -> Result<Self> {
|
||||
let con_id = name.map_or(ptr::null(), |n| n.as_ptr());
|
||||
let con_id = name.map_or(ptr::null(), |n| n.as_char_ptr());
|
||||
|
||||
// SAFETY: It is safe to call [`clk_get`] for a valid device pointer.
|
||||
//
|
||||
@@ -304,7 +304,7 @@ mod common_clk {
|
||||
/// [`clk_get_optional`]:
|
||||
/// https://docs.kernel.org/core-api/kernel-api.html#c.clk_get_optional
|
||||
pub fn get(dev: &Device, name: Option<&CStr>) -> Result<Self> {
|
||||
let con_id = name.map_or(ptr::null(), |n| n.as_ptr());
|
||||
let con_id = name.map_or(ptr::null(), |n| n.as_char_ptr());
|
||||
|
||||
// SAFETY: It is safe to call [`clk_get_optional`] for a valid device pointer.
|
||||
//
|
||||
|
||||
@@ -157,7 +157,7 @@ impl<Data> Subsystem<Data> {
|
||||
unsafe {
|
||||
bindings::config_group_init_type_name(
|
||||
&mut (*place.get()).su_group,
|
||||
name.as_ptr(),
|
||||
name.as_char_ptr(),
|
||||
item_type.as_ptr(),
|
||||
)
|
||||
};
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
// When DebugFS is disabled, many parameters are dead. Linting for this isn't helpful.
|
||||
#![cfg_attr(not(CONFIG_DEBUG_FS), allow(unused_variables))]
|
||||
|
||||
use crate::fmt;
|
||||
use crate::prelude::*;
|
||||
use crate::str::CStr;
|
||||
#[cfg(CONFIG_DEBUG_FS)]
|
||||
use crate::sync::Arc;
|
||||
use crate::uaccess::UserSliceReader;
|
||||
use core::fmt;
|
||||
use core::marker::PhantomData;
|
||||
use core::marker::PhantomPinned;
|
||||
#[cfg(CONFIG_DEBUG_FS)]
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
//! than a trait implementation. If provided, it will override the trait implementation.
|
||||
|
||||
use super::{Reader, Writer};
|
||||
use crate::fmt;
|
||||
use crate::prelude::*;
|
||||
use crate::uaccess::UserSliceReader;
|
||||
use core::fmt;
|
||||
use core::fmt::Formatter;
|
||||
use core::marker::PhantomData;
|
||||
use core::ops::Deref;
|
||||
|
||||
@@ -76,9 +75,9 @@ impl<D, F> Deref for FormatAdapter<D, F> {
|
||||
|
||||
impl<D, F> Writer for FormatAdapter<D, F>
|
||||
where
|
||||
F: Fn(&D, &mut Formatter<'_>) -> fmt::Result + 'static,
|
||||
F: Fn(&D, &mut fmt::Formatter<'_>) -> fmt::Result + 'static,
|
||||
{
|
||||
fn write(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
|
||||
fn write(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// SAFETY: FormatAdapter<_, F> can only be constructed if F is inhabited
|
||||
let f: &F = unsafe { materialize_zst() };
|
||||
f(&self.inner, fmt)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::debugfs::file_ops::FileOps;
|
||||
use crate::ffi::c_void;
|
||||
use crate::str::CStr;
|
||||
use crate::str::{CStr, CStrExt as _};
|
||||
use crate::sync::Arc;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
use super::{Reader, Writer};
|
||||
use crate::debugfs::callback_adapters::Adapter;
|
||||
use crate::fmt;
|
||||
use crate::prelude::*;
|
||||
use crate::seq_file::SeqFile;
|
||||
use crate::seq_print;
|
||||
use crate::uaccess::UserSlice;
|
||||
use core::fmt::{Display, Formatter, Result};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
#[cfg(CONFIG_DEBUG_FS)]
|
||||
@@ -65,8 +65,8 @@ impl<T> Deref for FileOps<T> {
|
||||
|
||||
struct WriterAdapter<T>(T);
|
||||
|
||||
impl<'a, T: Writer> Display for WriterAdapter<&'a T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
||||
impl<'a, T: Writer> fmt::Display for WriterAdapter<&'a T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.write(f)
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user