| author | |
| committer | |
| log | 0c1d610015e04c96508750e95b2f88408ded8843 |
| tree | cfead197cc965d08f0d618d730b645123add2809 |
| parent | de8e6124557d189d8b55f0d63d0a02fb98d51799 |
and transfer them correctly to the generated dylib as part of the dylib
id load command.4 files changed, 28 insertions(+), 3 deletions(-)
src/Compilation.zig+2| ... | ... | @@ -758,6 +758,7 @@ pub const InitOptions = struct { |
| 758 | 758 | image_base_override: ?u64 = null, |
| 759 | 759 | self_exe_path: ?[]const u8 = null, |
| 760 | 760 | version: ?std.builtin.Version = null, |
| 761 | compatibility_version: ?std.builtin.Version = null, | |
| 761 | 762 | libc_installation: ?*const LibCInstallation = null, |
| 762 | 763 | machine_code_model: std.builtin.CodeModel = .default, |
| 763 | 764 | clang_preprocessor_mode: ClangPreprocessorMode = .no, |
| ... | ... | @@ -1439,6 +1440,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 1439 | 1440 | .extra_lld_args = options.lld_argv, |
| 1440 | 1441 | .soname = options.soname, |
| 1441 | 1442 | .version = options.version, |
| 1443 | .compatibility_version = options.compatibility_version, | |
| 1442 | 1444 | .libc_installation = libc_dirs.libc_installation, |
| 1443 | 1445 | .pic = pic, |
| 1444 | 1446 | .pie = pie, |
src/link.zig+1| ... | ... | @@ -143,6 +143,7 @@ pub const Options = struct { |
| 143 | 143 | rpath_list: []const []const u8, |
| 144 | 144 | |
| 145 | 145 | version: ?std.builtin.Version, |
| 146 | compatibility_version: ?std.builtin.Version, | |
| 146 | 147 | libc_installation: ?*const LibCInstallation, |
| 147 | 148 | |
| 148 | 149 | /// WASI-only. Type of WASI execution model ("command" or "reactor"). |
src/link/MachO.zig+6-2| ... | ... | @@ -4038,12 +4038,16 @@ pub fn populateMissingMetadata(self: *MachO) !void { |
| 4038 | 4038 | self.base.options.emit.?.sub_path, |
| 4039 | 4039 | }); |
| 4040 | 4040 | defer self.base.allocator.free(install_name); |
| 4041 | const current_version = self.base.options.version orelse | |
| 4042 | std.builtin.Version{ .major = 1, .minor = 0, .patch = 0 }; | |
| 4043 | const compat_version = self.base.options.compatibility_version orelse | |
| 4044 | std.builtin.Version{ .major = 1, .minor = 0, .patch = 0 }; | |
| 4041 | 4045 | var dylib_cmd = try commands.createLoadDylibCommand( |
| 4042 | 4046 | self.base.allocator, |
| 4043 | 4047 | install_name, |
| 4044 | 4048 | 2, |
| 4045 | 0x10000, // TODO forward user-provided versions | |
| 4046 | 0x10000, | |
| 4049 | current_version.major << 16 | current_version.minor << 8 | current_version.patch, | |
| 4050 | compat_version.major << 16 | compat_version.minor << 8 | compat_version.patch, | |
| 4047 | 4051 | ); |
| 4048 | 4052 | errdefer dylib_cmd.deinit(self.base.allocator); |
| 4049 | 4053 | dylib_cmd.inner.cmd = macho.LC_ID_DYLIB; |
src/main.zig+19-1| ... | ... | @@ -564,6 +564,7 @@ fn buildOutputType( |
| 564 | 564 | var root_src_file: ?[]const u8 = null; |
| 565 | 565 | var version: std.builtin.Version = .{ .major = 0, .minor = 0, .patch = 0 }; |
| 566 | 566 | var have_version = false; |
| 567 | var compatibility_version: ?std.builtin.Version = null; | |
| 567 | 568 | var strip = false; |
| 568 | 569 | var single_threaded = false; |
| 569 | 570 | var function_sections = false; |
| ... | ... | @@ -1613,12 +1614,29 @@ fn buildOutputType( |
| 1613 | 1614 | ) catch |err| { |
| 1614 | 1615 | fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) }); |
| 1615 | 1616 | }; |
| 1616 | } else if (mem.eql(u8, arg, "-weak_framework")) { | |
| 1617 | } else if (mem.eql(u8, arg, "-framework") or mem.eql(u8, arg, "-weak_framework")) { | |
| 1617 | 1618 | i += 1; |
| 1618 | 1619 | if (i >= linker_args.items.len) { |
| 1619 | 1620 | fatal("expected linker arg after '{s}'", .{arg}); |
| 1620 | 1621 | } |
| 1621 | 1622 | try frameworks.append(linker_args.items[i]); |
| 1623 | } else if (mem.eql(u8, arg, "-compatibility_version")) { | |
| 1624 | i += 1; | |
| 1625 | if (i >= linker_args.items.len) { | |
| 1626 | fatal("expected linker arg after '{s}'", .{arg}); | |
| 1627 | } | |
| 1628 | compatibility_version = std.builtin.Version.parse(linker_args.items[i]) catch |err| { | |
| 1629 | fatal("unable to parse -compatibility_version '{s}': {s}", .{ linker_args.items[i], @errorName(err) }); | |
| 1630 | }; | |
| 1631 | } else if (mem.eql(u8, arg, "-current_version")) { | |
| 1632 | i += 1; | |
| 1633 | if (i >= linker_args.items.len) { | |
| 1634 | fatal("expected linker arg after '{s}'", .{arg}); | |
| 1635 | } | |
| 1636 | version = std.builtin.Version.parse(linker_args.items[i]) catch |err| { | |
| 1637 | fatal("unable to parse -current_version '{s}': {s}", .{ linker_args.items[i], @errorName(err) }); | |
| 1638 | }; | |
| 1639 | have_version = true; | |
| 1622 | 1640 | } else { |
| 1623 | 1641 | warn("unsupported linker arg: {s}", .{arg}); |
| 1624 | 1642 | } |