From 3b069a2ef810abb92db95f8ee1162b8fa6d7a9bd Mon Sep 17 00:00:00 2001 From: oxalica Date: Sun, 28 Feb 2021 00:33:10 +0800 Subject: [PATCH 1/3] bintools-wrapper: add dynamicLinker for riscv --- pkgs/build-support/bintools-wrapper/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index 53f367b9b84d..c2d67169c9ca 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -81,6 +81,8 @@ let else if targetPlatform.system == "aarch64-linux" then "${sharedLibraryLoader}/lib/ld-linux-aarch64.so.1" else if targetPlatform.system == "powerpc-linux" then "${sharedLibraryLoader}/lib/ld.so.1" else if targetPlatform.isMips then "${sharedLibraryLoader}/lib/ld.so.1" + # `ld-linux-riscv{32,64}-.so.1` + else if targetPlatform.isRiscV then "${sharedLibraryLoader}/lib/ld-linux-riscv*.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" From fc3ea54fb3d97865dc2bb173c3a5ea54eaf1ad13 Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 5 Mar 2021 03:46:32 +0800 Subject: [PATCH 2/3] make-bootstrap-tools: produce libatomic on riscv platform --- pkgs/stdenv/linux/make-bootstrap-tools.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index 0eee6e692fd3..84b63e7b8fd0 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -160,6 +160,11 @@ in with pkgs; rec { # pkgs/stdenv/linux/default.nix for the details. cp -d ${isl_0_20.out}/lib/libisl*.so* $out/lib + '' + lib.optionalString (stdenv.hostPlatform.isRiscV) '' + # libatomic is required on RiscV platform for C/C++ atomics and pthread + # even though they may be translated into native instructions. + cp -d ${bootGCC.out}/lib/libatomic.a* $out/lib + '' + '' cp -d ${bzip2.out}/lib/libbz2.so* $out/lib From 8cf96b94264402e958908862991c281999483d3a Mon Sep 17 00:00:00 2001 From: oxalica Date: Wed, 31 Mar 2021 23:56:38 +0800 Subject: [PATCH 3/3] stdenv: patch autoconf script for riscv in stage 2 --- pkgs/stdenv/linux/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index d2c74f7722d3..b2b0dad82d82 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -279,6 +279,10 @@ in }; }; }; + + # `libtool` comes with obsolete config.sub/config.guess that don't recognize Risc-V. + extraNativeBuildInputs = + lib.optional (localSystem.isRiscV) prevStage.updateAutotoolsGnuConfigScriptsHook; })