!xmLtiCaAJxfhURjrXl:matrix.org

NixOS RISC-V

223 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-v64 Servers

Load older messages


SenderMessageTime
10 Apr 2026
@cleverca22:matrix.orgcleverca22 arch/riscv/include/asm/alternative-macros.h
reading more, i can see it will generate the first opcode, nop, and force it to not be compressed (so both options are 32bits)
then it will use an assembly .if statement gated on the config flag, to maybe push the 2nd opcode into the .alternative section of the binary, along with some offsets to the nop
12:45:26
@cleverca22:matrix.orgcleverca22 oh, but i also see things now gated by CONFIG_RISCV_ALTERNATIVE, hmmmm? 12:49:04
@cleverca22:matrix.orgcleverca22 ah, when CONFIG_RISCV_ALTERNATIVE=n it just doesnt support the extensions at all, and always goes with the non-zbb case (in the strcmp example) 12:49:51
@cleverca22:matrix.orgcleverca22https://github.com/torvalds/linux/blob/master/arch/riscv/Kconfig#L542-L55512:51:54
@josw:matrix.org@josw:matrix.org left the room.16:46:54
13 Apr 2026
@slushee:crabsin.spacePol changed their display name from Slushee to Pol.14:16:53
15 Apr 2026
@98765abc:mozilla.org@98765abc:mozilla.org left the room.06:49:36
@blokyk:matrix.orgzoë (@blokyk) joined the room.09:38:46
@blokyk:matrix.orgzoë (@blokyk) i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.mkShell/stdenv with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain instead of an x86->rv32 one... where's the problem with my mental model, and how can i get a shell with the right environment? 09:46:07
@blokyk:matrix.orgzoë (@blokyk) i used this article and this one as sources, but I guess I might have missed or misunderstood something? 09:47:22
@blokyk:matrix.orgzoë (@blokyk) * i used this article and this one as sources, but I guess I might h](https://www.hobson.space/posts/nixcross/)ave missed or misunderstood something? 09:47:47
@blokyk:matrix.orgzoë (@blokyk) * i used this article and this one as sources, but I guess I might have missed or misunderstood something? 09:48:05
@blokyk:matrix.orgzoë (@blokyk) * i used this article and this one as sources, but I guess I must have missed or misunderstood something? 09:48:14
@blokyk:matrix.orgzoë (@blokyk) * i used this article and this one as sources, but I guess I must have missed or misunderstood something? 09:49:44
@blokyk:matrix.orgzoë (@blokyk) * i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.mkShell/stdenv with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain, and if i do nix-shell -E '(import <nixpkgs> {}).pkgsCross.riscv32.mkShell {} and try to compile a simple program, I get a cc1: execvp: no such file or directory error... where's the problem with my mental model, and how can i get a shell with the right environment? 09:54:19
@blokyk:matrix.orgzoë (@blokyk) * i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.mkShell/stdenv with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain, and if i do nix-shell -E '(import <nixpkgs> {}).pkgsCross.riscv32.mkShell {}' and try to compile a simple program, I get a cc1: execvp: no such file or directory error... where's the problem with my mental model, and how can i get a shell with the right environment? 09:59:49
@blokyk:matrix.orgzoë (@blokyk) * i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.mkShell/stdenv with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain (which cc points to a nix-managed gcc, but for x86)... where's the problem with my mental model, and how can i get a shell with the right environment? 10:01:19
@blokyk:matrix.orgzoë (@blokyk) * i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.stdenv/mkShell with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain (which cc points to a nix-managed gcc, but for x86)... where's the problem with my mental model, and how can i get a shell/derivation environment with the right toolchain? 10:12:44
@blokyk:matrix.orgzoë (@blokyk) * i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.stdenv/mkShell with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain (which cc points to a nix-managed gcc, but for x86)... where's the problem with my mental model, and how can i get a shell/derivation environment with the right toolchain?
(ideally i'd also like to get an llvm-based toolchain, but that seems like it's basically completely unsupported)
10:14:20
@blokyk:matrix.orgzoë (@blokyk) * i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.stdenv/mkShell with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain (which cc points to a nix-managed gcc, but for x86)... where's the problem with my mental model, and how can i get a shell/derivation environment with the right toolchain?
(ideally i'd also like to get an llvm-based toolchain, but that seems like it's basically completely unsupported ;-;)
10:14:27
@blokyk:matrix.orgzoë (@blokyk) * i'm not sure if this is the right place to ask, especially because this is a very noob question, but i'm trying to get a shell for doing cross-compilation from x86 to riscv. I thought it'd be a simple matter of getting a pkgsCross.riscv32.stdenv/mkShell with the right nativeBuildInputs etc, but if i do nix-shell -p pkgsCross.riscv32.stdenv, I just get an x86->x86 toolchain (which cc points to a nix-managed gcc, but for x86)... where's the problem with my mental model, and how can i get a shell/derivation environment with the right toolchain?
(ideally i'd also like to get an llvm-based toolchain, but that seems like it's basically completely unsupported ;-; i mean, compiler-rt-libc-riscv32-unknown-linux-gnu is broken so...)
10:15:21
@blokyk:matrix.orgzoë (@blokyk) hmm, i might just be dumb... i though that .stdenv was basically just like an empty mkDerivation { } but I guess not
also i got confused by mkShell having which cc point to my system's cc, but actually $CC is correct it seems. it's just going to be annoying since some of the stuff i want to use has cc in its makefiles instead of $CC
10:21:25
@blokyk:matrix.orgzoë (@blokyk)Redacted or Malformed Event10:50:43
@blokyk:matrix.orgzoë (@blokyk) *

ok so i wasn't going crazy: trying it out with just nix-shell and hard-coded pkgsCross.riscv32. in front of everything works, but for some reason callPackage/splicing doesn't work :(

# shell.nix
{
  llvmPackages_latest,
  mkShell
}:
let mkLLVMShell = mkShell.override { inherit (llvmPackages_latest) stdenv; }
in
mkLLVMShell { }
10:50:51
@blokyk:matrix.orgzoë (@blokyk) *

ok so i wasn't going crazy: trying it out with just nix-shell and hard-coded pkgsCross.riscv32. in front of everything works, but for some reason callPackage/splicing doesn't work :(

# shell.nix
{
  llvmPackages_latest,
  mkShell
}:
let mkLLVMShell = mkShell.override { inherit (llvmPackages_latest) stdenv; }
in
mkLLVMShell { }
$ nix-shell -E '(import <nixpkgs> {}).pkgsCross.riscv64.callPackage ./shell.nix {}'
[nix-shell:~] $ $CC --version
clang version 22.1.2
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/nqrpsik93243zfbysab689b4598x0srw-clang-22.1.2/bin

:(

10:53:55
@blokyk:matrix.orgzoë (@blokyk) *

ok so i wasn't going crazy: trying it out with just nix-shell and hard-coded pkgsCross.riscv32. in front of everything works, but for some reason callPackage/splicing doesn't work :(

# shell.nix
{
  llvmPackages_latest,
  mkShell
}:
let mkLLVMShell = mkShell.override { inherit (llvmPackages_latest) stdenv; }
in
mkLLVMShell { }
$ nix-shell -E '(import <nixpkgs> {}).pkgsCross.riscv64.callPackage ./shell.nix {}'

[nix-shell:~]$ $CC --version
clang version 22.1.2
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/nqrpsik93243zfbysab689b4598x0srw-clang-22.1.2/bin

:(

10:54:23
@blokyk:matrix.orgzoë (@blokyk) *

ok so i wasn't going crazy: trying it out with just nix-shell and hard-coded pkgsCross.riscv32. in front of everything works, but for some reason callPackage/splicing doesn't work :(

# shell.nix
{
  llvmPackages_latest,
  mkShell
}:
let mkLLVMShell = mkShell.override { inherit (llvmPackages_latest) stdenv; };
in
mkLLVMShell { }
$ nix-shell -E '(import <nixpkgs> {}).pkgsCross.riscv64.callPackage ./shell.nix {}'

[nix-shell:~]$ $CC --version
clang version 22.1.2
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/nqrpsik93243zfbysab689b4598x0srw-clang-22.1.2/bin

:(

10:55:24
@dramforever:matrix.orgdramforever stdenv.cc is the toolchain 13:01:19
@dramforever:matrix.orgdramforeverbut otherwise yeah pkgsCross.riscv32.mkShell should get you what you want13:03:23
@blokyk:matrix.orgzoë (@blokyk)yeah idk what i did, i was just confused13:03:49

Show newer messages


Back to Room ListRoom Version: 10