Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 701ec6a

Browse files
committed
Merge 8aebac8 ("Merge tag 'rust-v6.1-rc1' of https://github.com/Rust-for-Linux/linux") into android-mainline
Steps on the way to 6.1-rc1 Resolves merge conficts in: scripts/Makefile.modfinal Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I3b66e95488224202d13b481c686d55e9e3048cbb
2 parents b9921d2 + 8aebac8 commit 701ec6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+12552
-51
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
*.o
3838
*.o.*
3939
*.patch
40+
*.rmeta
41+
*.rsi
4042
*.s
4143
*.so
4244
*.so.dbg
@@ -97,6 +99,7 @@ modules.order
9799
!.gitattributes
98100
!.gitignore
99101
!.mailmap
102+
!.rustfmt.toml
100103

101104
#
102105
# Generated include files
@@ -162,3 +165,6 @@ x509.genkey
162165

163166
# Documentation toolchain
164167
sphinx_*/
168+
169+
# Rust analyzer configuration
170+
/rust-project.json

.rustfmt.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
edition = "2021"
2+
newline_style = "Unix"
3+
4+
# Unstable options that help catching some mistakes in formatting and that we may want to enable
5+
# when they become stable.
6+
#
7+
# They are kept here since they are useful to run from time to time.
8+
#format_code_in_doc_comments = true
9+
#reorder_impl_items = true
10+
#comment_width = 100
11+
#wrap_comments = true
12+
#normalize_comments = true

Documentation/core-api/printk-formats.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,16 @@ Examples::
625625
%p4cc Y10 little-endian (0x20303159)
626626
%p4cc NV12 big-endian (0xb231564e)
627627

628+
Rust
629+
----
630+
631+
::
632+
633+
%pA
634+
635+
Only intended to be used from Rust code to format ``core::fmt::Arguments``.
636+
Do *not* use it from C.
637+
628638
Thanks
629639
======
630640

Documentation/doc-guide/kernel-doc.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ when it is embedded in source files.
1414
reasons. The kernel source contains tens of thousands of kernel-doc
1515
comments. Please stick to the style described here.
1616

17+
.. note:: kernel-doc does not cover Rust code: please see
18+
Documentation/rust/general-information.rst instead.
19+
1720
The kernel-doc structure is extracted from the comments, and proper
1821
`Sphinx C Domain`_ function and type descriptions with anchors are
1922
generated from them. The descriptions are filtered for special kernel-doc

Documentation/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Various other manuals with useful information for all kernel developers.
5858
trace/index
5959
fault-injection/index
6060
livepatch/index
61+
rust/index
6162

6263

6364
User-oriented documentation

Documentation/kbuild/kbuild.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ KCFLAGS
4848
-------
4949
Additional options to the C compiler (for built-in and modules).
5050

51+
KRUSTFLAGS
52+
----------
53+
Additional options to the Rust compiler (for built-in and modules).
54+
5155
CFLAGS_KERNEL
5256
-------------
5357
Additional options for $(CC) when used to compile
@@ -57,6 +61,15 @@ CFLAGS_MODULE
5761
-------------
5862
Additional module specific options to use for $(CC).
5963

64+
RUSTFLAGS_KERNEL
65+
----------------
66+
Additional options for $(RUSTC) when used to compile
67+
code that is compiled as built-in.
68+
69+
RUSTFLAGS_MODULE
70+
----------------
71+
Additional module specific options to use for $(RUSTC).
72+
6073
LDFLAGS_MODULE
6174
--------------
6275
Additional options used for $(LD) when linking modules.
@@ -69,6 +82,10 @@ HOSTCXXFLAGS
6982
------------
7083
Additional flags to be passed to $(HOSTCXX) when building host programs.
7184

85+
HOSTRUSTFLAGS
86+
-------------
87+
Additional flags to be passed to $(HOSTRUSTC) when building host programs.
88+
7289
HOSTLDFLAGS
7390
-----------
7491
Additional flags to be passed when linking host programs.

Documentation/kbuild/makefiles.rst

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ This document describes the Linux kernel Makefiles.
2929
--- 4.1 Simple Host Program
3030
--- 4.2 Composite Host Programs
3131
--- 4.3 Using C++ for host programs
32-
--- 4.4 Controlling compiler options for host programs
33-
--- 4.5 When host programs are actually built
32+
--- 4.4 Using Rust for host programs
33+
--- 4.5 Controlling compiler options for host programs
34+
--- 4.6 When host programs are actually built
3435
3536
=== 5 Userspace Program support
3637
--- 5.1 Simple Userspace Program
@@ -835,7 +836,24 @@ Both possibilities are described in the following.
835836
qconf-cxxobjs := qconf.o
836837
qconf-objs := check.o
837838

838-
4.4 Controlling compiler options for host programs
839+
4.4 Using Rust for host programs
840+
--------------------------------
841+
842+
Kbuild offers support for host programs written in Rust. However,
843+
since a Rust toolchain is not mandatory for kernel compilation,
844+
it may only be used in scenarios where Rust is required to be
845+
available (e.g. when ``CONFIG_RUST`` is enabled).
846+
847+
Example::
848+
849+
hostprogs := target
850+
target-rust := y
851+
852+
Kbuild will compile ``target`` using ``target.rs`` as the crate root,
853+
located in the same directory as the ``Makefile``. The crate may
854+
consist of several source files (see ``samples/rust/hostprogs``).
855+
856+
4.5 Controlling compiler options for host programs
839857
--------------------------------------------------
840858

841859
When compiling host programs, it is possible to set specific flags.
@@ -867,7 +885,7 @@ Both possibilities are described in the following.
867885
When linking qconf, it will be passed the extra option
868886
"-L$(QTDIR)/lib".
869887

870-
4.5 When host programs are actually built
888+
4.6 When host programs are actually built
871889
-----------------------------------------
872890

873891
Kbuild will only build host-programs when they are referenced
@@ -1181,6 +1199,17 @@ When kbuild executes, the following steps are followed (roughly):
11811199
The first example utilises the trick that a config option expands
11821200
to 'y' when selected.
11831201

1202+
KBUILD_RUSTFLAGS
1203+
$(RUSTC) compiler flags
1204+
1205+
Default value - see top level Makefile
1206+
Append or modify as required per architecture.
1207+
1208+
Often, the KBUILD_RUSTFLAGS variable depends on the configuration.
1209+
1210+
Note that target specification file generation (for ``--target``)
1211+
is handled in ``scripts/generate_rust_target.rs``.
1212+
11841213
KBUILD_AFLAGS_KERNEL
11851214
Assembler options specific for built-in
11861215

@@ -1208,6 +1237,19 @@ When kbuild executes, the following steps are followed (roughly):
12081237
are used for $(CC).
12091238
From commandline CFLAGS_MODULE shall be used (see kbuild.rst).
12101239

1240+
KBUILD_RUSTFLAGS_KERNEL
1241+
$(RUSTC) options specific for built-in
1242+
1243+
$(KBUILD_RUSTFLAGS_KERNEL) contains extra Rust compiler flags used to
1244+
compile resident kernel code.
1245+
1246+
KBUILD_RUSTFLAGS_MODULE
1247+
Options for $(RUSTC) when building modules
1248+
1249+
$(KBUILD_RUSTFLAGS_MODULE) is used to add arch-specific options that
1250+
are used for $(RUSTC).
1251+
From commandline RUSTFLAGS_MODULE shall be used (see kbuild.rst).
1252+
12111253
KBUILD_LDFLAGS_MODULE
12121254
Options for $(LD) when linking modules
12131255

Documentation/process/changes.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ you probably needn't concern yourself with pcmciautils.
3131
====================== =============== ========================================
3232
GNU C 5.1 gcc --version
3333
Clang/LLVM (optional) 11.0.0 clang --version
34+
Rust (optional) 1.62.0 rustc --version
35+
bindgen (optional) 0.56.0 bindgen --version
3436
GNU make 3.81 make --version
3537
bash 4.2 bash --version
3638
binutils 2.23 ld -v
@@ -80,6 +82,29 @@ kernels. Older releases aren't guaranteed to work, and we may drop workarounds
8082
from the kernel that were used to support older versions. Please see additional
8183
docs on :ref:`Building Linux with Clang/LLVM <kbuild_llvm>`.
8284

85+
Rust (optional)
86+
---------------
87+
88+
A particular version of the Rust toolchain is required. Newer versions may or
89+
may not work because the kernel depends on some unstable Rust features, for
90+
the moment.
91+
92+
Each Rust toolchain comes with several "components", some of which are required
93+
(like ``rustc``) and some that are optional. The ``rust-src`` component (which
94+
is optional) needs to be installed to build the kernel. Other components are
95+
useful for developing.
96+
97+
Please see Documentation/rust/quick-start.rst for instructions on how to
98+
satisfy the build requirements of Rust support. In particular, the ``Makefile``
99+
target ``rustavailable`` is useful to check why the Rust toolchain may not
100+
be detected.
101+
102+
bindgen (optional)
103+
------------------
104+
105+
``bindgen`` is used to generate the Rust bindings to the C side of the kernel.
106+
It depends on ``libclang``.
107+
83108
Make
84109
----
85110

@@ -348,6 +373,12 @@ Sphinx
348373
Please see :ref:`sphinx_install` in :ref:`Documentation/doc-guide/sphinx.rst <sphinxdoc>`
349374
for details about Sphinx requirements.
350375

376+
rustdoc
377+
-------
378+
379+
``rustdoc`` is used to generate the documentation for Rust code. Please see
380+
Documentation/rust/general-information.rst for more information.
381+
351382
Getting updated software
352383
========================
353384

@@ -364,6 +395,16 @@ Clang/LLVM
364395

365396
- :ref:`Getting LLVM <getting_llvm>`.
366397

398+
Rust
399+
----
400+
401+
- Documentation/rust/quick-start.rst.
402+
403+
bindgen
404+
-------
405+
406+
- Documentation/rust/quick-start.rst.
407+
367408
Make
368409
----
369410

Documentation/rust/arch-support.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Arch Support
4+
============
5+
6+
Currently, the Rust compiler (``rustc``) uses LLVM for code generation,
7+
which limits the supported architectures that can be targeted. In addition,
8+
support for building the kernel with LLVM/Clang varies (please see
9+
Documentation/kbuild/llvm.rst). This support is needed for ``bindgen``
10+
which uses ``libclang``.
11+
12+
Below is a general summary of architectures that currently work. Level of
13+
support corresponds to ``S`` values in the ``MAINTAINERS`` file.
14+
15+
============ ================ ==============================================
16+
Architecture Level of support Constraints
17+
============ ================ ==============================================
18+
``x86`` Maintained ``x86_64`` only.
19+
============ ================ ==============================================

0 commit comments

Comments
 (0)