History

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

Linus Torvalds committed 3 years ago

Commit 6a66fdd2 parents 23309d6 d966c3c6 files · +27 −6Browse files

Unified · Split

6 files
  1. Documentation/rust/arch-support.rst +1 −1
  2. rust/Makefile +15 −1
  3. rust/kernel/print.rs +5 −1
  4. rust/kernel/str.rs +1 −1
  5. scripts/generate_rust_analyzer.py +4 −1
  6. scripts/is_rust_module.sh +1 −1
Documentation/rust/arch-support.rst+1−1
@@ -15,7 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file. · 14 unmodified lines
15============ ================ ==============================================15============ ================ ==============================================
16Architecture Level of support Constraints16Architecture Level of support Constraints
17============ ================ ==============================================17============ ================ ==============================================
18``x86`` Maintained ``x86_64`` only.
19``um`` Maintained ``x86_64`` only.18``um`` Maintained ``x86_64`` only.
19``x86`` Maintained ``x86_64`` only.
20============ ================ ==============================================20============ ================ ==============================================
21 21
rust/Makefile+15−1
@@ -262,6 +262,20 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) · 261 unmodified lines
262# some configurations, with new GCC versions, etc.262# some configurations, with new GCC versions, etc.
263bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)263bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
264 264
265# Auto variable zero-initialization requires an additional special option with
266# clang that is going to be removed sometime in the future (likely in
267# clang-18), so make sure to pass this option only if clang supports it
268# (libclang major version < 16).
269#
270# https://github.com/llvm/llvm-project/issues/44842
271# https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0-rc2/clang/docs/ReleaseNotes.rst#deprecated-compiler-flags
272ifdef CONFIG_INIT_STACK_ALL_ZERO
273libclang_maj_ver=$(shell $(BINDGEN) $(srctree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/\1/p')
274ifeq ($(shell expr $(libclang_maj_ver) \< 16), 1)
275bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
276endif
277endif
278
265bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \279bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
266 $(bindgen_extra_c_flags)280 $(bindgen_extra_c_flags)
267endif281endif
@@ -283,7 +297,7 @@ quiet_cmd_bindgen = BINDGEN $@ · 15 unmodified lines
283 $(bindgen_target_cflags) $(bindgen_target_extra)297 $(bindgen_target_cflags) $(bindgen_target_extra)
284 298
285$(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \299$(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
286 $(shell grep -v '^\#\|^$$' $(srctree)/$(src)/bindgen_parameters)300 $(shell grep -v '^#\|^$$' $(srctree)/$(src)/bindgen_parameters)
287$(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \301$(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
288 $(src)/bindgen_parameters FORCE302 $(src)/bindgen_parameters FORCE
289 $(call if_changed_dep,bindgen)303 $(call if_changed_dep,bindgen)
rust/kernel/print.rs+5−1
@@ -18,7 +18,11 @@ use crate::bindings; · 17 unmodified lines
18 18
19// Called from `vsprintf` with format specifier `%pA`.19// Called from `vsprintf` with format specifier `%pA`.
20#[no_mangle]20#[no_mangle]
21unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {21unsafe extern "C" fn rust_fmt_argument(
22 buf: *mut c_char,
23 end: *mut c_char,
24 ptr: *const c_void,
25) -> *mut c_char {
22 use fmt::Write;26 use fmt::Write;
23 // SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.27 // SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
24 let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };28 let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
rust/kernel/str.rs+1−1
@@ -408,7 +408,7 @@ impl RawFormatter { · 407 unmodified lines
408 /// If `pos` is less than `end`, then the region between `pos` (inclusive) and `end`408 /// If `pos` is less than `end`, then the region between `pos` (inclusive) and `end`
409 /// (exclusive) must be valid for writes for the lifetime of the returned [`RawFormatter`].409 /// (exclusive) must be valid for writes for the lifetime of the returned [`RawFormatter`].
410 pub(crate) unsafe fn from_ptrs(pos: *mut u8, end: *mut u8) -> Self {410 pub(crate) unsafe fn from_ptrs(pos: *mut u8, end: *mut u8) -> Self {
411 // INVARIANT: The safety requierments guarantee the type invariants.411 // INVARIANT: The safety requirements guarantee the type invariants.
412 Self {412 Self {
413 beg: pos as _,413 beg: pos as _,
414 pos: pos as _,414 pos: pos as _,
scripts/generate_rust_analyzer.py+4−1
@@ -104,7 +104,10 @@ def generate_crates(srctree, objtree, sysroot_src): · 103 unmodified lines
104 name = path.name.replace(".rs", "")104 name = path.name.replace(".rs", "")
105 105
106 # Skip those that are not crate roots.106 # Skip those that are not crate roots.
107 if f"{name}.o" not in open(path.parent / "Makefile").read():107 try:
108 if f"{name}.o" not in open(path.parent / "Makefile").read():
109 continue
110 except FileNotFoundError:
108 continue111 continue
109 112
110 logging.info("Adding %s", name)113 logging.info("Adding %s", name)
scripts/is_rust_module.sh+1−1
@@ -13,4 +13,4 @@ set -e · 12 unmodified lines
13#13#
14# In the future, checking for the `.comment` section may be another14# In the future, checking for the `.comment` section may be another
15# option, see https://github.com/rust-lang/rust/pull/97550.15# option, see https://github.com/rust-lang/rust/pull/97550.
16${NM} "$*" | grep -qE '^[0-9a-fA-F]+ r _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$'16${NM} "$*" | grep -qE '^[0-9a-fA-F]+ [Rr] _R[^[:space:]]+16___IS_RUST_MODULE[^[:space:]]*$'