Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.platforms.loongarch64: init #227560

Merged
merged 8 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion lib/systems/doubles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions lib/systems/examples.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ rec {
config = "mipsel-unknown-linux-gnu";
} // platforms.fuloong2f_n32;

loongarch64-linux = {
jackyliu16 marked this conversation as resolved.
Show resolved Hide resolved
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;
Expand Down
1 change: 1 addition & 0 deletions lib/systems/inspect.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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; }; };
Expand Down
2 changes: 2 additions & 0 deletions lib/systems/parse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"; };
};

Expand Down
2 changes: 1 addition & 1 deletion lib/tests/systems.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/libraries/libseccomp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ stdenv.mkDerivation rec {
platforms = platforms.linux;
badPlatforms = [
"alpha-linux"
"loongarch64-linux"
"riscv32-linux"
"sparc-linux"
"sparc64-linux"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/tools/misc/binutils/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkgs/os-specific/linux/fuse/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
7 changes: 5 additions & 2 deletions pkgs/tools/text/gnugrep/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 ];
Expand Down
31 changes: 31 additions & 0 deletions pkgs/tools/text/gnugrep/sigsegv-loongarch.patch
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26214,7 +26214,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;
};
Expand Down