diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-08-21 08:07:42 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-08-21 08:07:44 +0200 |
| commit | b73ef342895f00bdb31ea5f947ee83764f235d43 (patch) | |
| tree | 1aed709d194cdcfd203c2df5b88a1ac02a31d04c /src/link | |
| parent | 4793dafa0433d758b126f2f97d1de031b99e0fa1 (diff) | |
| download | zig-b73ef342895f00bdb31ea5f947ee83764f235d43.tar.gz zig-b73ef342895f00bdb31ea5f947ee83764f235d43.zip | |
frontend: directly pass resolved frameworks container to the linker
We can infer the framework name from the included resolved framework
path.
Fix hash implementation, and bump linker hash value from 9 to 10.
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Coff/lld.zig | 2 | ||||
| -rw-r--r-- | src/link/Elf.zig | 2 | ||||
| -rw-r--r-- | src/link/MachO/zld.zig | 23 | ||||
| -rw-r--r-- | src/link/Wasm.zig | 4 |
4 files changed, 15 insertions, 16 deletions
diff --git a/src/link/Coff/lld.zig b/src/link/Coff/lld.zig index bd82254e6a..c0f88704e5 100644 --- a/src/link/Coff/lld.zig +++ b/src/link/Coff/lld.zig @@ -63,7 +63,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod man = comp.cache_parent.obtain(); self.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 9); + comptime assert(Compilation.link_hash_implementation_version == 10); for (self.base.options.objects) |obj| { _ = try man.addFile(obj.path, null); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 9d71885e61..c1cc4355c6 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1367,7 +1367,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v // We are about to obtain this lock, so here we give other processes a chance first. self.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 9); + comptime assert(Compilation.link_hash_implementation_version == 10); try man.addOptionalFile(self.base.options.linker_script); try man.addOptionalFile(self.base.options.version_script); diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig index 7987bb4f1d..e4dde33453 100644 --- a/src/link/MachO/zld.zig +++ b/src/link/MachO/zld.zig @@ -3396,7 +3396,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr // We are about to obtain this lock, so here we give other processes a chance first. macho_file.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 9); + comptime assert(Compilation.link_hash_implementation_version == 10); for (options.objects) |obj| { _ = try man.addFile(obj.path, null); @@ -3417,7 +3417,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr man.hash.add(options.strip); man.hash.addListOfBytes(options.lib_dirs); man.hash.addListOfBytes(options.framework_dirs); - link.hashAddFrameworks(&man.hash, options.frameworks); + try link.hashAddFrameworks(&man, options.frameworks); man.hash.addListOfBytes(options.rpath_list); if (is_dyn_lib) { man.hash.addOptionalBytes(options.install_name); @@ -3555,9 +3555,8 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr } { - const vals = options.frameworks.values(); - try libs.ensureUnusedCapacity(vals.len); - for (vals) |v| libs.putAssumeCapacity(v.path, .{ + try libs.ensureUnusedCapacity(options.frameworks.len); + for (options.frameworks) |v| libs.putAssumeCapacity(v.path, .{ .needed = v.needed, .weak = v.weak, .path = v.path, @@ -3664,14 +3663,14 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr try argv.append(try std.fmt.allocPrint(arena, "-L{s}", .{lib_dir})); } - for (options.frameworks.keys()) |framework| { - const info = options.frameworks.get(framework).?; - const arg = if (info.needed) - try std.fmt.allocPrint(arena, "-needed_framework {s}", .{framework}) - else if (info.weak) - try std.fmt.allocPrint(arena, "-weak_framework {s}", .{framework}) + for (options.frameworks) |framework| { + const name = std.fs.path.stem(framework.path); + const arg = if (framework.needed) + try std.fmt.allocPrint(arena, "-needed_framework {s}", .{name}) + else if (framework.weak) + try std.fmt.allocPrint(arena, "-weak_framework {s}", .{name}) else - try std.fmt.allocPrint(arena, "-framework {s}", .{framework}); + try std.fmt.allocPrint(arena, "-framework {s}", .{name}); try argv.append(arg); } diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index f705c18b69..89c552a3fb 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -3193,7 +3193,7 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l // We are about to obtain this lock, so here we give other processes a chance first. wasm.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 9); + comptime assert(Compilation.link_hash_implementation_version == 10); for (options.objects) |obj| { _ = try man.addFile(obj.path, null); @@ -4254,7 +4254,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! // We are about to obtain this lock, so here we give other processes a chance first. wasm.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 9); + comptime assert(Compilation.link_hash_implementation_version == 10); for (wasm.base.options.objects) |obj| { _ = try man.addFile(obj.path, null); |
