mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
frontend: make SystemLib.path optional
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.
This commit is contained in:
parent
e565ff305a
commit
986a3d23ab
4 changed files with 10 additions and 6 deletions
|
|
@ -1728,7 +1728,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
|
|||
try comp.bin_file.options.system_libs.put(comp.gpa, name, .{
|
||||
.needed = false,
|
||||
.weak = false,
|
||||
.path = name,
|
||||
.path = null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -5621,7 +5621,7 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
|
|||
gop.value_ptr.* = .{
|
||||
.needed = true,
|
||||
.weak = false,
|
||||
.path = undefined,
|
||||
.path = null,
|
||||
};
|
||||
try comp.work_queue.writeItem(.{
|
||||
.windows_import_lib = comp.bin_file.options.system_libs.count() - 1,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@ const TypedValue = @import("TypedValue.zig");
|
|||
pub const SystemLib = struct {
|
||||
needed: bool,
|
||||
weak: bool,
|
||||
path: []const u8,
|
||||
/// 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.
|
||||
path: ?[]const u8,
|
||||
};
|
||||
|
||||
/// When adding a new field, remember to update `hashAddFrameworks`.
|
||||
|
|
@ -48,7 +52,7 @@ pub fn hashAddSystemLibs(
|
|||
for (hm.values()) |value| {
|
||||
man.hash.add(value.needed);
|
||||
man.hash.add(value.weak);
|
||||
_ = try man.addFile(value.path, null);
|
||||
if (value.path) |p| _ = try man.addFile(p, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1842,7 +1842,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
|
|||
// libraries and not static libraries (the check for that needs to be earlier),
|
||||
// but they could be full paths to .so files, in which case we
|
||||
// want to avoid prepending "-l".
|
||||
argv.appendAssumeCapacity(lib_info.path);
|
||||
argv.appendAssumeCapacity(lib_info.path.?);
|
||||
}
|
||||
|
||||
if (!as_needed) {
|
||||
|
|
|
|||
|
|
@ -3554,7 +3554,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr
|
|||
{
|
||||
const vals = options.system_libs.values();
|
||||
try libs.ensureUnusedCapacity(vals.len);
|
||||
for (vals) |v| libs.putAssumeCapacity(v.path, v);
|
||||
for (vals) |v| libs.putAssumeCapacity(v.path.?, v);
|
||||
}
|
||||
|
||||
try MachO.resolveLibSystem(arena, comp, options.sysroot, target, options.lib_dirs, &libs);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue