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
Unified · Split
| @@ -15,7 +15,7 @@ support corresponds to ``S`` values in the ``MAINTAINERS`` file. · 14 unmodified lines | |||
| 15 | ============ ================ ============================================== | 15 | ============ ================ ============================================== |
| 16 | Architecture Level of support Constraints | 16 | Architecture 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 | ||
| @@ -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. |
| 263 | bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) | 263 | bindgen_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 | ||
| 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 | |||
| 265 | bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \ | 279 | bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \ |
| 266 | $(bindgen_extra_c_flags) | 280 | $(bindgen_extra_c_flags) |
| 267 | endif | 281 | endif |
| @@ -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 FORCE | 302 | $(src)/bindgen_parameters FORCE |
| 289 | $(call if_changed_dep,bindgen) | 303 | $(call if_changed_dep,bindgen) |
| @@ -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] |
| 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 { | ||
| 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()) }; |
| @@ -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 _, |
| @@ -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 | continue | 111 | continue |
| 109 | 112 | ||
| 110 | logging.info("Adding %s", name) | 113 | logging.info("Adding %s", name) |
| @@ -13,4 +13,4 @@ set -e · 12 unmodified lines | |||
| 13 | # | 13 | # |
| 14 | # In the future, checking for the `.comment` section may be another | 14 | # 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:]]*$' |