| 28 Mar 2024 |
👉@crystallinefire:chat.solarpunk.moe | * ok so as far as i understand it, ghc doesn't support cross-compilation, ( pending PR merge ), so you need to do an emulated build, but also as far as i can tell, flakes doesn't support doing an emulated build ? | 00:36:20 |
Alex | In reply to @hive:the-apothecary.club ok so as far as i understand it, ghc doesn't support cross-compilation, ( pending PR merge ), so you need to do an emulated build, but also as far as i can tell, flakes doesn't support doing an emulated build ? 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. | 00:36:58 |
Alex | Your options are either:
- Find a pre-compiled RISC-V binary for GHC somewhere (e.g. Debian might have one).
- Use the unmerged PR to cross-compile a suitable bootstrap binary for GHC.
| 00:38:13 |
👉@crystallinefire:chat.solarpunk.moe | so even with an emulated build, it still doesn't bootstrap successfully ? | 00:39:25 |
Alex | (As the creator of the PR, I'm sorry I haven't yet found the time to get the PR merged.) | 00:39:27 |
👉@crystallinefire:chat.solarpunk.moe | i understand | 00:39:40 |
Alex | In reply to @hive:the-apothecary.club so even with an emulated build, it still doesn't bootstrap successfully ? Nixpkgs doesn't even evaluate, because it doesn't know where to find the RISC-V bootstrap binary.
See for yourself:
nix-shell -p '(import <nixpkgs> { system = "riscv64-linux"; }).ghc'
| 00:41:36 |
👉@crystallinefire:chat.solarpunk.moe | ah ok | 00:41:47 |
Alex | When building GHC from source, here's what Nixpkgs does:
- It fetches an appropriate GHC bindist from haskell.org (none exists for RISC-V).
- It uses the bindist to compile GHC.
(It is also possible to use the bindist directly, but AFAIK users rarely do that.) | 00:43:52 |
Alex | If you need help getting GHC working on RISC-V or you want to improve on my GHC cross-compilation PR, feel free to ask. | 00:45:47 |
👉@crystallinefire:chat.solarpunk.moe | i would love to help your PR get merged | 00:51:31 |
| 👉@crystallinefire:chat.solarpunk.moe changed their display name from Dagn Hive to tau. | 01:51:39 |
fgaz | 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 |
Steven Keuchel | In reply to @alex:tunstall.xyz
When building GHC from source, here's what Nixpkgs does:
- It fetches an appropriate GHC bindist from haskell.org (none exists for RISC-V).
- 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 joined the room. | 15:11:46 |
Alex | 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 | 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 | * 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 |
👉@crystallinefire:chat.solarpunk.moe | 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 |
👉@crystallinefire:chat.solarpunk.moe | 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 | 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 |
👉@crystallinefire:chat.solarpunk.moe | ah, ok | 23:49:26 |
| 29 Mar 2024 |
👉@crystallinefire:chat.solarpunk.moe | 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 |
👉@crystallinefire:chat.solarpunk.moe | i'm not sure what i'm doing wrong :( | 12:00:00 |
👉@crystallinefire:chat.solarpunk.moe | nix build "git+https://git.solarpunk.moe/geekygays/nixconf?ref=magrathea#nixosConfigurations.cmb2.config.system.build.sdImage"; | 12:13:16 |
👉@crystallinefire:chat.solarpunk.moe | if you want to try | 12:13:19 |
Steven Keuchel | There are no official ghc bindists available for riscv64. So you cannot built it natively with vanilla nixpkgs. | 12:27:53 |