Skip to content

Commit

Permalink
feat(toolchain): add recipe to build riscv64 toolchain
Browse files Browse the repository at this point in the history
Signed-off-by: Diogo Costa <diogoandreveigacosta@gmail.com>
  • Loading branch information
Diogo21Costa authored and miguelafsilva5 committed Feb 16, 2024
1 parent 4d83e97 commit 1c2fe06
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions pkgs/toolchains/riscv64-unknown-elf-10.2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) Bao Project and Contributors. All rights reserved.

{ lib
, stdenv
, fetchurl
, ncurses5
, python38
, zlib
}:

stdenv.mkDerivation rec {
pname = "riscv64-unknown-elf";
version = "1.0.0";
arch = "x86_64";

src = fetchurl {
url = "https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-${arch}-linux-ubuntu14.tar.gz";
sha256 = "sha256-vYVyQrfGSxqYxWs1vIAYZKxCBdA/ODxwEKkMXQu5VJo=";
};

nativeBuildInputs = [ zlib ]; #build time dependencies


dontConfigure = true;
dontBuild = true;
dontPatchELF = true;
dontStrip = true;

installPhase = ''
mkdir -p $out
cp -r * $out
'';

# Package -> put the binaries with nix store paths
preFixup = ''
find $out -type f | while read f; do
patchelf "$f" > /dev/null 2>&1 || continue
patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python38 zlib]} "$f" || true
done
'';

}


0 comments on commit 1c2fe06

Please sign in to comment.