Skip to content

Commit 6a66fdd

Browse files
committed
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
2 parents 23309d6 + d966c3c commit 6a66fdd

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

Documentation/rust/arch-support.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file.
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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,20 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH))
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 $@
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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ use crate::bindings;
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl RawFormatter {
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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ def append_crate(display_name, root_module, deps, cfg=[], is_workspace_member=Tr
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ set -e
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:]]*$'

0 commit comments

Comments
 (0)