From 96552638ae8c93882a4064988b3cab1b933997e3 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Mon, 11 Nov 2024 07:34:08 -0500 Subject: [PATCH 1/2] dev: support incremental for x86_64-linux env --- src/dev.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dev.zig b/src/dev.zig index 9746b307af..0d365c3e19 100644 --- a/src/dev.zig +++ b/src/dev.zig @@ -23,7 +23,7 @@ pub const Env = enum { sema, /// - sema - /// - `zig build-* -fno-llvm -fno-lld -target x86_64-linux` + /// - `zig build-* -fincremental -fno-llvm -fno-lld -target x86_64-linux --listen=-` @"x86_64-linux", /// - sema @@ -130,6 +130,8 @@ pub const Env = enum { else => Env.ast_gen.supports(feature), }, .@"x86_64-linux" => switch (feature) { + .stdio_listen, + .incremental, .x86_64_backend, .elf_linker, => true, From 11e54a3559d6cfebd09c48e16b8315e13d7de337 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 16 Nov 2024 14:02:49 -0500 Subject: [PATCH 2/2] link: fix failing incremental test cases --- src/link/Elf/ZigObject.zig | 9 +++++---- test/incremental/add_decl | 3 +-- test/incremental/fix_astgen_failure | 3 +-- test/incremental/function_becomes_inline | 2 +- .../incremental/recursive_function_becomes_non_recursive | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index 84b54aabcd..1e29ab8bf6 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -1496,7 +1496,7 @@ pub fn updateFunc( }); defer gpa.free(name); const osec = if (self.text_index) |sect_sym_index| - self.atom(self.symbol(sect_sym_index).ref.index).?.output_section_index + self.symbol(sect_sym_index).output_section_index else osec: { const osec = try elf_file.addSection(.{ .name = try elf_file.insertShString(".text"), @@ -1896,12 +1896,13 @@ pub fn deleteExport( } orelse return; const zcu = elf_file.base.comp.zcu.?; const exp_name = name.toSlice(&zcu.intern_pool); - const esym_index = metadata.@"export"(self, exp_name) orelse return; + const sym_index = metadata.@"export"(self, exp_name) orelse return; log.debug("deleting export '{s}'", .{exp_name}); - const esym = &self.symtab.items(.elf_sym)[esym_index.*]; + const esym_index = self.symbol(sym_index.*).esym_index; + const esym = &self.symtab.items(.elf_sym)[esym_index]; _ = self.globals_lookup.remove(esym.st_name); esym.* = Elf.null_sym; - self.symtab.items(.shndx)[esym_index.*] = elf.SHN_UNDEF; + self.symtab.items(.shndx)[esym_index] = elf.SHN_UNDEF; } pub fn getGlobalSymbol(self: *ZigObject, elf_file: *Elf, name: []const u8, lib_name: ?[]const u8) !u32 { diff --git a/test/incremental/add_decl b/test/incremental/add_decl index a2863d6bde..6b3a0dad84 100644 --- a/test/incremental/add_decl +++ b/test/incremental/add_decl @@ -1,5 +1,4 @@ -// Disabled on self-hosted due to linker crash -// #target=x86_64-linux-selfhosted +#target=x86_64-linux-selfhosted #target=x86_64-linux-cbe #target=x86_64-windows-cbe #update=initial version diff --git a/test/incremental/fix_astgen_failure b/test/incremental/fix_astgen_failure index b94c9c77ee..2298bc5248 100644 --- a/test/incremental/fix_astgen_failure +++ b/test/incremental/fix_astgen_failure @@ -1,5 +1,4 @@ -// Disabled on self-hosted due to linker crash -// #target=x86_64-linux-selfhosted +#target=x86_64-linux-selfhosted #target=x86_64-linux-cbe #target=x86_64-windows-cbe #update=initial version with error diff --git a/test/incremental/function_becomes_inline b/test/incremental/function_becomes_inline index b7e604bfac..607cd6805e 100644 --- a/test/incremental/function_becomes_inline +++ b/test/incremental/function_becomes_inline @@ -1,4 +1,4 @@ -//#target=x86_64-linux-selfhosted +#target=x86_64-linux-selfhosted #target=x86_64-linux-cbe #target=x86_64-windows-cbe #update=non-inline version diff --git a/test/incremental/recursive_function_becomes_non_recursive b/test/incremental/recursive_function_becomes_non_recursive index 7a9eb5d26f..e6f27bf2b4 100644 --- a/test/incremental/recursive_function_becomes_non_recursive +++ b/test/incremental/recursive_function_becomes_non_recursive @@ -1,4 +1,4 @@ -//#target=x86_64-linux-selfhosted +#target=x86_64-linux-selfhosted #target=x86_64-linux-cbe #target=x86_64-windows-cbe #update=initial version