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.