Skip to content

Commit

Permalink
clang: update cmdline options to include weak libs and frameworks
Browse files Browse the repository at this point in the history
Clang accepts `-weak-lx`, `-weak_library x` and `-weak_framework x`.
  • Loading branch information
kubkon authored and andrewrk committed Jul 19, 2022
1 parent 36dc0a3 commit a848144
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/clang_options_data.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4867,8 +4867,22 @@ flagpd1("version"),
.psl = false,
},
flagpd1("w"),
sepd1("weak_framework"),
sepd1("weak_library"),
.{
.name = "weak_framework",
.syntax = .separate,
.zig_equivalent = .weak_framework,
.pd1 = true,
.pd2 = false,
.psl = false,
},
.{
.name = "weak_library",
.syntax = .separate,
.zig_equivalent = .weak_library,
.pd1 = true,
.pd2 = false,
.psl = false,
},
sepd1("weak_reference_mismatches"),
flagpd1("whatsloaded"),
flagpd1("why_load"),
Expand Down Expand Up @@ -6200,7 +6214,14 @@ jspd1("iquote"),
.pd2 = true,
.psl = false,
},
joinpd1("weak-l"),
.{
.name = "weak-l",
.syntax = .joined,
.zig_equivalent = .weak_library,
.pd1 = true,
.pd2 = false,
.psl = false,
},
.{
.name = "Ofast",
.syntax = .flag,
Expand Down
4 changes: 4 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,8 @@ fn buildOutputType(
.entry => {
entry = it.only_arg;
},
.weak_library => try system_libs.put(it.only_arg, .{ .weak = true }),
.weak_framework => try frameworks.put(gpa, it.only_arg, .{ .weak = true }),
}
}
// Parse linker args.
Expand Down Expand Up @@ -4577,6 +4579,8 @@ pub const ClangArgIterator = struct {
emit_llvm,
sysroot,
entry,
weak_library,
weak_framework,
};

const Args = struct {
Expand Down
12 changes: 12 additions & 0 deletions tools/update_clang_options.zig
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,18 @@ const known_options = [_]KnownOpt{
.name = "e",
.ident = "entry",
},
.{
.name = "weak-l",
.ident = "weak_library",
},
.{
.name = "weak_library",
.ident = "weak_library",
},
.{
.name = "weak_framework",
.ident = "weak_framework",
},
};

const blacklisted_options = [_][]const u8{};
Expand Down

0 comments on commit a848144

Please sign in to comment.