| ... | ... | @@ -361,12 +361,13 @@ pub const OutputFunctionIndex = enum(u32) { |
| 361 | 361 | pub const GlobalIndex = enum(u32) { |
| 362 | 362 | _, |
| 363 | 363 | |
| 364 | | /// This is only accurate when there is a Zcu. |
| 364 | /// This is only accurate when not emitting an object and there is a Zcu. |
| 365 | 365 | pub const stack_pointer: GlobalIndex = @enumFromInt(0); |
| 366 | 366 | |
| 367 | 367 | /// Same as `stack_pointer` but with a safety assertion. |
| 368 | 368 | pub fn stackPointer(wasm: *const Wasm) Global.Index { |
| 369 | 369 | const comp = wasm.base.comp; |
| 370 | assert(comp.config.output_mode != .Obj); |
| 370 | 371 | assert(comp.zcu != null); |
| 371 | 372 | return .stack_pointer; |
| 372 | 373 | } |
| ... | ... | @@ -2450,7 +2451,7 @@ pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index |
| 2450 | 2451 | .variable => |variable| .{ variable.init, variable.owner_nav }, |
| 2451 | 2452 | else => .{ nav.status.resolved.val, nav_index }, |
| 2452 | 2453 | }; |
| 2453 | | log.debug("updateNav {} {}", .{ nav.fqn.fmt(ip), chased_nav_index }); |
| 2454 | //log.debug("updateNav {} {}", .{ nav.fqn.fmt(ip), chased_nav_index }); |
| 2454 | 2455 | assert(!wasm.imports.contains(chased_nav_index)); |
| 2455 | 2456 | |
| 2456 | 2457 | if (nav_init != .none and !Value.fromInterned(nav_init).typeOf(zcu).hasRuntimeBits(zcu)) { |
| ... | ... | @@ -2578,6 +2579,7 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.File.FlushError!v |
| 2578 | 2579 | const comp = wasm.base.comp; |
| 2579 | 2580 | const gpa = comp.gpa; |
| 2580 | 2581 | const rdynamic = comp.config.rdynamic; |
| 2582 | const is_obj = comp.config.output_mode == .Obj; |
| 2581 | 2583 | |
| 2582 | 2584 | assert(wasm.missing_exports.entries.len == 0); |
| 2583 | 2585 | for (wasm.export_symbol_names) |exp_name| { |
| ... | ... | @@ -2614,8 +2616,13 @@ pub fn prelink(wasm: *Wasm, prog_node: std.Progress.Node) link.File.FlushError!v |
| 2614 | 2616 | |
| 2615 | 2617 | if (comp.zcu != null) { |
| 2616 | 2618 | // Zig always depends on a stack pointer global. |
| 2617 | | try wasm.globals.put(gpa, .__stack_pointer, {}); |
| 2618 | | assert(wasm.globals.entries.len - 1 == @intFromEnum(GlobalIndex.stack_pointer)); |
| 2619 | // If emitting an object, it's an import. Otherwise, the linker synthesizes it. |
| 2620 | if (is_obj) { |
| 2621 | @panic("TODO"); |
| 2622 | } else { |
| 2623 | try wasm.globals.put(gpa, .__stack_pointer, {}); |
| 2624 | assert(wasm.globals.entries.len - 1 == @intFromEnum(GlobalIndex.stack_pointer)); |
| 2625 | } |
| 2619 | 2626 | } |
| 2620 | 2627 | |
| 2621 | 2628 | // These loops do both recursive marking of alive symbols well as checking for undefined symbols. |