Source: mlton
Severity: normal
Tags: patch ftbfs loong64
X-Debbugs-Cc: zhangjial...@loongson.cn

Dear Maintainer,
  Mlton is not support loongarch64 now , I port and bootstrap it in
loongarch64 . Please help to support mlton loongarch64 in debian. 

Thanks,
JiaLing Zhang
--- mlton-20210117+dfsg.orig/basis-library/mlton/platform.sig
+++ mlton-20210117+dfsg/basis-library/mlton/platform.sig
@@ -9,7 +9,7 @@ signature MLTON_PLATFORM =
    sig
       structure Arch:
          sig
-            datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | m68k |
+            datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | 
LoongArch64 | m68k |
                          MIPS | MIPS64 | PowerPC | PowerPC64 | RISCV |
                          RISCV64 | S390 | Sparc | X86
 
--- mlton-20210117+dfsg.orig/basis-library/mlton/platform.sml
+++ mlton-20210117+dfsg/basis-library/mlton/platform.sml
@@ -23,6 +23,7 @@ structure MLtonPlatform: MLTON_PLATFORM
                 (ARM64, "ARM64"),
                 (HPPA, "HPPA"),
                 (IA64, "IA64"),
+                (LoongArch64, "LoongArch64"),
                 (m68k, "m68k"),
                 (MIPS, "MIPS"),
                 (MIPS64, "MIPS64"),
--- mlton-20210117+dfsg.orig/basis-library/primitive/prim-mlton.sml
+++ mlton-20210117+dfsg/basis-library/primitive/prim-mlton.sml
@@ -154,6 +154,7 @@ structure Platform =
              | ARM64
              | HPPA
              | IA64
+             | LoongArch64
              | m68k
              | MIPS
              | MIPS64
@@ -173,6 +174,7 @@ structure Platform =
                 | "arm64" => ARM64
                 | "hppa" => HPPA
                 | "ia64" => IA64
+                | "loongarch64" => LoongArch64
                 | "m68k" => m68k
                 | "mips" => MIPS
                 | "mips64" => MIPS64
--- mlton-20210117+dfsg.orig/bin/platform
+++ mlton-20210117+dfsg/bin/platform
@@ -109,6 +109,9 @@ parisc*)
 ia64*)
         HOST_ARCH=ia64
 ;;
+loongarch64*)
+        HOST_ARCH=loongarch64
+;;
 m68k*)
         HOST_ARCH=m68k
 ;;
--- mlton-20210117+dfsg.orig/lib/stubs/mlton-stubs/mlton.sml
+++ mlton-20210117+dfsg/lib/stubs/mlton-stubs/mlton.sml
@@ -159,7 +159,7 @@ structure MLton: MLTON =
 
             structure Arch =
                struct
-                  datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 |
+                  datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | 
LoongArch64 |
                                m68k | MIPS | MIPS64 | PowerPC | PowerPC64 | 
RISCV |
                                RISCV64 | S390 | Sparc | X86
 
@@ -169,6 +169,7 @@ structure MLton: MLTON =
                              (ARM64, "ARM64"),
                              (HPPA, "HPPA"),
                              (IA64, "IA64"),
+                             (LoongArch64,"LoongArch64"),
                              (m68k, "m68k"),
                              (MIPS, "MIPS"),
                              (MIPS64, "MIPS64"),
--- mlton-20210117+dfsg.orig/lib/stubs/mlton-stubs/platform.sig
+++ mlton-20210117+dfsg/lib/stubs/mlton-stubs/platform.sig
@@ -9,7 +9,7 @@ signature MLTON_PLATFORM =
    sig
       structure Arch:
          sig
-            datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | m68k |
+            datatype t = Alpha | AMD64 | ARM | ARM64 | HPPA | IA64 | 
LoongArch64 | m68k |
                          MIPS | MIPS64 | PowerPC | PowerPC64 | RISCV | RISCV64 
|
                          S390 | Sparc | X86
 
--- mlton-20210117+dfsg.orig/mlton/main/main.fun
+++ mlton-20210117+dfsg/mlton/main/main.fun
@@ -199,6 +199,7 @@ fun defaultAlignIs8 () =
        | ARM64 => true
        | HPPA => true
        | IA64 => true
+       | LoongArch64 => true
        | MIPS => true
        | MIPS64 => true
        | RISCV64 => true
--- mlton-20210117+dfsg.orig/runtime/cenv.h
+++ mlton-20210117+dfsg/runtime/cenv.h
@@ -99,6 +99,8 @@ COMPILE_TIME_ASSERT(sizeof_double__is_ei
 #include "platform/hppa.h"
 #elif (defined (__ia64__))
 #include "platform/ia64.h"
+#elif (defined (__loongarch64))
+#include "platform/loongarch64.h"
 #elif (defined (__m68k__))
 #include "platform/m68k.h"
 #elif (defined (__mips64))
--- /dev/null
+++ mlton-20210117+dfsg/runtime/gdtoa/arith.h
@@ -0,0 +1,6 @@
+#define IEEE_8087
+#define Arith_Kind_ASL 1
+#define Long int
+#define Intcast (int)(long)
+#define Double_Align
+#define X64_bit_pointers
--- /dev/null
+++ mlton-20210117+dfsg/runtime/gdtoa/gd_qnan.h
@@ -0,0 +1,3 @@
+#define f_QNAN 0x7fc00000
+#define d_QNAN0 0x7ff80000
+#define d_QNAN1 0x0
--- mlton-20210117+dfsg.orig/runtime/platform/linux.c
+++ mlton-20210117+dfsg/runtime/platform/linux.c
@@ -28,6 +28,9 @@ static void catcher (__attribute__ ((unu
 #elif (defined(__ia64__))
         ucontext_t* ucp = (ucontext_t*)context;
         GC_handleSigProf ((code_pointer) ucp->_u._mc.sc_ip);
+#elif (defined(__loongarch64))
+        ucontext_t* ucp = (ucontext_t*)context;
+        GC_handleSigProf ((code_pointer) ucp->uc_mcontext.__pc);
 #elif (defined (__ppc__)) || (defined (__powerpc__))
         ucontext_t* ucp = (ucontext_t*)context;
         GC_handleSigProf ((code_pointer) ucp->uc_mcontext.regs->nip);
--- /dev/null
+++ mlton-20210117+dfsg/runtime/platform/loongarch64.h
@@ -0,0 +1 @@
+#define MLton_Platform_Arch_host "loongarch64"
--- a/debian/control    2022-01-04 23:38:53.000000000 +0000
+++ b/debian/control    2024-01-16 11:08:34.811707062 +0000
@@ -64,7 +64,7 @@
  This package includes non-man-page documentation.
 
 Package: mlton-compiler
-Architecture: alpha amd64 arm64 armel armhf hppa i386 kfreebsd-amd64 
kfreebsd-i386 mips mips64el mipsel powerpc ppc64el riscv64 s390x sparc
+Architecture: alpha amd64 arm64 armel armhf hppa i386 kfreebsd-amd64 
kfreebsd-i386 loong64 mips mips64el mipsel powerpc ppc64el riscv64 s390x sparc
 Multi-Arch: foreign
 Depends:
  gcc,
@@ -80,7 +80,7 @@
  This package includes the compiler itself.
 
 Package: mlton-tools
-Architecture: alpha amd64 arm64 armel armhf hppa i386 kfreebsd-amd64 
kfreebsd-i386 mips mips64el mipsel powerpc ppc64el riscv64 s390x sparc
+Architecture: alpha amd64 arm64 armel armhf hppa i386 kfreebsd-amd64 
kfreebsd-i386 loong64 mips mips64el mipsel powerpc ppc64el riscv64 s390x sparc
 Multi-Arch: foreign
 Depends:
  ${misc:Depends},
@@ -91,9 +91,9 @@
  This package includes tools which autogenerate SML.
 
 Package: mlton-runtime-native
-Architecture: alpha amd64 arm64 armel armhf hppa i386 kfreebsd-amd64 
kfreebsd-i386 mips mips64el mipsel powerpc ppc64el riscv64 s390x sparc
+Architecture: alpha amd64 arm64 armel armhf hppa i386 kfreebsd-amd64 
kfreebsd-i386 loong64 mips mips64el mipsel powerpc ppc64el riscv64 s390x sparc
 Depends:
- mlton-runtime-alpha-linux-gnu (= ${binary:Version}) [alpha] | 
mlton-runtime-x86-64-linux-gnu (= ${binary:Version}) [amd64] | 
mlton-runtime-aarch64-linux-gnu (= ${binary:Version}) [arm64] | 
mlton-runtime-arm-linux-gnueabi (= ${binary:Version}) [armel] | 
mlton-runtime-arm-linux-gnueabihf (= ${binary:Version}) [armhf] | 
mlton-runtime-hppa-linux-gnu (= ${binary:Version}) [hppa] | 
mlton-runtime-i486-linux-gnu (= ${binary:Version}) [i386] | 
mlton-runtime-i486-kfreebsd-gnu (= ${binary:Version}) [kfreebsd-i386] | 
mlton-runtime-x86-64-kfreebsd-gnu (= ${binary:Version}) [kfreebsd-amd64] | 
mlton-runtime-mips64el-linux-gnuabi64 (= ${binary:Version}) [mips64el] | 
mlton-runtime-mips-linux-gnu (= ${binary:Version}) [mips] | 
mlton-runtime-mipsel-linux-gnu (= ${binary:Version}) [mipsel] | 
mlton-runtime-powerpc-linux-gnu (= ${binary:Version}) [powerpc] | 
mlton-runtime-powerpc64le-linux-gnu (= ${binary:Version}) [ppc64el] | 
mlton-runtime-s390x-linux-gnu (= ${binary:Version}) [s390x] | 
mlton-runtime-sparc-linux-gnu (= ${binary:Version}) [sparc],
+ mlton-runtime-alpha-linux-gnu (= ${binary:Version}) [alpha] | 
mlton-runtime-x86-64-linux-gnu (= ${binary:Version}) [amd64] | 
mlton-runtime-aarch64-linux-gnu (= ${binary:Version}) [arm64] | 
mlton-runtime-arm-linux-gnueabi (= ${binary:Version}) [armel] | 
mlton-runtime-arm-linux-gnueabihf (= ${binary:Version}) [armhf] | 
mlton-runtime-hppa-linux-gnu (= ${binary:Version}) [hppa] | 
mlton-runtime-i486-linux-gnu (= ${binary:Version}) [i386] | 
mlton-runtime-i486-kfreebsd-gnu (= ${binary:Version}) [kfreebsd-i386] | 
mlton-runtime-x86-64-kfreebsd-gnu (= ${binary:Version}) [kfreebsd-amd64] | 
mlton-runtime-loong64-linux-gnu (= ${binary:Version}) [loong64] | 
mlton-runtime-mips64el-linux-gnuabi64 (= ${binary:Version}) [mips64el] | 
mlton-runtime-mips-linux-gnu (= ${binary:Version}) [mips] | 
mlton-runtime-mipsel-linux-gnu (= ${binary:Version}) [mipsel] | 
mlton-runtime-powerpc-linux-gnu (= ${binary:Version}) [powerpc] | 
mlton-runtime-powerpc64le-linux-gnu (= ${binary:Version}) [ppc64el] | 
mlton-runtime-s390x-linux-gnu (= ${binary:Version}) [s390x] | 
mlton-runtime-sparc-linux-gnu (= ${binary:Version}) [sparc],
  ${misc:Depends},
 Description: ${source:Synopsis} - native runtime libraries
  ${source:Extended-Description}
@@ -217,6 +217,20 @@
  .
  This package provides ${Arch} target libraries.
 
+Package: mlton-runtime-loong64-linux-gnu
+Architecture: loong64
+Multi-Arch: foreign
+Depends:
+ mlton-basis (= ${binary:Version}),
+ ${misc:Depends},
+Provides:
+ mlton-runtime,
+Description: ${source:Synopsis} - ${Arch} runtime libraries
+ ${source:Extended-Description}
+ .
+ This package provides ${Arch} target libraries.
+
+
 Package: mlton-runtime-mips64el-linux-gnuabi64
 Architecture: mips64el
 Multi-Arch: foreign

Reply via email to