← board

riscv32: support record (by-value struct) function results

Problem

The riscv32 backend rejects a function whose result is a record (small struct returned by value):

target riscv32: only ordinal/float/pointer/string function results supported yet

Per the RISC-V calling convention a struct ≤ 2 XLEN words is returned in a0/a1; larger aggregates use the hidden-pointer (sret) convention. Neither is emitted yet. x86-64 handles record returns (net.pas works on host).

Impact (why it surfaced)

lib/rtl/net.pas exposes TNetAddress (a 2-field record: Host: LongWord; Port: Integer) and the helpers NetAddress/NetLoopback return it by value. That makes net.pas itself fail to compile for --target=riscv32, so the blocking net facade cannot be used on ESP32-C3. The PAL layer (platform) has no record-returning functions and compiles + links fine for riscv32 — the ESP32-C3 lwIP socket smoke (examples/esp32/net-c3) therefore calls PAL directly instead of net.pas. This is a real codegen gap, not a reason to restructure net.pas: returning a small record by value is idiomatic Pascal.

Note Int64 results: a function returning Int64 works on riscv32 when the result is consumed directly (the PAL byte-count functions do this); only record results are blocked here.

Acceptance

Log

Fix log