Compiling to RiscV32

HuskyNator HuskyNator at protonmail.ch
Wed Jul 5 17:00:53 UTC 2023


Recently found out LDC supports cross-compiling to riscv, but 
while trying it out I can't seem to make it work. I am very 
likely missing something simple, as I haven't done something like 
this before. I've already been told it's likely something with 
linking, though I'm not sure how to set this up. (Nor even 
without imports & confined to 1 file)

Using a simple single '.d' file with no imports: `Error: cannot 
find program 'cc'`
With imports it's a longer issue:
```
E:\Code\D\Overig>ldc2 --mtriple=riscv32 --mcpu=generic-rv32 -c 
source/app.d
C:\Program Files\LDC 1.32\bin\..\import\std\stdio.d(49): Error: 
module `core.stdc.stddef` import `wchar_t` not found
C:\Program Files\LDC 1.32\bin\..\import\core\stdc\time.d(34): 
Error: undefined identifier `time_t`, did you mean function 
`time`?
... (many similar errors here)
C:\Program Files\LDC 1.32\bin\..\import\core\stdc\wchar_.d(175): 
Error: undefined identifier `wchar_t`, did you mean `dchar`?
```

Note, the command I'm using is: `ldc2 --mtriple=riscv32 
--mcpu=generic-rv32 -c source/app.d`

I've also wanted to look into dub's `--arch=riscv32` command, 
which should function given what I've read, though this just 
states it's not supported. (Even though I believe it should be 
using ldc for this?)

Apologies for naïvity here, I cant really find any examples or 
guidance.


More information about the Digitalmars-d-learn mailing list