Replace `*const anyopaque` with `anytype` when expecting function pointers

There are situations in which function pointers have attributes, like addrspace. This is generally true on (some) microcontrollers, where the address space of a pointer is important because the instructions required to interact with them may differ (harvard architecture).

The signature of @export is:

@export(comptime ptr: *const anyopaque, comptime options: ExportOptions) void

so I could not do this:

// I'm putting the explicit type here for clarity, but function pointers
// on these platforms _always_ have these attributes automatically.
const ptr: *const addrspace(.flash) fn() void = &myFun;
@export(ptr, .{...});

This is used all over the place in compiler_rt, specifically in pub inline fn symbol(comptime func: *const anyopaque, comptime name: []const u8) void.

This is because these addrspace pointers can not be coerced into *const anyopaque.

Do you think a viable option is to replace any mention of *const anyopaque with anytype, including in the @export builtin itself? Or is that too open of an API for something like that?

And for someone who has never contributed to zig before, how difficult does this sound at first? Might it require very complicated logic in the export builtin, because it’s going to have to analyze the pointer attributes, or would it just map them to something to be passed to llvm later down the line?

But then again, maybe it’s not necessary, since functions will be put into flash automatically, so maybe these pointer attributes are not needed. I don’t fully get how all of this works yet.

Wouldn’t it make more sense to make these function pointers coercible into *const anyopaque?

The main problem is that on harvard architecture, different devices do not map to different address ranges, but can use the same addresses, but must use different instructions. address spaces encode this information.

(on avr) To read from 0x00 in sram, you use ld. To read from 0x00 in flash, you use lpm. Same address.

so if I pass a pointer to a function that I expect it to read from, the compiler must know these pointer attributes so that it can emit the correct instructions.

*const anyopaque is actually a shorthand for *const addrspace(.generic) anyopaque.

edit: typo.