about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjackyliu16 <18922251299@163.com>2023-05-01 05:16:32 +0800
committerjackyliu16 <18922251299@163.com>2023-05-01 05:16:32 +0800
commitdf2c2e63f1a5e25ba3afda9387893dfb320eac18 (patch)
treea81429f22b537cc45009aa5bd70c1d258d32a4db
parent468356287fe4ce68f58fa5cf16e8ed6fc40a1a7f (diff)
cpython: add loongarch triplets
  using patch ref on: https://github.com/python/cpython/issues/90656
  to add loongarch triplets for using cpython in loongarch

  Note: This patch is being reviewed by cpython
-rw-r--r--pkgs/development/interpreters/python/cpython/default.nix3
-rw-r--r--pkgs/development/interpreters/python/cpython/loongarch-support.patch50
2 files changed, 53 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix
index 0afdba9983e02..3f48b2c6eb205 100644
--- a/pkgs/development/interpreters/python/cpython/default.nix
+++ b/pkgs/development/interpreters/python/cpython/default.nix
@@ -288,6 +288,9 @@ in with passthru; stdenv.mkDerivation {
     ./3.8/0001-On-all-posix-systems-not-just-Darwin-set-LDSHARED-if.patch
     # Use sysconfigdata to find headers. Fixes cross-compilation of extension modules.
     ./3.7/fix-finding-headers-when-cross-compiling.patch
+  ] ++ optionals stdenv.hostPlatform.isLoongArch64 [
+    # https://github.com/python/cpython/issues/90656
+    ./loongarch-support.patch
   ];
 
   postPatch = ''
diff --git a/pkgs/development/interpreters/python/cpython/loongarch-support.patch b/pkgs/development/interpreters/python/cpython/loongarch-support.patch
new file mode 100644
index 0000000000000..44348c5fe32a1
--- /dev/null
+++ b/pkgs/development/interpreters/python/cpython/loongarch-support.patch
@@ -0,0 +1,50 @@
+diff --git a/configure b/configure
+index 8133d47f61..334c98e208 100755
+--- a/configure
++++ b/configure
+@@ -6215,6 +6215,20 @@ cat > conftest.c <<EOF
+ #  else
+ #   error unknown platform triplet
+ #  endif
++# elif defined(__loongarch__)
++#  if defined(__loongarch_lp64)
++#   if defined(__loongarch_soft_float)
++        loongarch64-linux-gnusf
++#   elif defined(__loongarch_single_float)
++        loongarch64-linux-gnuf32
++#   elif defined(__loongarch_double_float)
++        loongarch64-linux-gnu
++#   else
++#     error unknown platform triplet
++#   endif 
++#  else
++#    error unknown platform triplet
++#  endif
+ # else
+ #   error unknown platform triplet
+ # endif
+diff --git a/configure.ac b/configure.ac
+index 3f20d8980d..acde94a181 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -959,6 +959,20 @@ cat > conftest.c <<EOF
+         hppa-linux-gnu
+ # elif defined(__ia64__)
+         ia64-linux-gnu
++# elif defined(__loongarch__)
++#  if defined(__loongarch_lp64)
++#   if defined(__loongarch_soft_float)
++        loongarch64-linux-gnusf
++#   elif defined(__loongarch_single_float)
++        loongarch64-linux-gnuf32
++#   elif defined(__loongarch_double_float)
++        loongarch64-linux-gnu
++#   else
++#    error unknown platform triplet
++#   endif
++#  else
++#   error unknown platform triplet
++#  endif
+ # elif defined(__m68k__) && !defined(__mcoldfire__)
+         m68k-linux-gnu
+ # elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL)