| author | |
| committer | |
| log | 986a3d23abcbdb61fd733d2340d4872b6ee55dca |
| tree | 9efe038889e06038573ead7e3596802585dc977a |
| parent | e565ff305ae208b15058a462d348fde515b3e950 |
This can be null in two cases right now:
1. Windows DLLs that zig ships such as advapi32.
2. extern "foo" fn declarations where we find out about libraries too late
TODO: make this non-optional and resolve those two cases somehow.4 files changed, 10 insertions(+), 6 deletions(-)
src/Compilation.zig+2-2| ... | @@ -1728,7 +1728,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1728,7 +1728,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1728 | try comp.bin_file.options.system_libs.put(comp.gpa, name, .{ | 1728 | try comp.bin_file.options.system_libs.put(comp.gpa, name, .{ |
| 1729 | .needed = false, | 1729 | .needed = false, |
| 1730 | .weak = false, | 1730 | .weak = false, |
| 1731 | .path = name, | 1731 | .path = null, |
| 1732 | }); | 1732 | }); |
| 1733 | } | 1733 | } |
| 1734 | } | 1734 | } |
| ... | @@ -5621,7 +5621,7 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void { | ... | @@ -5621,7 +5621,7 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void { |
| 5621 | gop.value_ptr.* = .{ | 5621 | gop.value_ptr.* = .{ |
| 5622 | .needed = true, | 5622 | .needed = true, |
| 5623 | .weak = false, | 5623 | .weak = false, |
| 5624 | .path = undefined, | 5624 | .path = null, |
| 5625 | }; | 5625 | }; |
| 5626 | try comp.work_queue.writeItem(.{ | 5626 | try comp.work_queue.writeItem(.{ |
| 5627 | .windows_import_lib = comp.bin_file.options.system_libs.count() - 1, | 5627 | .windows_import_lib = comp.bin_file.options.system_libs.count() - 1, |
src/link.zig+6-2| ... | @@ -26,7 +26,11 @@ const TypedValue = @import("TypedValue.zig"); | ... | @@ -26,7 +26,11 @@ const TypedValue = @import("TypedValue.zig"); |
| 26 | pub const SystemLib = struct { | 26 | pub const SystemLib = struct { |
| 27 | needed: bool, | 27 | needed: bool, |
| 28 | weak: bool, | 28 | weak: bool, |
| 29 | path: []const u8, | 29 | /// This can be null in two cases right now: |
| 30 | /// 1. Windows DLLs that zig ships such as advapi32. | ||
| 31 | /// 2. extern "foo" fn declarations where we find out about libraries too late | ||
| 32 | /// TODO: make this non-optional and resolve those two cases somehow. | ||
| 33 | path: ?[]const u8, | ||
| 30 | }; | 34 | }; |
| 31 | 35 | ||
| 32 | /// When adding a new field, remember to update `hashAddFrameworks`. | 36 | /// When adding a new field, remember to update `hashAddFrameworks`. |
| ... | @@ -48,7 +52,7 @@ pub fn hashAddSystemLibs( | ... | @@ -48,7 +52,7 @@ pub fn hashAddSystemLibs( |
| 48 | for (hm.values()) |value| { | 52 | for (hm.values()) |value| { |
| 49 | man.hash.add(value.needed); | 53 | man.hash.add(value.needed); |
| 50 | man.hash.add(value.weak); | 54 | man.hash.add(value.weak); |
| 51 | _ = try man.addFile(value.path, null); | 55 | if (value.path) |p| _ = try man.addFile(p, null); |
| 52 | } | 56 | } |
| 53 | } | 57 | } |
| 54 | 58 |
src/link/Elf.zig+1-1| ... | @@ -1842,7 +1842,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v | ... | @@ -1842,7 +1842,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v |
| 1842 | // libraries and not static libraries (the check for that needs to be earlier), | 1842 | // libraries and not static libraries (the check for that needs to be earlier), |
| 1843 | // but they could be full paths to .so files, in which case we | 1843 | // but they could be full paths to .so files, in which case we |
| 1844 | // want to avoid prepending "-l". | 1844 | // want to avoid prepending "-l". |
| 1845 | argv.appendAssumeCapacity(lib_info.path); | 1845 | argv.appendAssumeCapacity(lib_info.path.?); |
| 1846 | } | 1846 | } |
| 1847 | 1847 | ||
| 1848 | if (!as_needed) { | 1848 | if (!as_needed) { |
src/link/MachO/zld.zig+1-1| ... | @@ -3554,7 +3554,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr | ... | @@ -3554,7 +3554,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr |
| 3554 | { | 3554 | { |
| 3555 | const vals = options.system_libs.values(); | 3555 | const vals = options.system_libs.values(); |
| 3556 | try libs.ensureUnusedCapacity(vals.len); | 3556 | try libs.ensureUnusedCapacity(vals.len); |
| 3557 | for (vals) |v| libs.putAssumeCapacity(v.path, v); | 3557 | for (vals) |v| libs.putAssumeCapacity(v.path.?, v); |
| 3558 | } | 3558 | } |
| 3559 | 3559 | ||
| 3560 | try MachO.resolveLibSystem(arena, comp, options.sysroot, target, options.lib_dirs, &libs); | 3560 | try MachO.resolveLibSystem(arena, comp, options.sysroot, target, options.lib_dirs, &libs); |