| author | |
| committer | |
| log | e117e05768be08078a8484eaf982cfa5347a674e |
| tree | 5abf76c2a2bda4e964057f7f318a1117c7cbae82 |
| parent | 91de8dc8abd9db03ba4ac4c4a5fcbe86e8bc7ee4 |
3 files changed, 20 insertions(+), 8 deletions(-)
src/link/MachO/ZigObject.zig+3-1| ... | @@ -979,7 +979,9 @@ fn updateDeclCode( | ... | @@ -979,7 +979,9 @@ fn updateDeclCode( |
| 979 | sym.out_n_sect = sect_index; | 979 | sym.out_n_sect = sect_index; |
| 980 | atom.out_n_sect = sect_index; | 980 | atom.out_n_sect = sect_index; |
| 981 | 981 | ||
| 982 | sym.name = try self.strtab.insert(gpa, decl.fqn.toSlice(ip)); | 982 | const sym_name = try std.fmt.allocPrintZ(gpa, "_{s}", .{decl.fqn.toSlice(ip)}); |
| 983 | defer gpa.free(sym_name); | ||
| 984 | sym.name = try self.strtab.insert(gpa, sym_name); | ||
| 983 | atom.flags.alive = true; | 985 | atom.flags.alive = true; |
| 984 | atom.name = sym.name; | 986 | atom.name = sym.name; |
| 985 | nlist.n_strx = sym.name; | 987 | nlist.n_strx = sym.name; |
test/link/link.zig+2-1| ... | @@ -74,8 +74,9 @@ fn addCompileStep( | ... | @@ -74,8 +74,9 @@ fn addCompileStep( |
| 74 | .target = base.target, | 74 | .target = base.target, |
| 75 | .optimize = base.optimize, | 75 | .optimize = base.optimize, |
| 76 | .root_source_file = rsf: { | 76 | .root_source_file = rsf: { |
| 77 | const name = b.fmt("{s}.zig", .{overlay.name}); | ||
| 77 | const bytes = overlay.zig_source_bytes orelse break :rsf null; | 78 | const bytes = overlay.zig_source_bytes orelse break :rsf null; |
| 78 | break :rsf b.addWriteFiles().add("a.zig", bytes); | 79 | break :rsf b.addWriteFiles().add(name, bytes); |
| 79 | }, | 80 | }, |
| 80 | .pic = overlay.pic, | 81 | .pic = overlay.pic, |
| 81 | .strip = if (base.strip) |s| s else overlay.strip, | 82 | .strip = if (base.strip) |s| s else overlay.strip, |
test/link/macho.zig+15-6| ... | @@ -916,7 +916,7 @@ fn testLinksection(b: *Build, opts: Options) *Step { | ... | @@ -916,7 +916,7 @@ fn testLinksection(b: *Build, opts: Options) *Step { |
| 916 | 916 | ||
| 917 | if (opts.optimize == .Debug) { | 917 | if (opts.optimize == .Debug) { |
| 918 | check.checkInSymtab(); | 918 | check.checkInSymtab(); |
| 919 | check.checkContains("(__TEXT,__TestGenFnA) _a.testGenericFn__anon_"); | 919 | check.checkContains("(__TEXT,__TestGenFnA) _main.testGenericFn__anon_"); |
| 920 | } | 920 | } |
| 921 | 921 | ||
| 922 | test_step.dependOn(&check.step); | 922 | test_step.dependOn(&check.step); |
| ... | @@ -2519,11 +2519,20 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step { | ... | @@ -2519,11 +2519,20 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step { |
| 2519 | }); | 2519 | }); |
| 2520 | exe.addObject(obj); | 2520 | exe.addObject(obj); |
| 2521 | 2521 | ||
| 2522 | expectLinkErrors(exe, test_step, .{ .exact = &.{ | 2522 | // TODO order should match across backends if possible |
| 2523 | "error: undefined symbol: _foo", | 2523 | if (opts.use_llvm) { |
| 2524 | "note: referenced by /?/a.o:_bar", | 2524 | expectLinkErrors(exe, test_step, .{ .exact = &.{ |
| 2525 | "note: referenced by /?/main.o:_a.main", | 2525 | "error: undefined symbol: _foo", |
| 2526 | } }); | 2526 | "note: referenced by /?/a.o:_bar", |
| 2527 | "note: referenced by /?/main.o:_main.main", | ||
| 2528 | } }); | ||
| 2529 | } else { | ||
| 2530 | expectLinkErrors(exe, test_step, .{ .exact = &.{ | ||
| 2531 | "error: undefined symbol: _foo", | ||
| 2532 | "note: referenced by /?/main.o:_main.main", | ||
| 2533 | "note: referenced by /?/a.o:__TEXT$__text_zig", | ||
| 2534 | } }); | ||
| 2535 | } | ||
| 2527 | 2536 | ||
| 2528 | return test_step; | 2537 | return test_step; |
| 2529 | } | 2538 | } |