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
1515 ============ ================ ==============================================
1616 Architecture Level of support Constraints
1717 ============ ================ ==============================================
18−``x86`` Maintained ``x86_64`` only.
1918 ``um`` Maintained ``x86_64`` only.
19+``x86`` Maintained ``x86_64`` only.
2020 ============ ================ ==============================================
2121
rust/Makefile+15−1
@@ -262,6 +262,20 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) · 261 unmodified lines
262262 # some configurations, with new GCC versions, etc.
263263 bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET)
264264
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
272+ifdef CONFIG_INIT_STACK_ALL_ZERO
273+libclang_maj_ver=$(shell $(BINDGEN) $(srctree)/scripts/rust_is_available_bindgen_libclang.h 2>&1 | sed -ne 's/.*clang version \([0-9]*\).*/\1/p')
274+ifeq ($(shell expr $(libclang_maj_ver) \< 16), 1)
275+bindgen_extra_c_flags += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
276+endif
277+endif
278+
265279 bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \
266280 $(bindgen_extra_c_flags)
267281 endif
@@ -283,7 +297,7 @@ quiet_cmd_bindgen = BINDGEN $@ · 15 unmodified lines
283297 $(bindgen_target_cflags) $(bindgen_target_extra)
284298
285299 $(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)
287301 $(obj)/bindings/bindings_generated.rs: $(src)/bindings/bindings_helper.h \
288302 $(src)/bindgen_parameters FORCE
289303 $(call if_changed_dep,bindgen)
rust/kernel/print.rs+5−1
@@ -18,7 +18,11 @@ use crate::bindings; · 17 unmodified lines
1818
1919 // Called from `vsprintf` with format specifier `%pA`.
2020 #[no_mangle]
21−unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
21+unsafe 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 {
2226 use fmt::Write;
2327 // SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
2428 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
408408 /// If `pos` is less than `end`, then the region between `pos` (inclusive) and `end`
409409 /// (exclusive) must be valid for writes for the lifetime of the returned [`RawFormatter`].
410410 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.
412412 Self {
413413 beg: pos as _,
414414 pos: pos as _,
scripts/generate_rust_analyzer.py+4−1
@@ -104,7 +104,10 @@ def generate_crates(srctree, objtree, sysroot_src): · 103 unmodified lines
104104 name = path.name.replace(".rs", "")
105105
106106 # 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:
108111 continue
109112
110113 logging.info("Adding %s", name)
scripts/is_rust_module.sh+1−1
@@ -13,4 +13,4 @@ set -e · 12 unmodified lines
1313 #
1414 # In the future, checking for the `.comment` section may be another
1515 # 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:]]*$'