authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-06-29 07:56:21+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-06-29 07:56:21+02:00
logbb3e1bcf31bdf9306030e797ed673021c7766d58
tree9f69c650687742302e1a7a4760018439ad27680a
parent41533fa6a1fa5e9e9b38a59403930501fd61a259
parentc2c1998269f8a92e39c14dabb68b253c012d56ef
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #11954 from ziglang/fixes-weak-l

macho: weak libraries and frameworks fixes

4 files changed, 42 insertions(+), 3 deletions(-)

src/clang_options_data.zig+24-3
......@@ -4867,8 +4867,22 @@ flagpd1("version"),
48674867 .psl = false,
48684868},
48694869flagpd1("w"),
4870sepd1("weak_framework"),
4871sepd1("weak_library"),
4870.{
4871 .name = "weak_framework",
4872 .syntax = .separate,
4873 .zig_equivalent = .weak_framework,
4874 .pd1 = true,
4875 .pd2 = false,
4876 .psl = false,
4877},
4878.{
4879 .name = "weak_library",
4880 .syntax = .separate,
4881 .zig_equivalent = .weak_library,
4882 .pd1 = true,
4883 .pd2 = false,
4884 .psl = false,
4885},
48724886sepd1("weak_reference_mismatches"),
48734887flagpd1("whatsloaded"),
48744888flagpd1("why_load"),
......@@ -6200,7 +6214,14 @@ jspd1("iquote"),
62006214 .pd2 = true,
62016215 .psl = false,
62026216},
6203joinpd1("weak-l"),
6217.{
6218 .name = "weak-l",
6219 .syntax = .joined,
6220 .zig_equivalent = .weak_library,
6221 .pd1 = true,
6222 .pd2 = false,
6223 .psl = false,
6224},
62046225.{
62056226 .name = "Ofast",
62066227 .syntax = .flag,
src/link.zig+2
......@@ -19,6 +19,7 @@ const Package = @import("Package.zig");
1919const Type = @import("type.zig").Type;
2020const TypedValue = @import("TypedValue.zig");
2121
22/// When adding a new field, remember to update `hashAddSystemLibs`.
2223pub const SystemLib = struct {
2324 needed: bool = false,
2425 weak: bool = false,
......@@ -35,6 +36,7 @@ pub fn hashAddSystemLibs(
3536 hh.addListOfBytes(keys);
3637 for (hm.values()) |value| {
3738 hh.add(value.needed);
39 hh.add(value.weak);
3840 }
3941}
4042
src/main.zig+4
......@@ -1625,6 +1625,8 @@ fn buildOutputType(
16251625 .entry => {
16261626 entry = it.only_arg;
16271627 },
1628 .weak_library => try system_libs.put(it.only_arg, .{ .weak = true }),
1629 .weak_framework => try frameworks.put(gpa, it.only_arg, .{ .weak = true }),
16281630 }
16291631 }
16301632 // Parse linker args.
......@@ -4577,6 +4579,8 @@ pub const ClangArgIterator = struct {
45774579 emit_llvm,
45784580 sysroot,
45794581 entry,
4582 weak_library,
4583 weak_framework,
45804584 };
45814585
45824586 const Args = struct {
tools/update_clang_options.zig+12
......@@ -432,6 +432,18 @@ const known_options = [_]KnownOpt{
432432 .name = "e",
433433 .ident = "entry",
434434 },
435 .{
436 .name = "weak-l",
437 .ident = "weak_library",
438 },
439 .{
440 .name = "weak_library",
441 .ident = "weak_library",
442 },
443 .{
444 .name = "weak_framework",
445 .ident = "weak_framework",
446 },
435447};
436448
437449const blacklisted_options = [_][]const u8{};