std: full namespace tail — fs/process/socket/json/cli/hash/test
With 0115's own-wins globals landed, the remaining tail modules join std.sx: every '#import "modules/std.sx"' now carries mem/xml/log/fs/ process/socket/json/cli/hash/test as namespaces (trace stays a direct import). Enablers in the same change: - emit: dead-global elimination — a plain-data global no instruction references is not emitted, so tail modules' data (hash's 64-entry K table, OS/ARCH/POINTER_SIZE) stays out of binaries that don't use it. Comptime-backed globals keep their #run evaluation. 37 pinned IR snapshots regenerated (dead globals dropped + string renumbering from the larger module). - 1055/1056 stop pinning the global error-tag ordinal (it shifts with program composition); they assert nonzero + tag identity + name. - specs/readme/CLAUDE.md tail docs updated.
This commit is contained in:
@@ -860,7 +860,27 @@ pub const LLVMEmitter = struct {
|
||||
}
|
||||
|
||||
fn emitGlobals(self: *LLVMEmitter) void {
|
||||
// Dead-global elimination: a plain-data global no instruction
|
||||
// references is not emitted — without this, every module pulled in
|
||||
// via the std namespace tail lands its data (hash's K table, ...)
|
||||
// in every binary. Comptime-backed globals are kept: their #run
|
||||
// evaluation (and its failure diagnostics) is a semantic effect,
|
||||
// not just data.
|
||||
var used = std.AutoHashMap(u32, void).init(self.alloc);
|
||||
defer used.deinit();
|
||||
for (self.ir_mod.functions.items) |*func| {
|
||||
for (func.blocks.items) |*block| {
|
||||
for (block.insts.items) |*instruction| {
|
||||
switch (instruction.op) {
|
||||
.global_get, .global_addr => |gid| used.put(gid.index(), {}) catch {},
|
||||
.global_set => |gs| used.put(gs.global.index(), {}) catch {},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (self.ir_mod.globals.items, 0..) |global, i| {
|
||||
if (global.comptime_func == null and !used.contains(@intCast(i))) continue;
|
||||
const name = self.ir_mod.types.getString(global.name);
|
||||
const llvm_ty = self.toLLVMType(global.ty);
|
||||
const name_z = self.alloc.dupeZ(u8, name) catch continue;
|
||||
|
||||
Reference in New Issue
Block a user