Re: [PATCH v3 0/8] Add objtool and orc support for LoongArch

From: Huacai Chen
Date: Sat Oct 21 2023 - 04:14:16 EST


Hi, Tiezhu,

On Fri, Oct 20, 2023 at 6:55 PM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> wrote:
>
>
>
> On 10/20/2023 06:45 PM, Xi Ruoyao wrote:
> > On Fri, 2023-10-20 at 18:28 +0800, Tiezhu Yang wrote:
> >> On 10/20/2023 04:51 PM, Huacai Chen wrote:
> >>> Cross compiling on X86 for LoongArch fails:
> >>>
> >>> CALL scripts/checksyscalls.sh
> >>> DESCEND objtool
> >>> make[5]: *** No rule to make target
> >>> '/usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h', needed by
> >>> '/home/chenhuacai/linux-official.git/tools/objtool/libsubcmd/exec-cmd.o'.
> >>> Stop.
> >>> make[4]: *** [Makefile:80:
> >>> /home/chenhuacai/linux-official.git/tools/objtool/libsubcmd/libsubcmd-in.o]
> >>> Error 2
> >>> make[3]: *** [Makefile:82:
> >>> /home/chenhuacai/linux-official.git/tools/objtool/libsubcmd/libsubcmd.a]
> >>> Error 2
> >>> make[2]: *** [Makefile:73: objtool] Error 2
> >>> make[1]: *** [/home/chenhuacai/linux-official.git/Makefile:1355:
> >>> tools/objtool] Error 2
> >>> make: *** [Makefile:234: __sub-make] Error 2
> >>
> >> It seems that there is no stdbool.h in your cross compile environment.
> >>
> >> It works well with the following steps, you can try it.
> >
> > /* snip */
> >
> >> find /opt -name stdbool.h
> >> /opt/cross-tools/lib/gcc/loongarch64-unknown-linux-gnu/14.0.0/include/stdbool.h
> >> /opt/cross-tools/loongarch64-unknown-linux-gnu/include/c++/14.0.0/tr1/stdbool.h
> >
> > The problem is HOSTCC cannot find stdbool.h, not (target) CC. So these
> > two files are not relevant.
> >
>
> Oh, thank you for pointing out the real reason of this issue.
>
> By the way, my test system is Fedora 38 x86_64, it works well.
I can also cross compile now.

And I have fixed some issues I comments in this series, then I have pushed here:
https://github.com/chenhuacai/linux/commits/master

To save time, you can do additional modifications (e.g. Peter's
suggestions) on top of my version.

And there are still some problems that need some more effort.
1, Build warnings:
AS arch/loongarch/kernel/fpu.o
arch/loongarch/kernel/fpu.o: warning: objtool: _restore_fp+0xb0:
unreachable instruction
arch/loongarch/kernel/fpu.o: warning: objtool: _restore_lsx+0xf4:
unreachable instruction
arch/loongarch/kernel/fpu.o: warning: objtool: _restore_lasx+0xf4:
unreachable instruction
CC arch/loongarch/kernel/kfpu.o
AS arch/loongarch/kernel/lbt.o
arch/loongarch/kernel/lbt.o: warning: objtool:
_restore_ftop_context+0x18: unreachable instruction

2, Partial call stack:
[10589.180597] [<9000000002e435e0>] show_stack+0x34/0x14c
[10589.188124] [<9000000003f0bd7c>] dump_stack_lvl+0x5c/0x88
[10589.193487] [<9000000003f0bdb8>] dump_stack+0x10/0x20
[10589.198505] [<9000000002e43704>] show_regs+0xc/0x1c
[10589.203350] [<9000000003edb174>] nmi_cpu_backtrace+0x154/0x15c
[10589.209146] [<9000000002e43acc>] handle_backtrace+0xc/0x40
[10589.214597] [<9000000002f165d8>] __flush_smp_call_function_queue+0xe4/0x2bc
[10589.221518] [<9000000002f17538>]
generic_smp_call_function_single_interrupt+0xc/0x1c
[10589.229217] [<9000000002e4e6a0>] loongson_ipi_interrupt+0x7c/0xc0
[10589.235274] [<9000000002ecf1c4>] __handle_irq_event_percpu+0x50/0x130
[10589.241675] [<9000000002ecf2b8>] handle_irq_event_percpu+0x14/0x70
[10589.247818] [<9000000002ed5aa4>] handle_percpu_irq+0x50/0x78
[10589.253443] [<9000000002ece3c0>] generic_handle_domain_irq+0x24/0x40
[10589.259758] [<900000000369be68>] handle_cpu_irq+0x68/0xa4
[10589.265122] [<9000000003f0c128>] handle_loongarch_irq+0x2c/0x4c
[10589.271004] [<9000000003f0c1cc>] do_vint+0x84/0xbc

3, Runtime warnings:
[ 51.891244] [<9000000002b935e0>] show_stack+0x34/0x14c
[ 51.898777] [<9000000003c5bd7c>] dump_stack_lvl+0x5c/0x88
[ 51.904144] [<9000000003c5bdb8>] dump_stack+0x10/0x20
[ 51.909161] [<9000000003c2b158>] nmi_cpu_backtrace+0x138/0x15c
[ 51.914960] [<9000000003c2b324>] nmi_trigger_cpumask_backtrace+0x1a8/0x1e4
[ 51.921794] [<9000000002b944ec>] arch_trigger_cpumask_backtrace+0x10/0x20
[ 51.928541] [<9000000003508bd0>] sysrq_handle_showallcpus+0x14/0x24
[ 51.934772] [<90000000035095b8>] __handle_sysrq+0x184/0x1e0
[ 51.940310] [<9000000003509cf8>] write_sysrq_trigger+0x94/0x9c
[ 51.946107] [<9000000002e98a6c>] proc_reg_write+0xb4/0xf0
[ 51.951472] [<9000000002e07c4c>] vfs_write+0x108/0x3d8
[ 51.956580] [<9000000002e080d0>] ksys_write+0x74/0x124
[ 51.961686] [<9000000002e0818c>] sys_write+0xc/0x1c
[ 51.966533] [<9000000003c5d0b8>] do_syscall+0x78/0x98
[ 51.971552] [<9000000002b91198>] handle_syscall+0xb8/0x158
[ 51.977002] WARNING: unknown SP base reg 0 at handle_syscall+0xb8/0x158

Huacai

>
> Thanks,
> Tiezhu
>
>