| ... | @@ -223,9 +223,33 @@ pub fn getInputSection(self: ZigObject, atom: Atom, macho_file: *MachO) macho.se | ... | @@ -223,9 +223,33 @@ pub fn getInputSection(self: ZigObject, atom: Atom, macho_file: *MachO) macho.se |
| 223 | } | 223 | } |
| 224 | | 224 | |
| 225 | pub fn flushModule(self: *ZigObject, macho_file: *MachO) !void { | 225 | pub fn flushModule(self: *ZigObject, macho_file: *MachO) !void { |
| 226 | _ = self; | 226 | // Handle any lazy symbols that were emitted by incremental compilation. |
| 227 | _ = macho_file; | 227 | if (self.lazy_syms.getPtr(.none)) |metadata| { |
| 228 | @panic("TODO flushModule"); | 228 | const zcu = macho_file.base.comp.module.?; |
| | 229 | |
| | 230 | // Most lazy symbols can be updated on first use, but |
| | 231 | // anyerror needs to wait for everything to be flushed. |
| | 232 | if (metadata.text_state != .unused) self.updateLazySymbol( |
| | 233 | macho_file, |
| | 234 | link.File.LazySymbol.initDecl(.code, null, zcu), |
| | 235 | metadata.text_symbol_index, |
| | 236 | ) catch |err| return switch (err) { |
| | 237 | error.CodegenFail => error.FlushFailure, |
| | 238 | else => |e| e, |
| | 239 | }; |
| | 240 | if (metadata.const_state != .unused) self.updateLazySymbol( |
| | 241 | macho_file, |
| | 242 | link.File.LazySymbol.initDecl(.const_data, null, zcu), |
| | 243 | metadata.const_symbol_index, |
| | 244 | ) catch |err| return switch (err) { |
| | 245 | error.CodegenFail => error.FlushFailure, |
| | 246 | else => |e| e, |
| | 247 | }; |
| | 248 | } |
| | 249 | for (self.lazy_syms.values()) |*metadata| { |
| | 250 | if (metadata.text_state != .unused) metadata.text_state = .flushed; |
| | 251 | if (metadata.const_state != .unused) metadata.const_state = .flushed; |
| | 252 | } |
| 229 | } | 253 | } |
| 230 | | 254 | |
| 231 | pub fn getDeclVAddr( | 255 | pub fn getDeclVAddr( |