[PATCH v1 0/5] Add support for LoongArch32

mengqinggang mengqinggang@loongson.cn
Tue Dec 2 12:57:00 GMT 2025


Add support for LoongArch32(LA32) and LoongArch32 Reduced(LA32R).

The toolchains add support for LA32 ilp32d abi and LA32R ilp32s abi.

You can build toolchains by script/build-many-glibcs.py:
LA32 ilp32d abi:
build-many-glibcs.py -j128 --keep all . compilers loongarch32-linux-gnu
LA32R ilp32s abi:
build-many-glibcs.py -j128 --keep all . compilers loongarch32-linux-gnusf
Tested by qemu-user and qemu-system. Most testcases passed except for some 
about gdb and fenv. A LA32 linux system based on qemu is here[8].

These patches are based on Jiajie Chen's previous work[1].
The binutils and gcc patches is here[2] [3].
The binutils and gcc source code can also be find at here[4] [5].
A Chinese LA32R instruction set manual is here[6].
There is currently no separate LA32 instruction set manual.
The LA64 instruction set manual[7] specifies the instructions available in LA32.

[1] https://github.com/jiegec/glibc/tree/loongarch32
[2] https://sourceware.org/pipermail/binutils/2025-December/146091.html
[3] https://sourceware.org/pipermail/gcc-patches/2025-November/702128.html
[4] https://github.com/cloudspurs/binutils-gdb/tree/la32
[5] https://github.com/cloudspurs/gcc/tree/la32
[6] https://www.loongson.cn/uploads/images/2025032109211238668.%E9%BE%99%E6%9E%B6%E6%9E%8432%E4%BD%8D%E7%B2%BE%E7%AE%80%E7%89%88%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8C_r1p04.pdf
[7] https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-Vol1-EN/basic-integer-instructions/overview-of-basic-integer-instructions.adoc
[8] https://github.com/sunhaiyong1978/CLFS-for-LoongArch32/blob/main/Qemu_For_LoongArch32-Simple.md

mengqinggang (5):
  LoongArch: Add support for LA32 in sysdeps/loongarch
  LoongArch: Add support for LA32 in sysdeps/loongarch/fpu
  LoongArch: Add new file for LA32 in sysdeps/loongarch/ilp32
  LoongArch: Add support for LA32 in sysdeps/unix/sysv/linux/loongarch
  LoongArch: Add new files for LA32 in
    sysdeps/unix/sysv/linux/loongarch/ilp32

 scripts/build-many-glibcs.py                  |    7 +
 sysdeps/loongarch/configure                   |   36 +-
 sysdeps/loongarch/configure.ac                |   30 +-
 sysdeps/loongarch/dl-machine.h                |   16 +-
 sysdeps/loongarch/dl-tlsdesc-dynamic.h        |   32 +-
 sysdeps/loongarch/dl-tlsdesc.S                |    6 +-
 sysdeps/loongarch/dl-trampoline.h             |    4 +-
 sysdeps/loongarch/fpu/e_scalb.c               |   10 +
 sysdeps/loongarch/fpu/e_scalbf.c              |   10 +
 .../loongarch/fpu/math-use-builtins-llrint.h  |    2 +-
 .../loongarch/fpu/math-use-builtins-logb.h    |    2 +-
 .../loongarch/fpu/math-use-builtins-lrint.h   |    2 +-
 .../loongarch/fpu/math-use-builtins-rint.h    |    2 +-
 .../loongarch/fpu/math-use-builtins-sqrt.h    |   10 +-
 sysdeps/loongarch/fpu/s_scalbn.c              |   10 +
 sysdeps/loongarch/fpu/s_scalbnf.c             |    8 +
 sysdeps/loongarch/fpu/w_ilogb-impl.h          |    8 +
 sysdeps/loongarch/fpu/w_ilogbf-impl.h         |    8 +
 sysdeps/loongarch/hp-timing.h                 |    9 +
 sysdeps/loongarch/ilp32/Implies-after         |    1 +
 sysdeps/loongarch/ilp32/libm-test-ulps        | 1558 +++++++++++
 sysdeps/loongarch/ilp32/libm-test-ulps-name   |    1 +
 sysdeps/loongarch/preconfigure                |    3 +-
 sysdeps/loongarch/preconfigure.ac             |    3 +-
 sysdeps/loongarch/sfp-machine.h               |   33 +
 sysdeps/loongarch/start.S                     |   32 +-
 sysdeps/loongarch/sys/asm.h                   |   93 +-
 sysdeps/loongarch/tst-gnu2-tls2.h             |   12 +-
 sysdeps/unix/sysv/linux/loongarch/Makefile    |    4 +-
 sysdeps/unix/sysv/linux/loongarch/clone.S     |   10 +-
 sysdeps/unix/sysv/linux/loongarch/clone3.S    |    8 +-
 sysdeps/unix/sysv/linux/loongarch/configure   |   40 +
 .../unix/sysv/linux/loongarch/configure.ac    |    8 +
 .../unix/sysv/linux/loongarch/getcontext.S    |   12 +-
 .../unix/sysv/linux/loongarch/gettimeofday.c  |    9 +-
 .../unix/sysv/linux/loongarch/ilp32/Implies   |    2 +
 .../sysv/linux/loongarch/ilp32/arch-syscall.h |  310 +++
 .../sysv/linux/loongarch/ilp32/c++-types.data |   67 +
 .../sysv/linux/loongarch/ilp32/ld.abilist     |    8 +
 .../loongarch/ilp32/libBrokenLocale.abilist   |    1 +
 .../sysv/linux/loongarch/ilp32/libc.abilist   | 2273 +++++++++++++++++
 .../loongarch/ilp32/libc_malloc_debug.abilist |   26 +
 .../sysv/linux/loongarch/ilp32/libm.abilist   | 1126 ++++++++
 .../linux/loongarch/ilp32/libpthread.abilist  |    0
 .../linux/loongarch/ilp32/libresolv.abilist   |   55 +
 .../sysv/linux/loongarch/ilp32/librt.abilist  |    0
 .../loongarch/ilp32/libthread_db.abilist      |   40 +
 .../unix/sysv/linux/loongarch/ldd-rewrite.sed |    2 +-
 .../linux/loongarch/{ => lp64}/arch-syscall.h |    2 +-
 .../unix/sysv/linux/loongarch/pointer_guard.h |   18 +-
 .../unix/sysv/linux/loongarch/readelflib.c    |   33 +-
 .../unix/sysv/linux/loongarch/setcontext.S    |   24 +-
 .../unix/sysv/linux/loongarch/shlib-versions  |    6 +-
 .../unix/sysv/linux/loongarch/swapcontext.S   |   28 +-
 .../sysv/linux/loongarch/syscall_cancel.S     |    2 +-
 sysdeps/unix/sysv/linux/loongarch/sysdep.S    |    8 +-
 sysdeps/unix/sysv/linux/loongarch/sysdep.h    |   30 +-
 sysdeps/unix/sysv/linux/loongarch/vfork.S     |    6 +-
 58 files changed, 5947 insertions(+), 159 deletions(-)
 create mode 100644 sysdeps/loongarch/ilp32/Implies-after
 create mode 100644 sysdeps/loongarch/ilp32/libm-test-ulps
 create mode 100644 sysdeps/loongarch/ilp32/libm-test-ulps-name
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/Implies
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libc_malloc_debug.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libthread_db.abilist
 rename sysdeps/unix/sysv/linux/loongarch/{ => lp64}/arch-syscall.h (99%)

-- 
2.34.1



More information about the Libc-alpha mailing list