Create "static" arrays with large size

for a project of mine I need a comptime generated array that is part of the static memory. That on it’s own is fairly simple but my array is close to 0.2mb in size and as such apparently too large.
The exception is form the linker and contains a bunch of relocation errors (and that the variables for the label addresses are not large enough).
That makes sense, because the array is located in the first linker section and following addresses get very large as result.
Now there are two options.

  1. getting the linker to work with 32bit+ addresses which can be done with .code_mode = .large, which doesn’t have any impact sadly.
  2. putting the array in the last linker section so there are no labels following that would have huge addresses.
    I tried the second option with @export(to the last linker section) but that didn’t work since @export is runtime (and I need to write to the array at comptime).
    Maybe somebody has an idea.

greets from Germany!

Hmm this is a good question. Let’s start by examining a small test case - do you have one?

So I tried to reproduce it but I’m working on an embedded kernel(aarch64) and didn’t really manage to get a reproducible example.
But the pattern is as follows. Either it is:

const std =@import("std");

const test_block_eval = blk: {
    var testv: [4202492]usize = [_]usize{0} ** 4202492;

    var t: usize = 0;
    while (t < 4202492) : (t += 1) {
        testv[t] = 1;
    break :blk testv;

pub fn main() void {
    std.debug.print("{*}", .{&test_block_eval});

And then it fails and throws something like this:

LLD Link... ld.lld: error: /Users/xxx/Documents/Projekte/MinimalRoboticsPlatform/zig-cache/o/57cd907a8230ef09a2bd0d3b8ccbc477/boot.o:(.text.boot+0x24): relocation R_AARCH64_ADR_PREL_LO21 out of range: 4202492 is not in [-1048576, 1048575]; references _bss_start
ld.lld: error: /Users/xx/Documents/Projekte/MinimalRoboticsPlatform/zig-cache/o/57cd907a8230ef09a2bd0d3b8ccbc477/boot.o:(.text.boot+0x28): relocation R_AARCH64_ADR_PREL_LO21 out of range: 4202488 is not in [-1048576, 1048575]; references _bss_end
error: FileNotFound

What I also tried is exporting the compile time array (to the binary…) but that doesn’t work (at least the label is not found).
The thing that I didn’t try yet, is to have test_block_eval in the last section but I don’t know how I would do that. (already tried with export and the section parameter in the ExportOption but that unsurprisingly didn’t work)

I’m 95.83% sure that I’ve tried the master branch right at the beginning already… but maybe didn’t clean caches properly, that’s always a bit sketch with linker stuff. with 1.0 it does work. cheers