authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-04 12:20:28+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:04+02:00
log727d9431c8e9ccd29938934a2cd317c1cb43ae44
tree09f49a35ae656cab89ee2a18e90b1a9e4f6bb70a
parentd6cec5a586c55f471d3f830f34d7a5f668337fb9

elf: link hello-world in c++


1 files changed, 13 insertions(+), 1 deletions(-)

src/link/Elf.zig+13-1
...@@ -1140,6 +1140,18 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node...@@ -1140,6 +1140,18 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
11401140
1141 var system_libs = std.ArrayList(SystemLib).init(arena);1141 var system_libs = std.ArrayList(SystemLib).init(arena);
11421142
1143 // libc++ dep
1144 if (self.base.options.link_libcpp) {
1145 try system_libs.ensureUnusedCapacity(2);
1146 system_libs.appendAssumeCapacity(.{ .path = comp.libcxxabi_static_lib.?.full_object_path });
1147 system_libs.appendAssumeCapacity(.{ .path = comp.libcxx_static_lib.?.full_object_path });
1148 }
1149
1150 // libunwind dep
1151 if (self.base.options.link_libunwind) {
1152 try system_libs.append(.{ .path = comp.libunwind_static_lib.?.full_object_path });
1153 }
1154
1143 // libc dep1155 // libc dep
1144 self.error_flags.missing_libc = false;1156 self.error_flags.missing_libc = false;
1145 if (self.base.options.link_libc) {1157 if (self.base.options.link_libc) {
...@@ -1240,7 +1252,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node...@@ -1240,7 +1252,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
1240 self.files.set(index, .{ .linker_defined = .{ .index = index } });1252 self.files.set(index, .{ .linker_defined = .{ .index = index } });
1241 self.linker_defined_index = index;1253 self.linker_defined_index = index;
1242 }1254 }
1243 try self.addLinkerDefinedSymbols();
12441255
1245 // Now, we are ready to resolve the symbols across all input files.1256 // Now, we are ready to resolve the symbols across all input files.
1246 // We will first resolve the files in the ZigModule, next in the parsed1257 // We will first resolve the files in the ZigModule, next in the parsed
...@@ -1248,6 +1259,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node...@@ -1248,6 +1259,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
1248 // Any qualifing unresolved symbol will be upgraded to an absolute, weak1259 // Any qualifing unresolved symbol will be upgraded to an absolute, weak
1249 // symbol for potential resolution at load-time.1260 // symbol for potential resolution at load-time.
1250 self.resolveSymbols();1261 self.resolveSymbols();
1262 try self.addLinkerDefinedSymbols();
1251 self.markEhFrameAtomsDead();1263 self.markEhFrameAtomsDead();
1252 self.markImportsExports();1264 self.markImportsExports();
1253 self.claimUnresolved();1265 self.claimUnresolved();