mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-29 14:38:21 +00:00
rtl: fix LinkerSet on release builds
LLVM seemed to like doing DCE on those symbols, so export them to ensure they are used. The `Tag` mess is because we need to generate a unique symbol name, and the pointer cast is so we can export e.g zig functions. This is messy.
This commit is contained in:
+16
-3
@@ -26,12 +26,25 @@ pub fn LinkerSet(name: []const u8, comptime T: type) type {
|
||||
return arr[0..n];
|
||||
}
|
||||
|
||||
pub fn insert(elem: T) type {
|
||||
pub fn insert(comptime elem: T) type {
|
||||
const U = struct {
|
||||
var storage: T linksection("set_" ++ name) = elem;
|
||||
var storage: T = elem;
|
||||
|
||||
fn Tag(comptime e: T) type {
|
||||
return struct {
|
||||
const tagged = e;
|
||||
};
|
||||
}
|
||||
|
||||
comptime {
|
||||
_ = &storage;
|
||||
// What the fuck?
|
||||
@export(
|
||||
@as(*const usize, @ptrCast(&storage)),
|
||||
.{
|
||||
.name = "_set_elem_" ++ name ++ "_" ++ @typeName(Tag(elem)),
|
||||
.section = "set_" ++ name,
|
||||
},
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user