raspberrypi / raspberrypi/linux
Compiling the kernel with LLVM=1 fails for ARCH=arm CROSS_COMPILE=armv6l-unknown-linux-gnueabihf- kernels
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.2k
- Forks
- 5.5k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 21
Description
Describe the bug
The issue seems to be that https://github.com/raspberrypi/linux/blob/rpi-5.15.y/arch/arm/lib/memcmp_rpi.S (and perhaps others) are not compatible with the clang assembler.
Steps to reproduce the behaviour
On a nix system with flakes enabled,
$ nix build github:eliasnaur/rpikernel-clang-issue
error: builder for '/nix/store/3zc9nww3crck85wir5fs78zfyfv1nm5q-Raspberry-Pi-Linux-kernel.drv' failed with exit code 2;
last 10 log lines:
> ldrmib DAT5, [S_2]
> ^
> <instantiation>:11:9: note: while in macro instantiation
> memcmp_trailing_15bytes unaligned
> ^
> arch/arm/lib/memcmp_rpi.S:265:6: note: while in macro instantiation
> 140: memcmp_short_inner_loop 1
> ^
> make[1]: *** [scripts/Makefile.build:391: arch/arm/lib/memcmp_rpi.o] Error 1
> make: *** [Makefile:1900: arch/arm/lib] Error 2
For full logs, run 'nix log /nix/store/3zc9nww3crck85wir5fs78zfyfv1nm5q-Raspberry-Pi-Linux-kernel.drv'.
The relevant configuration and building scripts are in the repository. I'm using clang 14.
Device (s)
Raspberry Pi Zero, Raspberry Pi Zero W / WH
System
The issue is during building of custom kernel, not at runtime.
Logs
No response
Additional context
I'm building a custom kernel with LLVM because I have problems producing deterministic output from a gcc build.
The issue can be worked around by disabling BCM2835_FAST_MEMCPY in the kernel config.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with arch/arm/lib/memcmp_rpi.S and reproduce the failure using the linked Nix flake with LLVM=1, ARCH=arm, and the armv6l cross-compiler. Inspect the clang assembler diagnostics around the memcmp macros and compare the behavior with the existing GCC build. Done means the Raspberry Pi kernel builds with LLVM enabled without disabling BCM2835_FAST_MEMCPY.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- compilers, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100