summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/systems/default.nix1
-rw-r--r--lib/systems/doubles.nix3
-rw-r--r--lib/systems/examples.nix4
-rw-r--r--lib/systems/inspect.nix1
-rw-r--r--lib/systems/parse.nix2
-rw-r--r--lib/tests/systems.nix2
-rw-r--r--nixos/modules/system/boot/binfmt.nix4
-rw-r--r--pkgs/build-support/bintools-wrapper/default.nix1
-rw-r--r--pkgs/development/libraries/libseccomp/default.nix1
-rw-r--r--pkgs/development/tools/misc/binutils/default.nix2
-rw-r--r--pkgs/os-specific/linux/fuse/common.nix2
-rw-r--r--pkgs/tools/text/gnugrep/default.nix7
-rw-r--r--pkgs/tools/text/gnugrep/sigsegv-loongarch.patch31
-rw-r--r--pkgs/top-level/all-packages.nix2
14 files changed, 56 insertions, 7 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix
index b2cb8848f08..85e24e08d36 100644
--- a/lib/systems/default.nix
+++ b/lib/systems/default.nix
@@ -136,6 +136,7 @@ rec {
         else if final.isPower then "powerpc"
         else if final.isRiscV then "riscv"
         else if final.isS390 then "s390"
+        else if final.isLoongArch64 then "loongarch"
         else final.parsed.cpu.name;
 
       qemuArch =
diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix
index 6b19309d11f..6d2f015674e 100644
--- a/lib/systems/doubles.nix
+++ b/lib/systems/doubles.nix
@@ -26,7 +26,7 @@ let
 
     # Linux
     "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux"
-    "armv7l-linux" "i686-linux" "m68k-linux" "microblaze-linux"
+    "armv7l-linux" "i686-linux" "loongarch64-linux" "m68k-linux" "microblaze-linux"
     "microblazeel-linux" "mipsel-linux" "mips64el-linux" "powerpc64-linux"
     "powerpc64le-linux" "riscv32-linux" "riscv64-linux" "s390-linux"
     "s390x-linux" "x86_64-linux"
@@ -86,6 +86,7 @@ in {
   m68k          = filterDoubles predicates.isM68k;
   s390          = filterDoubles predicates.isS390;
   s390x         = filterDoubles predicates.isS390x;
+  loongarch64   = filterDoubles predicates.isLoongArch64;
   js            = filterDoubles predicates.isJavaScript;
 
   bigEndian     = filterDoubles predicates.isBigEndian;
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index 9ea2e3b56e9..3ae5d6ffd47 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -90,6 +90,10 @@ rec {
     config = "mipsel-unknown-linux-gnu";
   } // platforms.fuloong2f_n32;
 
+  loongarch64-linux = {
+    config = "loongarch64-unknown-linux-gnu";
+  };
+
   # can execute on 32bit chip
   mips-linux-gnu                = { config = "mips-unknown-linux-gnu";                } // platforms.gcc_mips32r2_o32;
   mipsel-linux-gnu              = { config = "mipsel-unknown-linux-gnu";              } // platforms.gcc_mips32r2_o32;
diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix
index 1700049ca4b..89e9f4231d9 100644
--- a/lib/systems/inspect.nix
+++ b/lib/systems/inspect.nix
@@ -57,6 +57,7 @@ rec {
     isM68k         = { cpu = { family = "m68k"; }; };
     isS390         = { cpu = { family = "s390"; }; };
     isS390x        = { cpu = { family = "s390"; bits = 64; }; };
+    isLoongArch64  = { cpu = { family = "loongarch"; bits = 64; }; };
     isJavaScript   = { cpu = cpuTypes.javascript; };
 
     is32bit        = { cpu = { bits = 32; }; };
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index bd3366e140b..ea8e1ff8fcf 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -131,6 +131,8 @@ rec {
 
     or1k     = { bits = 32; significantByte = bigEndian; family = "or1k"; };
 
+    loongarch64 = { bits = 64; significantByte = littleEndian; family = "loongarch"; };
+
     javascript = { bits = 32; significantByte = littleEndian; family = "javascript"; };
   };
 
diff --git a/lib/tests/systems.nix b/lib/tests/systems.nix
index 88e2e4206d5..792aa94f335 100644
--- a/lib/tests/systems.nix
+++ b/lib/tests/systems.nix
@@ -34,7 +34,7 @@ with lib.systems.doubles; lib.runTests {
   testredox = mseteq redox [ "x86_64-redox" ];
   testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */);
   testillumos = mseteq illumos [ "x86_64-solaris" ];
-  testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mips64el-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64-linux" "powerpc64le-linux" "m68k-linux" "s390-linux" "s390x-linux" "microblaze-linux" "microblazeel-linux" ];
+  testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mips64el-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64-linux" "powerpc64le-linux" "m68k-linux" "s390-linux" "s390x-linux" "microblaze-linux" "microblazeel-linux" "loongarch64-linux" ];
   testnetbsd = mseteq netbsd [ "aarch64-netbsd" "armv6l-netbsd" "armv7a-netbsd" "armv7l-netbsd" "i686-netbsd" "m68k-netbsd" "mipsel-netbsd" "powerpc-netbsd" "riscv32-netbsd" "riscv64-netbsd" "x86_64-netbsd" ];
   testopenbsd = mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ];
   testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "i686-windows" "x86_64-windows" ];
diff --git a/nixos/modules/system/boot/binfmt.nix b/nixos/modules/system/boot/binfmt.nix
index cceb02c1a73..b003d983d2b 100644
--- a/nixos/modules/system/boot/binfmt.nix
+++ b/nixos/modules/system/boot/binfmt.nix
@@ -125,6 +125,10 @@ let
       magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00'';
       mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
     };
+    loongarch64-linux = {
+      magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01'';
+      mask = ''\xff\xff\xff\xff\xff\xff\xff\xfc\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'';
+    };
     wasm32-wasi = {
       magicOrExtension = ''\x00asm'';
       mask = ''\xff\xff\xff\xff'';
diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix
index 0a4ea1ebf26..acc433496b0 100644
--- a/pkgs/build-support/bintools-wrapper/default.nix
+++ b/pkgs/build-support/bintools-wrapper/default.nix
@@ -88,6 +88,7 @@ let
     else if targetPlatform.isMips                     then "${sharedLibraryLoader}/lib/ld.so.1"
     # `ld-linux-riscv{32,64}-<abi>.so.1`
     else if targetPlatform.isRiscV                    then "${sharedLibraryLoader}/lib/ld-linux-riscv*.so.1"
+    else if targetPlatform.isLoongArch64              then "${sharedLibraryLoader}/lib/ld-linux-loongarch*.so.1"
     else if targetPlatform.isDarwin                   then "/usr/lib/dyld"
     else if targetPlatform.isFreeBSD                  then "/libexec/ld-elf.so.1"
     else if lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1"
diff --git a/pkgs/development/libraries/libseccomp/default.nix b/pkgs/development/libraries/libseccomp/default.nix
index e68603c490c..aadaad561db 100644
--- a/pkgs/development/libraries/libseccomp/default.nix
+++ b/pkgs/development/libraries/libseccomp/default.nix
@@ -42,6 +42,7 @@ stdenv.mkDerivation rec {
     platforms = platforms.linux;
     badPlatforms = [
       "alpha-linux"
+      "loongarch64-linux"
       "riscv32-linux"
       "sparc-linux"
       "sparc64-linux"
diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix
index 10a0281b075..0db491f225c 100644
--- a/pkgs/development/tools/misc/binutils/default.nix
+++ b/pkgs/development/tools/misc/binutils/default.nix
@@ -1,5 +1,5 @@
 let
-  withGold = platform: platform.parsed.kernel.execFormat.name == "elf" && !platform.isRiscV;
+  withGold = platform: platform.parsed.kernel.execFormat.name == "elf" && !platform.isRiscV && !platform.isLoongArch64;
 in
 
 { stdenv
diff --git a/pkgs/os-specific/linux/fuse/common.nix b/pkgs/os-specific/linux/fuse/common.nix
index 1ff496abd0c..bbd871a1b9a 100644
--- a/pkgs/os-specific/linux/fuse/common.nix
+++ b/pkgs/os-specific/linux/fuse/common.nix
@@ -24,7 +24,7 @@ in stdenv.mkDerivation rec {
 
   patches =
     lib.optional
-      (!isFuse3 && stdenv.isAarch64)
+      (!isFuse3 && (stdenv.isAarch64 || stdenv.hostPlatform.isLoongArch64))
       (fetchpatch {
         url = "https://github.com/libfuse/libfuse/commit/914871b20a901e3e1e981c92bc42b1c93b7ab81b.patch";
         sha256 = "1w4j6f1awjrycycpvmlv0x5v9gprllh4dnbjxl4dyl2jgbkaw6pa";
diff --git a/pkgs/tools/text/gnugrep/default.nix b/pkgs/tools/text/gnugrep/default.nix
index efb3be1c8fb..fc285bb4c4d 100644
--- a/pkgs/tools/text/gnugrep/default.nix
+++ b/pkgs/tools/text/gnugrep/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchurl, pcre, libiconv, perl }:
+{ lib, stdenv, fetchurl, pcre, libiconv, perl, autoreconfHook }:
 
 # Note: this package is used for bootstrapping fetchurl, and thus
 # cannot use fetchpatch! All mutable patches (generated by GitHub or
@@ -16,8 +16,11 @@ stdenv.mkDerivation {
     sha256 = "0g42svbc1nq5bamxfj6x7320wli4dlj86padk0hwgbk04hqxl42w";
   };
 
+  # https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=b50c6442e43d79471a31a2a202d3e50c0557446f
+  patches = lib.optional stdenv.hostPlatform.isLoongArch64 ./sigsegv-loongarch.patch;
+
   # Perl is needed for testing
-  nativeBuildInputs = [ perl ];
+  nativeBuildInputs = [ perl ] ++ lib.optional stdenv.hostPlatform.isLoongArch64 autoreconfHook;
   outputs = [ "out" "info" ]; # the man pages are rather small
 
   buildInputs = [ pcre libiconv ];
diff --git a/pkgs/tools/text/gnugrep/sigsegv-loongarch.patch b/pkgs/tools/text/gnugrep/sigsegv-loongarch.patch
new file mode 100644
index 00000000000..19bb2c1d70c
--- /dev/null
+++ b/pkgs/tools/text/gnugrep/sigsegv-loongarch.patch
@@ -0,0 +1,31 @@
+From b50c6442e43d79471a31a2a202d3e50c0557446f Mon Sep 17 00:00:00 2001
+From: Sun Haiyong <youbest@sina.com>
+Date: Sat, 4 Sep 2021 15:06:43 +0200
+Subject: sigsegv: Improve cross-compilation support for LoongArch CPU.
+
+* m4/stack-direction.m4 (SV_STACK_DIRECTION): Assume the stack grows
+down on LoongArch.
+---
+ m4/stack-direction.m4 | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/m4/stack-direction.m4 b/m4/stack-direction.m4
+index 9328725..e682be9 100644
+--- a/m4/stack-direction.m4
++++ b/m4/stack-direction.m4
+@@ -1,4 +1,4 @@
+-# stack-direction.m4 serial 7
++# stack-direction.m4 serial 8
+ dnl Copyright (C) 2002-2021 Free Software Foundation, Inc.
+ dnl This file is free software, distributed under the terms of the GNU
+ dnl General Public License.  As a special exception to the GNU General
+@@ -32,6 +32,7 @@ AC_DEFUN([SV_STACK_DIRECTION],
+       i?86 | x86_64 | \
+       i860 | \
+       ia64 | \
++      loongarch* | \
+       m32r | \
+       m68* | \
+       m88k | \
+-- 
+cgit v1.1
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index bccd7b58a6c..e10d94db89b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -26321,7 +26321,7 @@ with pkgs;
   busybox = callPackage ../os-specific/linux/busybox { };
   busybox-sandbox-shell = callPackage ../os-specific/linux/busybox/sandbox-shell.nix {
     # musl roadmap has RISC-V support projected for 1.1.20
-    busybox = if !stdenv.hostPlatform.isRiscV && stdenv.hostPlatform.libc != "bionic"
+    busybox = if !stdenv.hostPlatform.isRiscV && !stdenv.hostPlatform.isLoongArch64 && stdenv.hostPlatform.libc != "bionic"
               then pkgsStatic.busybox
               else busybox;
   };