Commit 6a66fdd2 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rust-fixes-6.3' of https://github.com/Rust-for-Linux/linux

Pull Rust fixes from Miguel Ojeda:
 "Most of these are straightforward.

  The last one is more complex, but it only touches Rust + GCC builds
  which are for the moment best-effort.

   - Code: Missing 'extern "C"' fix.

   - Scripts: 'is_rust_module.sh' and 'generate_rust_analyzer.py' fixes.

   - A couple trivial fixes

   - Build: Rust + GCC build fix and 'grep' warning fix"

* tag 'rust-fixes-6.3' of https://github.com/Rust-for-Linux/linux:
  rust: allow to use INIT_STACK_ALL_ZERO
  rust: fix regexp in scripts/is_rust_module.sh
  rust: build: Fix grep warning
  scripts: generate_rust_analyzer: Handle sub-modules with no Makefile
  rust: kernel: Mark rust_fmt_argument as extern "C"
  rust: sort uml documentation arch support table
  rust: str: fix requierments->requirements typo
parents 23309d60 d966c3ca
...@@ -15,7 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file. ...@@ -15,7 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
============ ================ ============================================== ============ ================ ==============================================
Architecture Level of support Constraints Architecture Level of support Constraints
============ ================ ============================================== ============ ================ ==============================================
``x86`` Maintained ``x86_64`` only.
``um`` Maintained ``x86_64`` only. ``um`` Maintained ``x86_64`` only.
``x86`` Maintained ``x86_64`` only.
============ ================ ============================================== ============ ================ ==============================================
...@@ -262,6 +262,20 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) ...@@ -262,6 +262,20 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
# some configurations, with new GCC versions, etc. # some configurations, with new GCC versions, etc.
bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
# Auto variable zero-initialization requires an additional special option with
# clang that is going to be removed sometime in the future (likely in
# clang-18), so make sure to pass this option only if clang supports it
# (libclang major version < 16).
#
# https://github.com/llvm/llvm-project/issues/44842
# https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0-rc2/clang/docs/ReleaseNotes.rst#deprecated-compiler-flags
ifdef CONFIG_INIT_STACK_ALL_ZERO
libclang_maj_ver=$(shell $(BINDGEN) $(srctree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/\1/p')
ifeq ($(shell expr $(libclang_maj_ver) \< 16), 1)
bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
endif
endif
bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \ bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
$(bindgen_extra_c_flags) $(bindgen_extra_c_flags)
endif endif
...@@ -283,7 +297,7 @@ quiet_cmd_bindgen = BINDGEN $@ ...@@ -283,7 +297,7 @@ quiet_cmd_bindgen = BINDGEN $@
$(bindgen_target_cflags) $(bindgen_target_extra) $(bindgen_target_cflags) $(bindgen_target_extra)
$(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \ $(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
$(shell grep -v '^\#\|^$$' $(srctree)/$(src)/bindgen_parameters) $(shell grep -v '^#\|^$$' $(srctree)/$(src)/bindgen_parameters)
$(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \ $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
$(src)/bindgen_parameters FORCE $(src)/bindgen_parameters FORCE
$(call if_changed_dep,bindgen) $(call if_changed_dep,bindgen)
......
...@@ -18,7 +18,11 @@ ...@@ -18,7 +18,11 @@
// Called from `vsprintf` with format specifier `%pA`. // Called from `vsprintf` with format specifier `%pA`.
#[no_mangle] #[no_mangle]
unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char { unsafe extern "C" fn rust_fmt_argument(
buf: *mut c_char,
end: *mut c_char,
ptr: *const c_void,
) -> *mut c_char {
use fmt::Write; use fmt::Write;
// SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`. // SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) }; let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
......
...@@ -408,7 +408,7 @@ fn new() -> Self { ...@@ -408,7 +408,7 @@ fn new() -> Self {
/// If `pos` is less than `end`, then the region between `pos` (inclusive) and `end` /// If `pos` is less than `end`, then the region between `pos` (inclusive) and `end`
/// (exclusive) must be valid for writes for the lifetime of the returned [`RawFormatter`]. /// (exclusive) must be valid for writes for the lifetime of the returned [`RawFormatter`].
pub(crate) unsafe fn from_ptrs(pos: *mut u8, end: *mut u8) -> Self { pub(crate) unsafe fn from_ptrs(pos: *mut u8, end: *mut u8) -> Self {
// INVARIANT: The safety requierments guarantee the type invariants. // INVARIANT: The safety requirements guarantee the type invariants.
Self { Self {
beg: pos as _, beg: pos as _,
pos: pos as _, pos: pos as _,
......
...@@ -104,7 +104,10 @@ def generate_crates(srctree, objtree, sysroot_src): ...@@ -104,7 +104,10 @@ def generate_crates(srctree, objtree, sysroot_src):
name = path.name.replace(".rs", "") name = path.name.replace(".rs", "")
# Skip those that are not crate roots. # Skip those that are not crate roots.
if f"{name}.o" not in open(path.parent / "Makefile").read(): try:
if f"{name}.o" not in open(path.parent / "Makefile").read():
continue
except FileNotFoundError:
continue continue
logging.info("Adding %s", name) logging.info("Adding %s", name)
......
...@@ -13,4 +13,4 @@ set -e ...@@ -13,4 +13,4 @@ set -e
# #
# In the future, checking for the `.comment` section may be another # In the future, checking for the `.comment` section may be another
# option, see https://github.com/rust-lang/rust/pull/97550. # option, see https://github.com/rust-lang/rust/pull/97550.
${NM} "$*" | grep -qE '^[0-9a-fA-F]+ r _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$' ${NM} "$*" | grep -qE '^[0-9a-fA-F]+ [Rr] _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment