Source: kbuild
Version: 1:0.1.9998svn3604+dfsg-1
Severity: normal
Tags: patch
User: [email protected]
Usertags: loong64

Dear maintainers,

Compiling the kbuild failed for loong64 in the Debian Package Auto-Building environment.
Build failed 14 times.
The build error log is as follows,
```
.......
kBuild/env.sh --full make -f bootstrap.gmk SRCDIR=`pwd` ASH=/bin/bash ECHO=/bin/echo MKDIR=/bin/mkdir CP=/bin/cp RM=/bin/rm INSTALL=/usr/bin/install YACC=/usr/bin/byacc
kBuild/env.sh: unknown cpu/arch - loongarch64
make[1]: *** [debian/rules:21: override_dh_auto_build] Error 1
```
The full log can be found at https://buildd.debian.org/status/logs.php?pkg=kbuild&arch=loong64.

Please consider the patch I have attached.
And the kbuild source package was compiled successfully on my local loong64 rootfs environment.
```
......
dpkg-deb: building package 'kbuild' in '../kbuild_0.1.9998svn3604+dfsg-1_loong64.deb'.
 dpkg-genbuildinfo -O../kbuild_0.1.9998svn3604+dfsg-1_loong64.buildinfo
 dpkg-genchanges -O../kbuild_0.1.9998svn3604+dfsg-1_loong64.changes
```
Would it be possible to include the support for loongarch64 in the next upload?

thanks,
Dandan Zhang

Description: Add loongarch64 support 
Last-Update: 2024-07-02

--- kbuild-0.1.9998svn3604+dfsg.orig/kBuild/env.sh
+++ kbuild-0.1.9998svn3604+dfsg/kBuild/env.sh
@@ -377,6 +377,9 @@ if test -z "$KBUILD_HOST_ARCH"; then
         ia64)
             KBUILD_HOST_ARCH='ia64'
             ;;
+        loongarch64*)
+            KBUILD_HOST_ARCH='loong64'
+            ;;
         m68k)
             KBUILD_HOST_ARCH='m68k'
             ;;
--- kbuild-0.1.9998svn3604+dfsg.orig/kBuild/header.kmk
+++ kbuild-0.1.9998svn3604+dfsg/kBuild/header.kmk
@@ -197,8 +197,8 @@ KBUILD_BLD_TYPES := release profile debu
 # build types. (PORTME)
 #
 KBUILD_OSES      := darwin dos dragonfly freebsd gnuhurd gnukfbsd gnuknbsd haiku l4 linux netbsd nt openbsd os2 solaris win os-agnostic
-KBUILD_ARCHES    := x86 amd64 noarch alpha arm32 arm64 hppa32 hppa64 ia64 m68k mips32 mips64 ppc32 ppc64 riscv32 riscv64 s390 s390x sh32 sh64 sparc32 sparc64 x32
-KBUILD_ARCHES_64 := amd64 alpha arm64 hppa64 ia64 mips64 ppc64 riscv64 s390x sh64 sparc64 x32
+KBUILD_ARCHES    := x86 amd64 noarch alpha arm32 arm64 hppa32 hppa64 ia64 loong64 m68k mips32 mips64 ppc32 ppc64 riscv32 riscv64 s390 s390x sh32 sh64 sparc32 sparc64 x32
+KBUILD_ARCHES_64 := amd64 alpha arm64 hppa64 ia64 loong64 mips64 ppc64 riscv64 s390x sh64 sparc64 x32
 KBUILD_ARCHES_32 := x86 arm32 hppa32 m68k mips32 ppc32 riscv32 s390 sh32 sparc32
 
 
--- kbuild-0.1.9998svn3604+dfsg.orig/src/grep/lib/sigsegv.c
+++ kbuild-0.1.9998svn3604+dfsg/src/grep/lib/sigsegv.c
@@ -168,6 +168,18 @@ int libsigsegv_version = LIBSIGSEGV_VERS
    because $bsp and $bspstore never differ by more than ca. 1 KB.  */
 #  define SIGSEGV_FAULT_BSP_POINTER  ((ucontext_t *) ucp)->uc_mcontext.sc_ar_bsp
 
+# elif defined __loongarch64
+
+/* See glibc/sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
+   and the definition of GET_STACK in
+   glibc/sysdeps/unix/sysv/linux/loongarch/sigcontextinfo.h.
+   Note that the 'mcontext_t' defined in
+   glibc/sysdeps/unix/sysv/linux/loongarch/sys/ucontext.h
+   and the 'struct sigcontext' defined in <asm/sigcontext.h>
+   are effectively the same.  */
+
+#  define SIGSEGV_FAULT_STACKPOINTER  ((ucontext_t *) ucp)->uc_mcontext.__gregs[LARCH_REG_SP]
+
 # elif defined __m68k__
 
 /* See glibc/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
--- kbuild-0.1.9998svn3604+dfsg.orig/src/lib/kStuff/include/k/kDefs.h
+++ kbuild-0.1.9998svn3604+dfsg/src/lib/kStuff/include/k/kDefs.h
@@ -196,8 +196,10 @@
 #define K_ARCH_RISCV_64         (13 | K_ARCH_BIT_64 | K_ARCH_END_LITTLE)
 /** 64-bit RISC-V, big endian. */
 #define K_ARCH_RISCV_64_BE      (13 | K_ARCH_BIT_64 | K_ARCH_END_BIG)
+/** 64-bit LOONGARCH */
+#define K_ARCH_LOONGARCH_64     (14 | K_ARCH_BIT_64 | K_ARCH_END_BI)
 /** The end of the valid architecture values (exclusive). */
-#define K_ARCH_MAX              (12+1)
+#define K_ARCH_MAX              (14+1)
 /** @} */
 
 
@@ -222,6 +224,8 @@
 #  define K_ARCH    K_ARCH_PARISC_64
 # elif defined(__hppa__)
 #  define K_ARCH    K_ARCH_PARISC_32
+# elif defined(__loongarch64)
+#  define K_ARCH    K_ARCH_LOONGARCH_64
 # elif defined(__m68k__)
 #  define K_ARCH    K_ARCH_M68K
 # elif defined(__mips64)

Reply via email to