authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-25 20:52:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-25 20:52:02-07:00
loga337046832b936d912b6902e331cb58bdc513a2d
tree2475300223038682fad3477d5e59473b78992a5b
parentaded86e6909e01dfb45b35204e9dedf6aabb3d58

stage2: properly handle zig cc used as a preprocessor

This cleans up how the CLI parses and handles -E, -S, and -c. Compilation explicitly acknowledges when it is being used to do C preprocessing. -S is properly translated to -fno-emit-bin -femit-asm but Compilation does not yet handle -femit-asm. There is not yet a mechanism for skipping the linking step when there is only a single object file, and so to make this work we have to do a file copy in link.flush() to copy the file from zig-cache into the output directory.

7 files changed, 130 insertions(+), 87 deletions(-)

BRANCH_TODO+1-3
......@@ -1,5 +1,3 @@
1 * make sure that `zig cc -o hello hello.c -target native-native-musl` and `zig build-exe hello.zig -lc -target native-native-musl` will share the same libc build.
2 * zig cc as a preprocessor (-E)
31 * tests passing with -Dskip-non-native
42 * `-ftime-report`
53 * -fstack-report print stack size diagnostics\n"
......@@ -20,6 +18,7 @@
2018 * restore error messages for stage2_add_link_lib
2119 * windows CUSTOMBUILD : error : unable to build compiler_rt: FileNotFound [D:\a\1\s\build\zig_install_lib_files.vcxproj]
2220 * try building some software with zig cc
21 * implement support for -femit-asm
2322
2423 * implement proper parsing of clang stderr/stdout and exposing compile errors with the Compilation API
2524 * implement proper parsing of LLD stderr/stdout and exposing compile errors with the Compilation API
......@@ -57,4 +56,3 @@
5756 * make std.Progress support multithreaded
5857 * update musl.zig static data to use native path separator in static data rather than replacing '/' at runtime
5958 * linking hello world with LLD, lld is silently calling exit(1) instead of reporting ok=false. when run standalone the error message is: ld.lld: error: section [index 3] has a sh_offset (0x57000) + sh_size (0x68) that is greater than the file size (0x57060)
60
src/Compilation.zig+28-10
......@@ -49,6 +49,7 @@ sanitize_c: bool,
4949/// Otherwise we attempt to parse the error messages and expose them via the Compilation API.
5050/// This is `true` for `zig cc`, `zig c++`, and `zig translate-c`.
5151clang_passthrough_mode: bool,
52clang_preprocessor_mode: ClangPreprocessorMode,
5253/// Whether to print clang argvs to stdout.
5354verbose_cc: bool,
5455verbose_tokenize: bool,
......@@ -271,6 +272,14 @@ pub const EmitLoc = struct {
271272 basename: []const u8,
272273};
273274
275pub const ClangPreprocessorMode = enum {
276 no,
277 /// This means we are doing `zig cc -E -o <path>`.
278 yes,
279 /// This means we are doing `zig cc -E`.
280 stdout,
281};
282
274283pub const InitOptions = struct {
275284 zig_lib_directory: Directory,
276285 local_cache_directory: Directory,
......@@ -285,6 +294,8 @@ pub const InitOptions = struct {
285294 emit_bin: ?EmitLoc,
286295 /// `null` means to not emit a C header file.
287296 emit_h: ?EmitLoc = null,
297 /// `null` means to not emit assembly.
298 emit_asm: ?EmitLoc = null,
288299 link_mode: ?std.builtin.LinkMode = null,
289300 dll_export_fns: ?bool = false,
290301 /// Normally when using LLD to link, Zig uses a file named "lld.id" in the
......@@ -349,6 +360,7 @@ pub const InitOptions = struct {
349360 version: ?std.builtin.Version = null,
350361 libc_installation: ?*const LibCInstallation = null,
351362 machine_code_model: std.builtin.CodeModel = .default,
363 clang_preprocessor_mode: ClangPreprocessorMode = .no,
352364 /// This is for stage1 and should be deleted upon completion of self-hosting.
353365 color: @import("main.zig").Color = .Auto,
354366 test_filter: ?[]const u8 = null,
......@@ -478,6 +490,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
478490 } else must_pic;
479491
480492 if (options.emit_h != null) fatal("-femit-h not supported yet", .{}); // TODO
493 if (options.emit_asm != null) fatal("-femit-asm not supported yet", .{}); // TODO
481494
482495 const emit_bin = options.emit_bin orelse fatal("-fno-emit-bin not supported yet", .{}); // TODO
483496
......@@ -750,6 +763,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
750763 .sanitize_c = sanitize_c,
751764 .rand = options.rand,
752765 .clang_passthrough_mode = options.clang_passthrough_mode,
766 .clang_preprocessor_mode = options.clang_preprocessor_mode,
753767 .verbose_cc = options.verbose_cc,
754768 .verbose_tokenize = options.verbose_tokenize,
755769 .verbose_ast = options.verbose_ast,
......@@ -1215,7 +1229,6 @@ fn obtainCObjectCacheManifest(comp: *Compilation) Cache.Manifest {
12151229 // Only things that need to be added on top of the base hash, and only things
12161230 // that apply both to @cImport and compiling C objects. No linking stuff here!
12171231 // Also nothing that applies only to compiling .zig code.
1218
12191232 man.hash.add(comp.sanitize_c);
12201233 man.hash.addListOfBytes(comp.clang_argv);
12211234 man.hash.add(comp.bin_file.options.link_libcpp);
......@@ -1381,6 +1394,8 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
13811394 var man = comp.obtainCObjectCacheManifest();
13821395 defer man.deinit();
13831396
1397 man.hash.add(comp.clang_preprocessor_mode);
1398
13841399 _ = try man.addFile(c_object.src.src_path, null);
13851400 {
13861401 // Hash the extra flags, with special care to call addFile for file parameters.
......@@ -1424,7 +1439,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
14241439 var zig_cache_tmp_dir = try comp.local_cache_directory.handle.makeOpenPath("tmp", .{});
14251440 defer zig_cache_tmp_dir.close();
14261441
1427 try argv.appendSlice(&[_][]const u8{ self_exe_path, "clang", "-c" });
1442 try argv.appendSlice(&[_][]const u8{ self_exe_path, "clang" });
14281443
14291444 const ext = classifyFileExt(c_object.src.src_path);
14301445 const out_dep_path: ?[]const u8 = if (comp.disable_c_depfile or !ext.clangSupportsDepFile())
......@@ -1433,8 +1448,12 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
14331448 try std.fmt.allocPrint(arena, "{}.d", .{out_obj_path});
14341449 try comp.addCCArgs(arena, &argv, ext, out_dep_path);
14351450
1436 try argv.append("-o");
1437 try argv.append(out_obj_path);
1451 try argv.ensureCapacity(argv.items.len + 3);
1452 switch (comp.clang_preprocessor_mode) {
1453 .no => argv.appendSliceAssumeCapacity(&[_][]const u8{"-c", "-o", out_obj_path}),
1454 .yes => argv.appendSliceAssumeCapacity(&[_][]const u8{"-E", "-o", out_obj_path}),
1455 .stdout => argv.appendAssumeCapacity("-E"),
1456 }
14381457
14391458 try argv.append(c_object.src.src_path);
14401459 try argv.appendSlice(c_object.src.extra_flags);
......@@ -1460,6 +1479,8 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
14601479 // TODO https://github.com/ziglang/zig/issues/6342
14611480 std.process.exit(1);
14621481 }
1482 if (comp.clang_preprocessor_mode == .stdout)
1483 std.process.exit(0);
14631484 },
14641485 else => std.process.exit(1),
14651486 }
......@@ -1522,14 +1543,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
15221543 break :blk digest;
15231544 };
15241545
1525 const components = if (comp.local_cache_directory.path) |p|
1526 &[_][]const u8{ p, "o", &digest, o_basename }
1527 else
1528 &[_][]const u8{ "o", &digest, o_basename };
1529
15301546 c_object.status = .{
15311547 .success = .{
1532 .object_path = try std.fs.path.join(comp.gpa, components),
1548 .object_path = try comp.local_cache_directory.join(comp.gpa, &[_][]const u8{
1549 "o", &digest, o_basename,
1550 }),
15331551 .lock = man.toOwnedLock(),
15341552 },
15351553 };
src/clang_options_data.zig+9-5
......@@ -7,7 +7,7 @@ flagpd1("CC"),
77.{
88 .name = "E",
99 .syntax = .flag,
10 .zig_equivalent = .pp_or_asm,
10 .zig_equivalent = .preprocess_only,
1111 .pd1 = true,
1212 .pd2 = false,
1313 .psl = false,
......@@ -95,7 +95,7 @@ flagpd1("Qy"),
9595.{
9696 .name = "S",
9797 .syntax = .flag,
98 .zig_equivalent = .pp_or_asm,
98 .zig_equivalent = .asm_only,
9999 .pd1 = true,
100100 .pd2 = false,
101101 .psl = false,
......@@ -196,7 +196,7 @@ sepd1("Zlinker-input"),
196196.{
197197 .name = "E",
198198 .syntax = .flag,
199 .zig_equivalent = .pp_or_asm,
199 .zig_equivalent = .preprocess_only,
200200 .pd1 = true,
201201 .pd2 = false,
202202 .psl = true,
......@@ -1477,7 +1477,7 @@ flagpsl("MT"),
14771477.{
14781478 .name = "assemble",
14791479 .syntax = .flag,
1480 .zig_equivalent = .pp_or_asm,
1480 .zig_equivalent = .asm_only,
14811481 .pd1 = false,
14821482 .pd2 = true,
14831483 .psl = false,
......@@ -1805,7 +1805,7 @@ flagpsl("MT"),
18051805.{
18061806 .name = "preprocess",
18071807 .syntax = .flag,
1808 .zig_equivalent = .pp_or_asm,
1808 .zig_equivalent = .preprocess_only,
18091809 .pd1 = false,
18101810 .pd2 = true,
18111811 .psl = false,
......@@ -3406,6 +3406,8 @@ flagpd1("mlong-double-128"),
34063406flagpd1("mlong-double-64"),
34073407flagpd1("mlong-double-80"),
34083408flagpd1("mlongcall"),
3409flagpd1("mlvi-cfi"),
3410flagpd1("mlvi-hardening"),
34093411flagpd1("mlwp"),
34103412flagpd1("mlzcnt"),
34113413flagpd1("mmadd4"),
......@@ -3499,6 +3501,8 @@ flagpd1("mno-ldc1-sdc1"),
34993501flagpd1("mno-local-sdata"),
35003502flagpd1("mno-long-calls"),
35013503flagpd1("mno-longcall"),
3504flagpd1("mno-lvi-cfi"),
3505flagpd1("mno-lvi-hardening"),
35023506flagpd1("mno-lwp"),
35033507flagpd1("mno-lzcnt"),
35043508flagpd1("mno-madd4"),
src/link.zig+19-2
......@@ -1,16 +1,18 @@
11const std = @import("std");
22const mem = std.mem;
33const Allocator = std.mem.Allocator;
4const fs = std.fs;
5const log = std.log.scoped(.link);
6const assert = std.debug.assert;
7
48const Compilation = @import("Compilation.zig");
59const Module = @import("Module.zig");
6const fs = std.fs;
710const trace = @import("tracy.zig").trace;
811const Package = @import("Package.zig");
912const Type = @import("type.zig").Type;
1013const Cache = @import("Cache.zig");
1114const build_options = @import("build_options");
1215const LibCInstallation = @import("libc_installation.zig").LibCInstallation;
13const log = std.log.scoped(.link);
1416
1517pub const producer_string = if (std.builtin.is_test) "zig test" else "zig " ++ build_options.version;
1618
......@@ -303,6 +305,21 @@ pub const File = struct {
303305 /// Commit pending changes and write headers. Takes into account final output mode
304306 /// and `use_lld`, not only `effectiveOutputMode`.
305307 pub fn flush(base: *File, comp: *Compilation) !void {
308 if (comp.clang_preprocessor_mode == .yes) {
309 // TODO: avoid extra link step when it's just 1 object file (the `zig cc -c` case)
310 // Until then, we do `lld -r -o output.o input.o` even though the output is the same
311 // as the input. For the preprocessing case (`zig cc -E -o foo`) we copy the file
312 // to the final location.
313 const full_out_path = try base.options.directory.join(comp.gpa, &[_][]const u8{
314 base.options.sub_path,
315 });
316 defer comp.gpa.free(full_out_path);
317 assert(comp.c_object_table.count() == 1);
318 const the_entry = comp.c_object_table.items()[0];
319 const cached_pp_file_path = the_entry.key.status.success.object_path;
320 try fs.cwd().copyFile(cached_pp_file_path, fs.cwd(), full_out_path, .{});
321 return;
322 }
306323 const use_lld = build_options.have_llvm and base.options.use_lld;
307324 if (use_lld and base.options.output_mode == .Lib and base.options.link_mode == .Static and
308325 !base.options.target.isWasm())
src/link/Elf.zig+1-4
......@@ -1401,10 +1401,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
14011401 try argv.append("-pie");
14021402 }
14031403
1404 const full_out_path = if (directory.path) |dir_path|
1405 try fs.path.join(arena, &[_][]const u8{dir_path, self.base.options.sub_path})
1406 else
1407 self.base.options.sub_path;
1404 const full_out_path = try directory.join(arena, &[_][]const u8{self.base.options.sub_path});
14081405 try argv.append("-o");
14091406 try argv.append(full_out_path);
14101407
src/main.zig+54-45
......@@ -327,6 +327,7 @@ pub fn buildOutputType(
327327 var time_report = false;
328328 var show_builtin = false;
329329 var emit_bin: Emit = .yes_default_path;
330 var emit_asm: Emit = .no;
330331 var emit_zir: Emit = .no;
331332 var target_arch_os_abi: []const u8 = "native";
332333 var target_mcpu: ?[]const u8 = null;
......@@ -345,7 +346,6 @@ pub fn buildOutputType(
345346 var want_stack_check: ?bool = null;
346347 var want_valgrind: ?bool = null;
347348 var rdynamic: bool = false;
348 var only_pp_or_asm = false;
349349 var linker_script: ?[]const u8 = null;
350350 var version_script: ?[]const u8 = null;
351351 var disable_c_depfile = false;
......@@ -371,6 +371,7 @@ pub fn buildOutputType(
371371 var override_global_cache_dir: ?[]const u8 = null;
372372 var override_lib_dir: ?[]const u8 = null;
373373 var main_pkg_path: ?[]const u8 = null;
374 var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no;
374375
375376 var system_libs = std.ArrayList([]const u8).init(gpa);
376377 defer system_libs.deinit();
......@@ -752,7 +753,14 @@ pub fn buildOutputType(
752753 ensure_libcpp_on_non_freestanding = arg_mode == .cpp;
753754 want_native_include_dirs = true;
754755
755 var c_arg = false;
756 const COutMode = enum {
757 link,
758 object,
759 assembly,
760 preprocessor,
761 };
762 var c_out_mode: COutMode = .link;
763 var out_path: ?[]const u8 = null;
756764 var is_shared_lib = false;
757765 var linker_args = std.ArrayList([]const u8).init(arena);
758766 var it = ClangArgIterator.init(arena, all_args);
......@@ -762,12 +770,10 @@ pub fn buildOutputType(
762770 };
763771 switch (it.zig_equivalent) {
764772 .target => target_arch_os_abi = it.only_arg, // example: -target riscv64-linux-unknown
765 .o => {
766 // -o
767 emit_bin = .{ .yes = it.only_arg };
768 enable_cache = true;
769 },
770 .c => c_arg = true, // -c
773 .o => out_path = it.only_arg, // -o
774 .c => c_out_mode = .object, // -c
775 .asm_only => c_out_mode = .assembly, // -S
776 .preprocess_only => c_out_mode = .preprocessor, // -E
771777 .other => {
772778 try clang_argv.appendSlice(it.other_args);
773779 },
......@@ -813,11 +819,6 @@ pub fn buildOutputType(
813819 try linker_args.append(linker_arg);
814820 }
815821 },
816 .pp_or_asm => {
817 // This handles both -E and -S.
818 only_pp_or_asm = true;
819 try clang_argv.appendSlice(it.other_args);
820 },
821822 .optimize => {
822823 // Alright, what release mode do they want?
823824 if (mem.eql(u8, it.only_arg, "Os")) {
......@@ -999,32 +1000,43 @@ pub fn buildOutputType(
9991000 }
10001001 }
10011002
1002 if (only_pp_or_asm) {
1003 output_mode = .Obj;
1004 fatal("TODO implement using zig cc as a preprocessor", .{});
1005 //// Transfer "link_objects" into c_source_files so that all those
1006 //// args make it onto the command line.
1007 //try c_source_files.appendSlice(link_objects.items);
1008 //for (c_source_files.items) |c_source_file| {
1009 // const src_path = switch (emit_bin) {
1010 // .yes => |p| p,
1011 // else => c_source_file.source_path,
1012 // };
1013 // const basename = fs.path.basename(src_path);
1014 // c_source_file.preprocessor_only_basename = basename;
1015 //}
1016 //emit_bin = .no;
1017 } else if (!c_arg) {
1018 output_mode = if (is_shared_lib) .Lib else .Exe;
1019 switch (emit_bin) {
1020 .no, .yes_default_path => {
1021 emit_bin = .{ .yes = "a.out" };
1022 enable_cache = true;
1023 },
1024 .yes => {},
1025 }
1026 } else {
1027 output_mode = .Obj;
1003 switch (c_out_mode) {
1004 .link => {
1005 output_mode = if (is_shared_lib) .Lib else .Exe;
1006 emit_bin = .{ .yes = out_path orelse "a.out" };
1007 enable_cache = true;
1008 },
1009 .object => {
1010 output_mode = .Obj;
1011 if (out_path) |p| {
1012 emit_bin = .{ .yes = p };
1013 } else {
1014 emit_bin = .yes_default_path;
1015 }
1016 },
1017 .assembly => {
1018 output_mode = .Obj;
1019 emit_bin = .no;
1020 if (out_path) |p| {
1021 emit_asm = .{ .yes = p };
1022 } else {
1023 emit_asm = .yes_default_path;
1024 }
1025 },
1026 .preprocessor => {
1027 output_mode = .Obj;
1028 // An error message is generated when there is more than 1 C source file.
1029 if (c_source_files.items.len != 1) {
1030 // For example `zig cc` and no args should print the "no input files" message.
1031 return punt_to_clang(arena, all_args);
1032 }
1033 if (out_path) |p| {
1034 emit_bin = .{ .yes = p };
1035 clang_preprocessor_mode = .yes;
1036 } else {
1037 clang_preprocessor_mode = .stdout;
1038 }
1039 },
10281040 }
10291041 if (c_source_files.items.len == 0 and link_objects.items.len == 0) {
10301042 // For example `zig cc` and no args should print the "no input files" message.
......@@ -1407,6 +1419,7 @@ pub fn buildOutputType(
14071419 .self_exe_path = self_exe_path,
14081420 .rand = &default_prng.random,
14091421 .clang_passthrough_mode = arg_mode != .build,
1422 .clang_preprocessor_mode = clang_preprocessor_mode,
14101423 .version = optional_version,
14111424 .libc_installation = if (libc_installation) |*lci| lci else null,
14121425 .verbose_cc = verbose_cc,
......@@ -1453,11 +1466,6 @@ pub fn buildOutputType(
14531466
14541467 try updateModule(gpa, comp, zir_out_path, hook);
14551468
1456 if (build_options.have_llvm and only_pp_or_asm) {
1457 // this may include dumping the output to stdout
1458 fatal("TODO: implement `zig cc` when using it as a preprocessor", .{});
1459 }
1460
14611469 if (build_options.is_stage1 and comp.stage1_lock != null and watch) {
14621470 std.log.warn("--watch is not recommended with the stage1 backend; it leaks memory and is not capable of incremental compilation", .{});
14631471 }
......@@ -2436,7 +2444,8 @@ pub const ClangArgIterator = struct {
24362444 shared,
24372445 rdynamic,
24382446 wl,
2439 pp_or_asm,
2447 preprocess_only,
2448 asm_only,
24402449 optimize,
24412450 debug,
24422451 sanitize,
tools/update_clang_options.zig+18-18
......@@ -116,19 +116,19 @@ const known_options = [_]KnownOpt{
116116 },
117117 .{
118118 .name = "E",
119 .ident = "pp_or_asm",
119 .ident = "preprocess_only",
120120 },
121121 .{
122122 .name = "preprocess",
123 .ident = "pp_or_asm",
123 .ident = "preprocess_only",
124124 },
125125 .{
126126 .name = "S",
127 .ident = "pp_or_asm",
127 .ident = "asm_only",
128128 },
129129 .{
130130 .name = "assemble",
131 .ident = "pp_or_asm",
131 .ident = "asm_only",
132132 },
133133 .{
134134 .name = "O1",
......@@ -346,7 +346,7 @@ pub fn main() anyerror!void {
346346 for (blacklisted_options) |blacklisted_key| {
347347 if (std.mem.eql(u8, blacklisted_key, kv.key)) continue :it_map;
348348 }
349 if (kv.value.Object.get("Name").?.value.String.len == 0) continue;
349 if (kv.value.Object.get("Name").?.String.len == 0) continue;
350350 try all_objects.append(&kv.value.Object);
351351 }
352352 }
......@@ -365,11 +365,11 @@ pub fn main() anyerror!void {
365365 );
366366
367367 for (all_objects.span()) |obj| {
368 const name = obj.get("Name").?.value.String;
368 const name = obj.get("Name").?.String;
369369 var pd1 = false;
370370 var pd2 = false;
371371 var pslash = false;
372 for (obj.get("Prefixes").?.value.Array.span()) |prefix_json| {
372 for (obj.get("Prefixes").?.Array.span()) |prefix_json| {
373373 const prefix = prefix_json.String;
374374 if (std.mem.eql(u8, prefix, "-")) {
375375 pd1 = true;
......@@ -465,7 +465,7 @@ const Syntax = union(enum) {
465465 self: Syntax,
466466 comptime fmt: []const u8,
467467 options: std.fmt.FormatOptions,
468 out_stream: var,
468 out_stream: anytype,
469469 ) !void {
470470 switch (self) {
471471 .multi_arg => |n| return out_stream.print(".{{.{}={}}}", .{ @tagName(self), n }),
......@@ -475,8 +475,8 @@ const Syntax = union(enum) {
475475};
476476
477477fn objSyntax(obj: *json.ObjectMap) Syntax {
478 const num_args = @intCast(u8, obj.get("NumArgs").?.value.Integer);
479 for (obj.get("!superclasses").?.value.Array.span()) |superclass_json| {
478 const num_args = @intCast(u8, obj.get("NumArgs").?.Integer);
479 for (obj.get("!superclasses").?.Array.span()) |superclass_json| {
480480 const superclass = superclass_json.String;
481481 if (std.mem.eql(u8, superclass, "Joined")) {
482482 return .joined;
......@@ -510,19 +510,19 @@ fn objSyntax(obj: *json.ObjectMap) Syntax {
510510 return .{ .multi_arg = num_args };
511511 }
512512 }
513 const name = obj.get("Name").?.value.String;
513 const name = obj.get("Name").?.String;
514514 if (std.mem.eql(u8, name, "<input>")) {
515515 return .flag;
516516 } else if (std.mem.eql(u8, name, "<unknown>")) {
517517 return .flag;
518518 }
519 const kind_def = obj.get("Kind").?.value.Object.get("def").?.value.String;
519 const kind_def = obj.get("Kind").?.Object.get("def").?.String;
520520 if (std.mem.eql(u8, kind_def, "KIND_FLAG")) {
521521 return .flag;
522522 }
523 const key = obj.get("!name").?.value.String;
523 const key = obj.get("!name").?.String;
524524 std.debug.warn("{} (key {}) has unrecognized superclasses:\n", .{ name, key });
525 for (obj.get("!superclasses").?.value.Array.span()) |superclass_json| {
525 for (obj.get("!superclasses").?.Array.span()) |superclass_json| {
526526 std.debug.warn(" {}\n", .{superclass_json.String});
527527 }
528528 std.process.exit(1);
......@@ -560,15 +560,15 @@ fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {
560560 }
561561
562562 if (!a_match_with_eql and !b_match_with_eql) {
563 const a_name = a.get("Name").?.value.String;
564 const b_name = b.get("Name").?.value.String;
563 const a_name = a.get("Name").?.String;
564 const b_name = b.get("Name").?.String;
565565 if (a_name.len != b_name.len) {
566566 return a_name.len > b_name.len;
567567 }
568568 }
569569
570 const a_key = a.get("!name").?.value.String;
571 const b_key = b.get("!name").?.value.String;
570 const a_key = a.get("!name").?.String;
571 const b_key = b.get("!name").?.String;
572572 return std.mem.lessThan(u8, a_key, b_key);
573573}
574574