Another month, another post about the work that I have done as a kernel/compiler developer! One of the highlights this month is that I got LLVM commit access so I can merge my own patches into LLVM, which I did twice so far.
Linux kernel patches
-
powerpc/fadump: Mark fadump_calculate_reserve_size as __init
: LLVM 13 switched over to the New Pass Manager (NPM), which has impacted some inlining decisions, which in turn exposed some bugs in section annotations. The kernel places certain functions and variables into specific sections that are discarded and freed after init. If a non-init function calls an init function, that is technically a use-after-free so the kernel warns when this happens. In this particular case,identical_pvr_fixup()
was not marked as__init
and it was not getting inlined so the calls toidentify_cpu()
andof_get_flat_dt_prop()
resulting in the modpost warnings. In practice, this is not an issue becauseidentical_pvr_fixup()
is only called from__init
context but it is important to get these things right so that real warnings can easily be caught. -
powerpc/prom: Mark identical_pvr_fixup as __init
: Same situation as above :) -
Makefile: Remove '--gcc-toolchain' flag
andMakefile: Only specify '--prefix=' when building with clang + GNU as
: These two patches clean up our clang specific compiler flags. I noticed that we specify--prefix=
with a full path after commit ca9b31f6bb9c (“Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang cross compilation”), meaning that--gcc-toolchain=
is unnecessary because the kernel uses nothing within the sysroot usually provided by GCC. As a follow up, specifying--prefix=
is only necessary when we are using the GNU assembler. -
ARM: Make UNWINDER_ARM depend on ld.bfd or ld.lld 11.0.0+
: A workaround for a bug in all LLD versions prior to 11.0.0. The kernel’s minimum supported version of LLVM is 10.0.1, meaning that if something is broken with LLVM 10.0.1+, it must be fixed or worked around. KernelCI has run into this as their testing plan is now the minimum supported version of LLVM and the latest stable version. -
riscv: Fix CONFIG_FUNCTION_TRACER with clang
: This series fixes build errors on RISC-V whenCONFIG_FUNCTION_TRACER
is set. This was a rather fun series to develop but at the same time, incredibly frustrating because of how it evolved. Unfortunately, it requires a kind of ugly workaround due to an LLVM bug (more on that below). I am hoping that it will be picked up before Linux 5.12 is released but it is not like it cannot be backported to stable. -
riscv: Use $(LD) instead of $(CC) to link vDSO
: In traditional projects, the linker is never directly invoked; instead, the compiler is called and it calls the linker implicitly. For the kernel, it is the other way around: the compiler is only used to build.o
files and the linker is directly invoked on them, except in certain vDSO Makefiles. We have been working on getting rid of this and making the behavior consistent over the kernel so thatld.lld
can be used in more places, asclang
by default defauls to callingld.bfd
. -
Fix cross compiling x86 with clang
: Back in December, someone reported that x86 was not cross compilable due to a lack of the--target=
flag. This is not a very common task as x86 is the dominant architecture but arm64 is starting to become more common, especially with Apple’s M1 chip. This series adds the--target=
flag to specific subdirectories that have hand rolledKBUILD_CFLAGS
(which is an antipattern that should really be avoided but simple fix for now).
LLVM patches
I contributed a few small patches to LLVM this month:
-
debuginfo-tests: Fix check-gdb-mlir-support build after MLIR API change in a4bb667d831c
: A MILR API change that was not reflected back in the MILR debuginfo-tests. -
[RISCV] Fix mcount name
: This is the LLVM side of the RISC-V function tracing series above. Somehow, LLVM used a different name for the mcount symbol than GCC did, which needed to be fixed. Thankfully, LLVM already had the plumbing inside of it for this, I just had to hook into it for RISC-V and add some tests. -
libc: Default LIBC_INSTALL_PREFIX to ${CMAKE_INSTALL_PREFIX}
: While working on the full toolchain tc-build series below, I ran into this issue while runningninja install
.
Patch review and input
I feel like I gave more input/review this month than I have before, which is never a bad thing :) Being a quick reviewer for others incentivizes them to give you a quick review in return. For some of the links below, I linked the top message/patch; my full input can be seen at the bottom by clicking on my name.
-
[PATCH] Fix ld-version.sh script if LLD was built with LLD_VENDOR
-
[PATCH] MIPS: Add comment about CONFIG_MIPS32_O32 in loongson3_defconfig when build with Clang
andRe: [PATCH v2] MIPS: Make MIPS32_O32 depends on !CC_IS_CLANG
-
Re: [PATCH] KVM: arm64: Don't use cbz/adr with external symbols
-
Re: [PATCH] kbuild: dummy-tools: adjust to scripts/cc-version.sh
-
Re: [PATCH] kbuild: fix ld-version.sh to not be affected by locale
Issue triage and reporting
Healthy dose of LLVM regressions and Linux kernel build failures due to new functionality.
-
[mlir] Simplify various pieces of code now that Identifier has access to the Context/Dialect
-
[RISCV] Add basic cost modelling for fixed vector gather/scatter.
-
Build failures with LLVM 13.0.0-++20210330111113+6d2fb3cefba6-1~exp1~20210330091825.3874
-
Issue around hyp_panic while building aarch64 allmodconfig with ThinLTO
-
a0e2bf7cb7006b5a58ee81f4da4fe575875f2781 in -next breaks compiling with CFI
-
Re: [PATCH 3/4] certs: Add ability to preload revocation certs
-
Re: [PATCH v8 09/13] phy: tegra: xusb: Add wake/sleepwalk for Tegra210
-
8ec7ea3ddce7379e13e8dfb4a5260a6d2004aa1c causes more stack usage on PowerPC
Tooling patches
I focused on streamlining our boot utilities, increasing the build coverage, and improving the toolchain build scripts.
-
build-binutils.py: Remove '--with-sysroot' configuration flag
-
Make script more friendly to being used system-wide/LLVM development and add more kernel PGO options
Conclusion
When dealing with various issues all at once, it is hard to see any progress being made so doing these status reports is a great way to help keep myself grounded and realize that progress is indeed being made. There are some cool things in development such as Sami Tolvanen’s Control Flow Integrity series, which is high priority for testing on arm64. Stay tuned for more on that!