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

Tiezhu Yang posted 8 patches 2 years, 1 month ago
There is a newer version of this series
arch/loongarch/Kconfig                             |   2 +
arch/loongarch/Kconfig.debug                       |  11 +
arch/loongarch/Makefile                            |  18 +
arch/loongarch/include/asm/Kbuild                  |   1 +
arch/loongarch/include/asm/bug.h                   |   1 +
arch/loongarch/include/asm/exception.h             |   2 +
arch/loongarch/include/asm/module.h                |   7 +
arch/loongarch/include/asm/orc_header.h            |  19 +
arch/loongarch/include/asm/orc_lookup.h            |  34 ++
arch/loongarch/include/asm/orc_types.h             |  58 +++
arch/loongarch/include/asm/stackframe.h            |   3 +
arch/loongarch/include/asm/unwind.h                |  22 +-
arch/loongarch/include/asm/unwind_hints.h          |  28 ++
arch/loongarch/kernel/Makefile                     |   3 +
arch/loongarch/kernel/entry.S                      |   5 +
arch/loongarch/kernel/genex.S                      |   4 +
arch/loongarch/kernel/module.c                     |  11 +-
arch/loongarch/kernel/relocate_kernel.S            |   2 +
arch/loongarch/kernel/setup.c                      |   2 +
arch/loongarch/kernel/stacktrace.c                 |   1 +
arch/loongarch/kernel/traps.c                      |  44 +-
arch/loongarch/kernel/unwind_orc.c                 | 522 +++++++++++++++++++++
arch/loongarch/kernel/vmlinux.lds.S                |   3 +
arch/loongarch/lib/Makefile                        |   2 +
arch/loongarch/mm/tlb.c                            |  27 +-
arch/loongarch/mm/tlbex.S                          |   9 +
arch/loongarch/vdso/Makefile                       |   1 +
include/linux/compiler.h                           |   9 +
scripts/Makefile                                   |   7 +-
tools/arch/loongarch/include/asm/inst.h            | 161 +++++++
tools/arch/loongarch/include/asm/orc_types.h       |  58 +++
tools/include/linux/bitops.h                       |  11 +
tools/objtool/Makefile                             |   4 +
tools/objtool/arch/loongarch/Build                 |   3 +
tools/objtool/arch/loongarch/decode.c              | 352 ++++++++++++++
.../objtool/arch/loongarch/include/arch/cfi_regs.h |  22 +
tools/objtool/arch/loongarch/include/arch/elf.h    |  30 ++
.../objtool/arch/loongarch/include/arch/special.h  |  33 ++
tools/objtool/arch/loongarch/orc.c                 | 171 +++++++
tools/objtool/arch/loongarch/special.c             |  15 +
tools/objtool/arch/x86/Build                       |   1 +
tools/objtool/arch/x86/orc.c                       | 188 ++++++++
tools/objtool/check.c                              | 118 +++--
tools/objtool/include/objtool/orc.h                |  14 +
tools/objtool/orc_dump.c                           |  69 +--
tools/objtool/orc_gen.c                            | 113 +----
46 files changed, 1964 insertions(+), 257 deletions(-)
create mode 100644 arch/loongarch/include/asm/orc_header.h
create mode 100644 arch/loongarch/include/asm/orc_lookup.h
create mode 100644 arch/loongarch/include/asm/orc_types.h
create mode 100644 arch/loongarch/include/asm/unwind_hints.h
create mode 100644 arch/loongarch/kernel/unwind_orc.c
create mode 100644 tools/arch/loongarch/include/asm/inst.h
create mode 100644 tools/arch/loongarch/include/asm/orc_types.h
create mode 100644 tools/objtool/arch/loongarch/Build
create mode 100644 tools/objtool/arch/loongarch/decode.c
create mode 100644 tools/objtool/arch/loongarch/include/arch/cfi_regs.h
create mode 100644 tools/objtool/arch/loongarch/include/arch/elf.h
create mode 100644 tools/objtool/arch/loongarch/include/arch/special.h
create mode 100644 tools/objtool/arch/loongarch/orc.c
create mode 100644 tools/objtool/arch/loongarch/special.c
create mode 100644 tools/objtool/arch/x86/orc.c
create mode 100644 tools/objtool/include/objtool/orc.h
[PATCH v3 0/8] Add objtool and orc support for LoongArch
Posted by Tiezhu Yang 2 years, 1 month ago
This version is based on the latest torvalds/linux.git (20231020)
which includes the commit 00c2ca84c680 ("LoongArch: Use SYM_CODE_*
to annotate exception handlers"), tested with the latest upstream
gcc and binutils (20231009).

v3:
  -- Use tab for indentation in special.h
  -- Replace BP/bp with FP/fp
  -- Modify jirl decoder to handle special case in hibernate_asm.o
  -- Remove the calling of bswap_if_needed() which always return false
  -- Remove OBJECT_FILES_NON_STANDARD_suspend_asm.o
  -- Remove check of assembler version in Makefile
  -- Remove UNWIND_HINT_EMPTY in kernel_entry
  -- Put unwind_init() after cpu_probe()
  -- Remove CONFIG_BPF_JIT_ALWAYS_ON in defconfig
  -- Rename title of patch #8 to "Add ORC stack unwinder support"
  -- Fix build error of scripts/sorttable.h reported by test robot
  -- Add exception_table[] to save exception handlers

Tiezhu Yang (8):
  objtool/LoongArch: Enable objtool to be built
  objtool/LoongArch: Implement instruction decoder
  objtool/x86: Separate arch-specific and generic parts
  objtool/LoongArch: Enable orc to be built
  objtool: Check local label about sibling call
  objtool: Check local label in add_dead_ends()
  objtool: Check local label in read_unwind_hints()
  LoongArch: Add ORC stack unwinder support

 arch/loongarch/Kconfig                             |   2 +
 arch/loongarch/Kconfig.debug                       |  11 +
 arch/loongarch/Makefile                            |  18 +
 arch/loongarch/include/asm/Kbuild                  |   1 +
 arch/loongarch/include/asm/bug.h                   |   1 +
 arch/loongarch/include/asm/exception.h             |   2 +
 arch/loongarch/include/asm/module.h                |   7 +
 arch/loongarch/include/asm/orc_header.h            |  19 +
 arch/loongarch/include/asm/orc_lookup.h            |  34 ++
 arch/loongarch/include/asm/orc_types.h             |  58 +++
 arch/loongarch/include/asm/stackframe.h            |   3 +
 arch/loongarch/include/asm/unwind.h                |  22 +-
 arch/loongarch/include/asm/unwind_hints.h          |  28 ++
 arch/loongarch/kernel/Makefile                     |   3 +
 arch/loongarch/kernel/entry.S                      |   5 +
 arch/loongarch/kernel/genex.S                      |   4 +
 arch/loongarch/kernel/module.c                     |  11 +-
 arch/loongarch/kernel/relocate_kernel.S            |   2 +
 arch/loongarch/kernel/setup.c                      |   2 +
 arch/loongarch/kernel/stacktrace.c                 |   1 +
 arch/loongarch/kernel/traps.c                      |  44 +-
 arch/loongarch/kernel/unwind_orc.c                 | 522 +++++++++++++++++++++
 arch/loongarch/kernel/vmlinux.lds.S                |   3 +
 arch/loongarch/lib/Makefile                        |   2 +
 arch/loongarch/mm/tlb.c                            |  27 +-
 arch/loongarch/mm/tlbex.S                          |   9 +
 arch/loongarch/vdso/Makefile                       |   1 +
 include/linux/compiler.h                           |   9 +
 scripts/Makefile                                   |   7 +-
 tools/arch/loongarch/include/asm/inst.h            | 161 +++++++
 tools/arch/loongarch/include/asm/orc_types.h       |  58 +++
 tools/include/linux/bitops.h                       |  11 +
 tools/objtool/Makefile                             |   4 +
 tools/objtool/arch/loongarch/Build                 |   3 +
 tools/objtool/arch/loongarch/decode.c              | 352 ++++++++++++++
 .../objtool/arch/loongarch/include/arch/cfi_regs.h |  22 +
 tools/objtool/arch/loongarch/include/arch/elf.h    |  30 ++
 .../objtool/arch/loongarch/include/arch/special.h  |  33 ++
 tools/objtool/arch/loongarch/orc.c                 | 171 +++++++
 tools/objtool/arch/loongarch/special.c             |  15 +
 tools/objtool/arch/x86/Build                       |   1 +
 tools/objtool/arch/x86/orc.c                       | 188 ++++++++
 tools/objtool/check.c                              | 118 +++--
 tools/objtool/include/objtool/orc.h                |  14 +
 tools/objtool/orc_dump.c                           |  69 +--
 tools/objtool/orc_gen.c                            | 113 +----
 46 files changed, 1964 insertions(+), 257 deletions(-)
 create mode 100644 arch/loongarch/include/asm/orc_header.h
 create mode 100644 arch/loongarch/include/asm/orc_lookup.h
 create mode 100644 arch/loongarch/include/asm/orc_types.h
 create mode 100644 arch/loongarch/include/asm/unwind_hints.h
 create mode 100644 arch/loongarch/kernel/unwind_orc.c
 create mode 100644 tools/arch/loongarch/include/asm/inst.h
 create mode 100644 tools/arch/loongarch/include/asm/orc_types.h
 create mode 100644 tools/objtool/arch/loongarch/Build
 create mode 100644 tools/objtool/arch/loongarch/decode.c
 create mode 100644 tools/objtool/arch/loongarch/include/arch/cfi_regs.h
 create mode 100644 tools/objtool/arch/loongarch/include/arch/elf.h
 create mode 100644 tools/objtool/arch/loongarch/include/arch/special.h
 create mode 100644 tools/objtool/arch/loongarch/orc.c
 create mode 100644 tools/objtool/arch/loongarch/special.c
 create mode 100644 tools/objtool/arch/x86/orc.c
 create mode 100644 tools/objtool/include/objtool/orc.h

-- 
2.1.0
Re: [PATCH v3 0/8] Add objtool and orc support for LoongArch
Posted by Huacai Chen 2 years, 1 month ago
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

Huacai

On Fri, Oct 20, 2023 at 10:27 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> This version is based on the latest torvalds/linux.git (20231020)
> which includes the commit 00c2ca84c680 ("LoongArch: Use SYM_CODE_*
> to annotate exception handlers"), tested with the latest upstream
> gcc and binutils (20231009).
>
> v3:
>   -- Use tab for indentation in special.h
>   -- Replace BP/bp with FP/fp
>   -- Modify jirl decoder to handle special case in hibernate_asm.o
>   -- Remove the calling of bswap_if_needed() which always return false
>   -- Remove OBJECT_FILES_NON_STANDARD_suspend_asm.o
>   -- Remove check of assembler version in Makefile
>   -- Remove UNWIND_HINT_EMPTY in kernel_entry
>   -- Put unwind_init() after cpu_probe()
>   -- Remove CONFIG_BPF_JIT_ALWAYS_ON in defconfig
>   -- Rename title of patch #8 to "Add ORC stack unwinder support"
>   -- Fix build error of scripts/sorttable.h reported by test robot
>   -- Add exception_table[] to save exception handlers
>
> Tiezhu Yang (8):
>   objtool/LoongArch: Enable objtool to be built
>   objtool/LoongArch: Implement instruction decoder
>   objtool/x86: Separate arch-specific and generic parts
>   objtool/LoongArch: Enable orc to be built
>   objtool: Check local label about sibling call
>   objtool: Check local label in add_dead_ends()
>   objtool: Check local label in read_unwind_hints()
>   LoongArch: Add ORC stack unwinder support
>
>  arch/loongarch/Kconfig                             |   2 +
>  arch/loongarch/Kconfig.debug                       |  11 +
>  arch/loongarch/Makefile                            |  18 +
>  arch/loongarch/include/asm/Kbuild                  |   1 +
>  arch/loongarch/include/asm/bug.h                   |   1 +
>  arch/loongarch/include/asm/exception.h             |   2 +
>  arch/loongarch/include/asm/module.h                |   7 +
>  arch/loongarch/include/asm/orc_header.h            |  19 +
>  arch/loongarch/include/asm/orc_lookup.h            |  34 ++
>  arch/loongarch/include/asm/orc_types.h             |  58 +++
>  arch/loongarch/include/asm/stackframe.h            |   3 +
>  arch/loongarch/include/asm/unwind.h                |  22 +-
>  arch/loongarch/include/asm/unwind_hints.h          |  28 ++
>  arch/loongarch/kernel/Makefile                     |   3 +
>  arch/loongarch/kernel/entry.S                      |   5 +
>  arch/loongarch/kernel/genex.S                      |   4 +
>  arch/loongarch/kernel/module.c                     |  11 +-
>  arch/loongarch/kernel/relocate_kernel.S            |   2 +
>  arch/loongarch/kernel/setup.c                      |   2 +
>  arch/loongarch/kernel/stacktrace.c                 |   1 +
>  arch/loongarch/kernel/traps.c                      |  44 +-
>  arch/loongarch/kernel/unwind_orc.c                 | 522 +++++++++++++++++++++
>  arch/loongarch/kernel/vmlinux.lds.S                |   3 +
>  arch/loongarch/lib/Makefile                        |   2 +
>  arch/loongarch/mm/tlb.c                            |  27 +-
>  arch/loongarch/mm/tlbex.S                          |   9 +
>  arch/loongarch/vdso/Makefile                       |   1 +
>  include/linux/compiler.h                           |   9 +
>  scripts/Makefile                                   |   7 +-
>  tools/arch/loongarch/include/asm/inst.h            | 161 +++++++
>  tools/arch/loongarch/include/asm/orc_types.h       |  58 +++
>  tools/include/linux/bitops.h                       |  11 +
>  tools/objtool/Makefile                             |   4 +
>  tools/objtool/arch/loongarch/Build                 |   3 +
>  tools/objtool/arch/loongarch/decode.c              | 352 ++++++++++++++
>  .../objtool/arch/loongarch/include/arch/cfi_regs.h |  22 +
>  tools/objtool/arch/loongarch/include/arch/elf.h    |  30 ++
>  .../objtool/arch/loongarch/include/arch/special.h  |  33 ++
>  tools/objtool/arch/loongarch/orc.c                 | 171 +++++++
>  tools/objtool/arch/loongarch/special.c             |  15 +
>  tools/objtool/arch/x86/Build                       |   1 +
>  tools/objtool/arch/x86/orc.c                       | 188 ++++++++
>  tools/objtool/check.c                              | 118 +++--
>  tools/objtool/include/objtool/orc.h                |  14 +
>  tools/objtool/orc_dump.c                           |  69 +--
>  tools/objtool/orc_gen.c                            | 113 +----
>  46 files changed, 1964 insertions(+), 257 deletions(-)
>  create mode 100644 arch/loongarch/include/asm/orc_header.h
>  create mode 100644 arch/loongarch/include/asm/orc_lookup.h
>  create mode 100644 arch/loongarch/include/asm/orc_types.h
>  create mode 100644 arch/loongarch/include/asm/unwind_hints.h
>  create mode 100644 arch/loongarch/kernel/unwind_orc.c
>  create mode 100644 tools/arch/loongarch/include/asm/inst.h
>  create mode 100644 tools/arch/loongarch/include/asm/orc_types.h
>  create mode 100644 tools/objtool/arch/loongarch/Build
>  create mode 100644 tools/objtool/arch/loongarch/decode.c
>  create mode 100644 tools/objtool/arch/loongarch/include/arch/cfi_regs.h
>  create mode 100644 tools/objtool/arch/loongarch/include/arch/elf.h
>  create mode 100644 tools/objtool/arch/loongarch/include/arch/special.h
>  create mode 100644 tools/objtool/arch/loongarch/orc.c
>  create mode 100644 tools/objtool/arch/loongarch/special.c
>  create mode 100644 tools/objtool/arch/x86/orc.c
>  create mode 100644 tools/objtool/include/objtool/orc.h
>
> --
> 2.1.0
>
Re: [PATCH v3 0/8] Add objtool and orc support for LoongArch
Posted by Tiezhu Yang 2 years, 1 month ago

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.

wget 
https://github.com/loongson/build-tools/releases/download/2023.08.08/x86_64-cross-tools-loongarch64-gcc-libc.tar.xz
tar xf x86_64-cross-tools-loongarch64-gcc-libc.tar.xz -C /opt
export PATH=/opt/cross-tools/bin/:$PATH
export 
LD_LIBRARY_PATH=/opt/cross-tools/loongarch64-unknown-linux-gnu/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/opt/cross-tools/lib:$LD_LIBRARY_PATH
export CROSS_COMPILE=loongarch64-unknown-linux-gnu-
export ARCH=loongarch

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

cd linux.git
make loongson3_defconfig
make menuconfig   # select CONFIG_UNWINDER_ORC
make -j4

Thanks,
Tiezhu
Re: [PATCH v3 0/8] Add objtool and orc support for LoongArch
Posted by Xi Ruoyao 2 years, 1 month ago
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.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
Re: [PATCH v3 0/8] Add objtool and orc support for LoongArch
Posted by Tiezhu Yang 2 years, 1 month ago

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.

Thanks,
Tiezhu
Re: [PATCH v3 0/8] Add objtool and orc support for LoongArch
Posted by Huacai Chen 2 years, 1 month ago
Hi, Tiezhu,

On Fri, Oct 20, 2023 at 6:55 PM Tiezhu Yang <yangtiezhu@loongson.cn> 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
>
>