!xmLtiCaAJxfhURjrXl:matrix.org

NixOS RISC-V

233 Members
NixOS on RISC-V https://wiki.nixos.org/wiki/RISC-V https://pad.lassul.us/NixOS-riscv64-linux https://github.com/orgs/NixOS/teams/risc-v69 Servers

Load older messages


SenderMessageTime
28 Mar 2024
@fgaz:matrix.orgfgaz
In reply to @alex:tunstall.xyz

Flakes support binfmt emulation.

The issue is that Nixpkgs doesn't know how to bootstrap GHC on RISC-V, because it doesn't know where to get a binary for GHC.

I should ask the ghcup maintainer to produce one so we finally have a trusted haskell risc-v bootstrap path...
11:00:09
@skeuchel:matrix.orgSteven Keuchel
In reply to @alex:tunstall.xyz

When building GHC from source, here's what Nixpkgs does:

  1. It fetches an appropriate GHC bindist from haskell.org (none exists for RISC-V).
  2. It uses the bindist to compile GHC.

(It is also possible to use the bindist directly, but AFAIK users rarely do that.)

I tried using a self-compiled ghc963 bindist for rv64 directly to avoid recompiling ghc every now and then. Unfortunately a couple of packages fail to compile this way. also happens on amd64, try e.g. nixpkgs#haskell.packages.ghc963Binary.generics-sop.
11:45:24
@shalokshalom:kde.org@shalokshalom:kde.org joined the room.15:11:46
@alex:tunstall.xyzAlex
In reply to @skeuchel:matrix.org
I tried using a self-compiled ghc963 bindist for rv64 directly to avoid recompiling ghc every now and then. Unfortunately a couple of packages fail to compile this way. also happens on amd64, try e.g. nixpkgs#haskell.packages.ghc963Binary.generics-sop.

The bindists only need to work well enough to compile GHC, so I assume that in Nixpkgs they might not be tested well enough for everything to work like it does with the Nixpkgs-native builds.

This is still quite puzzling though, as those bindists generally work well in FHS-compatible distributions.

15:22:08
@alex:tunstall.xyzAlex
In reply to @skeuchel:matrix.org
I tried using a self-compiled ghc963 bindist for rv64 directly to avoid recompiling ghc every now and then. Unfortunately a couple of packages fail to compile this way. also happens on amd64, try e.g. nixpkgs#haskell.packages.ghc963Binary.generics-sop.

I tried building generics-sop with various compilers.

x86_64, ghc963Binary = fails
x86_64, ghc963 = ok
x86_64, ghc928 = ok
RV64GC, ghc928 (cross-compiled from x86_64) = fails on th-abstraction (relocation R_RISCV_HI20 against a local symbol' can not be used when making a shared object; recompile with -fPIC) RV64GC, ghc928` (native, booted with cross-compiled 8.10.7) = ok

All compilers except ghc963Binary were built using Nixpkgs (cross-compiled versions required a custom branch).

(Excuse the old RV64GC compiler versions. My dev board hasn't been updated in months and I don't have the patience to wait 15+ hours for a new GHC version to compile.)

16:36:12
@alex:tunstall.xyzAlex *

I tried building generics-sop with various compilers.

x86_64, ghc963Binary = fails
x86_64, ghc963 = ok
x86_64, ghc928 = ok
RV64GC, ghc928 (cross-compiled from x86_64) = fails on th-abstraction (relocation R_RISCV_HI20 against 'a local symbol' can not be used when making a shared object; recompile with -fPIC)
RV64GC, ghc928 (native, booted with cross-compiled 8.10.7) = ok

All compilers except ghc963Binary were built using Nixpkgs (cross-compiled versions required a custom branch).

(Excuse the old RV64GC compiler versions. My dev board hasn't been updated in months and I don't have the patience to wait 15+ hours for a new GHC version to compile.)

16:36:37
@hive:the-apothecary.clubDagn Hive i looked through the chat and couldn't find any good binary caches, maybe i missed something, but https://github.com/misuzu/nixos-vf2/blob/master/flake.nix#L3 seems to just give a 404 ? at the very least, when trying it i'm still getting the error with ghc so i'm not sure what's going on here 23:41:51
@hive:the-apothecary.clubDagn Hive
  nixConfig = {
    extra-substituters = [ "https://cache.ztier.in" ];
    extra-trusted-public-keys = [ "cache.ztier.link-1:3P5j2ZB9dNgFFFVkCQWT3mh0E+S3rIWtZvoql64UaXM=" ];
  };

i think i have this setup correctly ?

23:48:18
@alex:tunstall.xyzAlex
In reply to @hive:the-apothecary.club
i looked through the chat and couldn't find any good binary caches, maybe i missed something, but https://github.com/misuzu/nixos-vf2/blob/master/flake.nix#L3 seems to just give a 404 ? at the very least, when trying it i'm still getting the error with ghc so i'm not sure what's going on here
Error with GHC?
AFAIK GHC is not in any binary caches (at least, I haven't uploaded my GHC builds to one).
23:49:14
@hive:the-apothecary.clubDagn Hiveah, ok23:49:26
29 Mar 2024
@hive:the-apothecary.clubDagn Hive

so i'm trying to build with your branch, but i'm getting the error:

error: cannot bootstrap GHC on this platform ('riscv64-linux' with libc 'defaultLibc')
11:54:02
@hive:the-apothecary.clubDagn Hivei'm not sure what i'm doing wrong :(12:00:00
@hive:the-apothecary.clubDagn Hive nix build "git+https://git.solarpunk.moe/geekygays/nixconf?ref=magrathea#nixosConfigurations.cmb2.config.system.build.sdImage"; 12:13:16
@hive:the-apothecary.clubDagn Hiveif you want to try12:13:19
@skeuchel:matrix.orgSteven KeuchelThere are no official ghc bindists available for riscv64. So you cannot built it natively with vanilla nixpkgs.12:27:53
@hive:the-apothecary.clubDagn Hiveit's not vanilla12:29:28
@hive:the-apothecary.clubDagn Hiveit has alex's patches12:29:50
@skeuchel:matrix.orgSteven Keuchelyeah but that branch does not add any bindists, it's about getting ghc itself to cross compile when build != host = target12:30:55
@hive:the-apothecary.clubDagn Hivei was trying to cross compile though12:32:38
@skeuchel:matrix.orgSteven KeuchelThe error message that you are seeing comes from trying to build ghc from a binary bindist.12:32:39
@skeuchel:matrix.orgSteven KeuchelBut there is not bindist for riscv64, e.g. in here for ghc963Binary https://github.com/NixOS/nixpkgs/blob/6a2bf3ad24583dd4486bf669b6790d61ac239879/pkgs/development/compilers/ghc/9.6.3-binary.nix#L44-L11112:33:00
@skeuchel:matrix.orgSteven Keuchelyou should not be seeing that error message for a cross-compile though12:33:25
@hive:the-apothecary.clubDagn Hivehmm ok12:33:47
@skeuchel:matrix.orgSteven Keuchel

tau: Here is a minimal flake that at least evaluates

{
  inputs = {
    nixpkgs.url = "github:AlexandreTunstall/nixpkgs/ghc-cross";
  };

  outputs = { nixpkgs, ... }:
    {
      nixosConfigurations.riscv64 = nixpkgs.lib.nixosSystem {
        modules = [({lib, pkgs, ...}: {
          nixpkgs.crossSystem.system = "riscv64-linux";
          nixpkgs.localSystem.system = "x86_64-linux";
          environment.systemPackages = [
             pkgs.haskell.compiler.native-bignum.ghc948
          ];
          # Dummy values
          fileSystems."/".device  = lib.mkDefault "/dev/sda1";
          boot.loader.grub.device = lib.mkDefault "/dev/sda";
        })];
      };
    };
}

Maybe you can use that to figure out what is going wrong.

12:58:51
@skeuchel:matrix.orgSteven KeuchelThis won't build a complete config though since https://github.com/NixOS/nixpkgs/pull/298001 is not in Alex's branch.12:59:22
@hive:the-apothecary.clubDagn Hiveok, thanks12:59:57
@misuzu:matrix.orgmisuzu
In reply to @hive:the-apothecary.club
i looked through the chat and couldn't find any good binary caches, maybe i missed something, but https://github.com/misuzu/nixos-vf2/blob/master/flake.nix#L3 seems to just give a 404 ? at the very least, when trying it i'm still getting the error with ghc so i'm not sure what's going on here
That cache only has binaries for that flake
18:08:51
@alex:tunstall.xyzAlex

tau you're in luck because I was planning on writing some instructions in the shared notes (see room description) this evening.

I'll let you know when the instructions are ready.

18:10:19
@hive:the-apothecary.clubDagn Hiveoh awesome18:20:00
@alex:tunstall.xyzAlex

tau Steven Keuchel fgaz the shared notes now have instructions for how to get a working GHC.

(Disclaimer: It's been a while since I first booted GHC and I haven't yet had time to properly test the instructions.)

19:39:30

Show newer messages


Back to Room ListRoom Version: 10