mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
A new experimental Kconfig option, `RUST_INLINE_HELPERS` is added to
allow C helpers (which were created to allow Rust to call into
inline/macro C functions without having to re-implement the logic in
Rust) to be inlined into Rust crates without performing global LTO.
If the option is enabled, the following is performed:
* For helpers, instead of compiling them to an object file to be linked
into vmlinux, they're compiled to LLVM IR bitcode. Two versions are
generated: one for built-in code (`helpers.bc`) and one for modules
(`helpers_module.bc`, with -DMODULE defined). This ensures that C
macros/inlines that behave differently for modules (e.g. static calls)
function correctly when inlined.
* When a Rust crate or object is compiled, instead of generating an
object file, LLVM bitcode is generated.
* llvm-link is invoked with --internalize to combine the helper bitcode
with the crate bitcode. This step is similar to LTO, but this is much
faster since it only needs to inline the helpers.
* clang is invoked to turn the combined bitcode into a final object file.
* Since clang may produce LLVM bitcode when LTO is enabled, and objtool
requires ELF input, $(cmd_ld_single) is invoked to ensure the object
is converted to ELF before objtool runs.
The --internalize flag tells llvm-link to treat all symbols in
helpers.bc using `internal` linkage [1]. This matches the behavior of
`clang` on `static inline` functions, and avoids exporting the symbol
from the object file.
To ensure that RUST_INLINE_HELPERS is not incompatible with BTF, we pass
the -g0 flag when building helpers. See commit 5daa0c35a1 ("rust:
Disallow BTF generation with Rust + LTO") for details.
We have an intended triple mismatch of `aarch64-unknown-none` vs
`aarch64-unknown-linux-gnu`, so we pass --suppress-warnings to llvm-link
to suppress it.
I considered adding some sort of check that KBUILD_MODNAME is not
present in helpers_module.bc, but this is actually not so easy to carry
out because .bc files store strings in a weird binary format, so you
cannot just grep it for a string to check whether it ended up using
KBUILD_MODNAME anywhere.
[ Andreas writes:
For the rnull driver, enabling helper inlining with this patch
gives an average speedup of 2% over the set of 120 workloads that
we publish on [2].
Link: https://rust-for-linux.com/null-block-driver [2]
This series also uncovered a pre-existing UB instance thanks to an
`objtool` warning which I noticed while testing the series (details
in the mailing list).
- Miguel ]
Link: https://github.com/llvm/llvm-project/pull/170397 [1]
Co-developed-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Co-developed-by: Matthew Maurer <mmaurer@google.com>
Signed-off-by: Matthew Maurer <mmaurer@google.com>
Signed-off-by: Gary Guo <gary@garyguo.net>
Co-developed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://patch.msgid.link/20260203-inline-helpers-v2-3-beb8547a03c9@google.com
[ Some changes, apart from the rebase:
- Added "(EXPERIMENTAL)" to Kconfig as the commit mentions.
- Added `depends on ARM64 || X86_64` and `!UML` for now, since this is
experimental, other architectures may require other changes (e.g.
the issues I mentioned in the mailing list for ARM and UML) and they
are not really tested so far. So let arch maintainers pick this up
if they think it is worth it.
- Gated the `cmd_ld_single` step also into the new mode, which also
means that any possible future `objcopy` step is done after the
translation, as expected.
- Added `.gitignore` for `.bc` with exception for existing script.
- Added `part-of-*` for helpers bitcode files as discussed, and
dropped `$(if $(filter %_module.bc,$@),-DMODULE)` since `-DMODULE`
is already there (would be duplicated otherwise).
- Moved `LLVM_LINK` to keep binutils list alphabetized.
- Fixed typo in title.
- Dropped second `cmd_ld_single` commit message paragraph.
- Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
191 lines
2.3 KiB
Plaintext
191 lines
2.3 KiB
Plaintext
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
# NOTE! Don't add files that are generated in specific
|
|
# subdirectories here. Add them in the ".gitignore" file
|
|
# in that subdirectory instead.
|
|
#
|
|
# NOTE! Please use 'git ls-files -i -c --exclude-per-directory=.gitignore'
|
|
# command after changing this file, to see if there are
|
|
# any tracked files which get ignored after the change.
|
|
#
|
|
# Normal rules (sorted alphabetically)
|
|
#
|
|
.*
|
|
*.a
|
|
*.asn1.[ch]
|
|
*.bc
|
|
*.bin
|
|
*.bz2
|
|
*.c.[012]*.*
|
|
*.dt.yaml
|
|
*.dtb
|
|
*.dtbo
|
|
*.dtb.S
|
|
*.dtbo.S
|
|
*.dwo
|
|
*.dylib
|
|
*.elf
|
|
*.gcno
|
|
*.gcda
|
|
*.gz
|
|
*.i
|
|
*.ko
|
|
*.lex.c
|
|
*.ll
|
|
*.lst
|
|
*.lz4
|
|
*.lzma
|
|
*.lzo
|
|
*.mod
|
|
*.mod.c
|
|
*.o
|
|
*.o.*
|
|
*.patch
|
|
*.pyc
|
|
*.rlib
|
|
*.rmeta
|
|
*.rpm
|
|
*.rsi
|
|
*.s
|
|
*.so
|
|
*.so.dbg
|
|
*.su
|
|
*.symtypes
|
|
*.tab.[ch]
|
|
*.tar
|
|
*.xz
|
|
*.zst
|
|
Module.symvers
|
|
dtbs-list
|
|
modules.order
|
|
|
|
#
|
|
# Top-level generic files
|
|
#
|
|
/linux
|
|
/modules-only.symvers
|
|
/vmlinux
|
|
/vmlinux.32
|
|
/vmlinux.map
|
|
/vmlinux.symvers
|
|
/vmlinux.unstripped
|
|
/vmlinux-gdb.py
|
|
/vmlinuz
|
|
/System.map
|
|
/Module.markers
|
|
/modules.builtin
|
|
/modules.builtin.modinfo
|
|
/modules.builtin.ranges
|
|
/modules.nsdeps
|
|
|
|
#
|
|
# RPM spec file (make rpm-pkg)
|
|
#
|
|
/rpmbuild/
|
|
|
|
#
|
|
# Debian directory (make deb-pkg)
|
|
#
|
|
/debian/
|
|
|
|
#
|
|
# Snap directory (make snap-pkg)
|
|
#
|
|
/snap/
|
|
|
|
#
|
|
# tar directory (make tar*-pkg)
|
|
#
|
|
/tar-install/
|
|
|
|
#
|
|
# pacman files (make pacman-pkg)
|
|
#
|
|
/PKGBUILD
|
|
/pacman/
|
|
|
|
#
|
|
# We don't want to ignore the following even if they are dot-files
|
|
#
|
|
!.clang-format
|
|
!.clippy.toml
|
|
!.cocciconfig
|
|
!.editorconfig
|
|
!.get_maintainer.ignore
|
|
!.gitattributes
|
|
!.gitignore
|
|
!.kunitconfig
|
|
!.mailmap
|
|
!.pylintrc
|
|
!.rustfmt.toml
|
|
|
|
#
|
|
# Generated include files
|
|
#
|
|
/include/config/
|
|
/include/generated/
|
|
/arch/*/include/generated/
|
|
|
|
# stgit generated dirs
|
|
patches-*
|
|
|
|
# quilt's files
|
|
patches
|
|
series
|
|
|
|
# ctags files
|
|
tags
|
|
!tags/
|
|
TAGS
|
|
|
|
# cscope files
|
|
cscope.*
|
|
ncscope.*
|
|
|
|
# gnu global files
|
|
GPATH
|
|
GRTAGS
|
|
GSYMS
|
|
GTAGS
|
|
|
|
# id-utils files
|
|
ID
|
|
|
|
*~
|
|
\#*#
|
|
|
|
#
|
|
# Leavings from module signing
|
|
#
|
|
extra_certificates
|
|
signing_key.pem
|
|
signing_key.priv
|
|
signing_key.x509
|
|
x509.genkey
|
|
|
|
# Kconfig presets
|
|
/all.config
|
|
/alldef.config
|
|
/allmod.config
|
|
/allno.config
|
|
/allrandom.config
|
|
/allyes.config
|
|
|
|
# Kconfig savedefconfig output
|
|
/defconfig
|
|
|
|
# Kdevelop4
|
|
*.kdev4
|
|
|
|
# Clang's compilation database file
|
|
compile_commands.json
|
|
|
|
# Documentation toolchain
|
|
sphinx_*/
|
|
|
|
# Rust analyzer configuration
|
|
/rust-project.json
|
|
|
|
# bc language scripts (not LLVM bitcode)
|
|
!kernel/time/timeconst.bc
|