[PATCH v3] RISC-V: build: Allow LTO to be selected

Conor Dooley conor at kernel.org
Tue Oct 10 14:02:38 PDT 2023


On Tue, Oct 10, 2023 at 12:52:47PM -0700, Nathan Chancellor wrote:
> On Tue, Oct 10, 2023 at 10:03:15AM -0700, Nick Desaulniers wrote:
> > On Tue, Oct 3, 2023 at 12:17 PM Nathan Chancellor <nathan at kernel.org> wrote:
> > >
> > > From: Wende Tan <twd2.me at gmail.com>
> > >
> > > Allow LTO to be selected for RISC-V, only when LLD >= 14, since there is an
> > > issue [1] in prior LLD versions that prevents LLD to generate proper
> > > machine code for RISC-V when writing `nop`s.
> > >
> > > I have tested enabling LTO for `defconfig`. The LLD took ~2m21s and ~3GiB
> > > on our Intel Xeon Gold 6140 server and produced an 18MiB Image. The image
> > > can boot to shell using an archriscv rootfs on QEMU.
> > >
> > > I have also tested it for `allyesconfig` without COMPILE_TEST, FTRACE,
> > > KASAN, and GCOV. The LLD took ~7h03m and ~335GiB on the server,
> > > successfully producing a 1.7GiB Image. Unfortunately, we cannot boot this
> > > image because the `create_kernel_page_table()` -> `alloc_pmd_early()` ->
> > > `BUG_ON()` logic limits the image to be < 1GiB. Maybe we can fix it in a
> > > separate patch further.
> > >
> > > Disable LTO for arch/riscv/kernel/pi, as llvm-objcopy expects an ELF
> > > object file when manipulating the files in that subfolder, rather than
> > > LLVM bitcode.
> > >
> > > [1] https://github.com/llvm/llvm-project/issues/50505, resolved by LLVM
> > >     commit e63455d5e0e5 ("[MC] Use local MCSubtargetInfo in writeNops")
> > >
> > > Tested-by: Wende Tan <twd2.me at gmail.com>
> > > Signed-off-by: Wende Tan <twd2.me at gmail.com>
> > > Co-developed-by: Nathan Chancellor <nathan at kernel.org>
> > > Signed-off-by: Nathan Chancellor <nathan at kernel.org>
> > 
> > Perhaps worth a v4 due to linker relaxation resulting in boot failures
> > you observed:
> > https://github.com/ClangBuiltLinux/linux/issues/1942 ?
> 
> Yes, agreed. RISC-V patchwork folks, consider marking this as "Changes
> Requested" or whatever other status there is that indicates that I need
> to send a v4 working around that issue, at least until we better
> understand the issue.

Done.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20231010/3c31b3e0/attachment.sig>


More information about the linux-riscv mailing list