#1070 Relocation Errors Riscv64 Freestanding

1 messages · Page 1 of 1 (latest)

warm canopy
#
    const target = b.standardTargetOptions(.{
        .default_target = .{
            .cpu_arch = std.Target.Cpu.Arch.riscv64,
            .os_tag = std.Target.Os.Tag.freestanding,
            .abi = std.Target.Abi.none,
            .ofmt = std.Target.ObjectFormat.elf,
            .cpu_model = .{ .explicit = &std.Target.riscv.cpu.baseline_rv64 },
        },
    });

I'm using these build options and I'm getting about 1070 of these errors.

error: ld.lld: /home/chris/.cache/zig/o/16002fdb080b21242a4512bb77c96eae/libcompiler_rt.a(/home/chris/.cache/zig/o/16002fdb080b21242a4512bb77c96eae/libcompiler_rt_zcu.o):(function __atomic_compare_exchange_16: .text.__atomic_compare_exchange_16+0xc): relocation R_RISCV_HI20 out of range: 524356 is not in [-524288, 524287]; references 'compiler_rt.atomics.spinlocks'
    note: referenced by atomics.zig:104 (/home/chris/zig/0.15.0/lib/compiler_rt/atomics.zig:104)
    note: defined in 
...

Build Summary: 0/3 steps succeeded; 1 failed
install transitive failure
└─ install vm-kit transitive failure
   └─ compile exe vm-kit Debug riscv64-freestanding-none 1070 error

It's just an entry.S file and a main.zig with an exported _start function.

I have tried other targets as well. (linux-none-elf) I know when I build this with rust, the triple is unknown-none-elf.. I have tried with that combo in the build options. with more relo errors.

My linker script is putting the text at 0x8000_0000.

A quick google shows that the code model needs to be medany, but im not sure how to set that in zig

oblique monolith
#

you can set it when creating your module, .code_model = .medany

warm canopy
#

ahh, the module. thank you