authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-17 23:27:24-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-17 23:27:24-07:00
loga9b18023a4c33a0563fca2aa20a239e3ee38927a
tree88a968afb4e2f56c0fff6757eb059d36c435d23b
parentdc478687d95ee0d495cd26182edae78a01db59af

stage2: implement --show-builtin

This takes the place of `zig builtin`. This is an improvement over the command because now the generated source will correctly show LinkMode and OutputMode, whereas before it was always stuck as Static and Obj, respectively.

11 files changed, 247 insertions(+), 64 deletions(-)

BRANCH_TODO+8-6
......@@ -1,9 +1,5 @@
1 * `zig builtin`
21 * `zig translate-c`
32 * `zig test`
4 * `zig run`
5 * `zig init-lib`
6 * `zig init-exe`
73 * `zig build`
84 * `-ftime-report`
95 * -fstack-report print stack size diagnostics\n"
......@@ -15,14 +11,14 @@
1511 * -femit-llvm-ir produce a .ll file with LLVM IR\n"
1612 * -fno-emit-llvm-ir (default) do not produce a .ll file with LLVM IR\n"
1713 * --cache-dir [path] override the local cache directory\n"
18 * move main.cpp to stage2
1914 * make sure zig cc works
2015 - using it as a preprocessor (-E)
2116 - try building some software
2217 * support rpaths in ELF linker code
2318 * build & link against compiler-rt
2419 - stage1 C++ code integration
25 * build & link againstn freestanding libc
20 * repair @cImport
21 * build & link against freestanding libc
2622 * add CLI support for a way to pass extra flags to c source files
2723 * capture lld stdout/stderr better
2824 * musl
......@@ -41,6 +37,9 @@
4137 * implement -fno-emit-bin
4238 * audit the base cache hash
4339 * audit the CLI options for stage2
40 * `zig init-lib`
41 * `zig init-exe`
42 * `zig run`
4443
4544 * implement serialization/deserialization of incremental compilation metadata
4645 * incremental compilation - implement detection of which source files changed
......@@ -69,3 +68,6 @@
6968 * rename src-self-hosted/ to src/
7069 * improve Directory.join to only use 1 allocation in a clean way.
7170 * tracy builds with lc++
71 * some kind of "zig identifier escape" function rather than unconditionally using @"" syntax
72 in builtin.zig
73 * rename Mode to OptimizeMode
src-self-hosted/Compilation.zig+201-18
......@@ -29,7 +29,7 @@ c_object_table: std.AutoArrayHashMapUnmanaged(*CObject, void) = .{},
2929
3030link_error_flags: link.File.ErrorFlags = .{},
3131
32work_queue: std.fifo.LinearFifo(WorkItem, .Dynamic),
32work_queue: std.fifo.LinearFifo(Job, .Dynamic),
3333
3434/// The ErrorMsg memory is owned by the `CObject`, using Compilation's general purpose allocator.
3535failed_c_objects: std.AutoArrayHashMapUnmanaged(*CObject, *ErrorMsg) = .{},
......@@ -43,8 +43,9 @@ sanitize_c: bool,
4343/// This is `true` for `zig cc`, `zig c++`, and `zig translate-c`.
4444clang_passthrough_mode: bool,
4545/// Whether to print clang argvs to stdout.
46debug_cc: bool,
46verbose_cc: bool,
4747disable_c_depfile: bool,
48is_test: bool,
4849
4950c_source_files: []const CSourceFile,
5051clang_argv: []const []const u8,
......@@ -56,16 +57,16 @@ zig_cache_directory: Directory,
5657libc_include_dir_list: []const []const u8,
5758rand: *std.rand.Random,
5859
59/// Populated when we build libc++.a. A WorkItem to build this is placed in the queue
60/// Populated when we build libc++.a. A Job to build this is placed in the queue
6061/// and resolved before calling linker.flush().
6162libcxx_static_lib: ?[]const u8 = null,
62/// Populated when we build libc++abi.a. A WorkItem to build this is placed in the queue
63/// Populated when we build libc++abi.a. A Job to build this is placed in the queue
6364/// and resolved before calling linker.flush().
6465libcxxabi_static_lib: ?[]const u8 = null,
65/// Populated when we build libunwind.a. A WorkItem to build this is placed in the queue
66/// Populated when we build libunwind.a. A Job to build this is placed in the queue
6667/// and resolved before calling linker.flush().
6768libunwind_static_lib: ?CRTFile = null,
68/// Populated when we build c.a. A WorkItem to build this is placed in the queue
69/// Populated when we build c.a. A Job to build this is placed in the queue
6970/// and resolved before calling linker.flush().
7071libc_static_lib: ?[]const u8 = null,
7172
......@@ -98,7 +99,7 @@ pub const CSourceFile = struct {
9899 extra_flags: []const []const u8 = &[0][]const u8{},
99100};
100101
101const WorkItem = union(enum) {
102const Job = union(enum) {
102103 /// Write the machine code for a Decl to the output file.
103104 codegen_decl: *Module.Decl,
104105 /// The Decl needs to be analyzed and possibly export itself.
......@@ -116,8 +117,11 @@ const WorkItem = union(enum) {
116117 glibc_crt_file: glibc.CRTFile,
117118 /// all of the glibc shared objects
118119 glibc_shared_objects,
119
120 /// libunwind.a, usually needed when linking libc
120121 libunwind: void,
122
123 /// Generate builtin.zig source code and write it into the correct place.
124 generate_builtin_zig: void,
121125};
122126
123127pub const CObject = struct {
......@@ -282,8 +286,9 @@ pub const InitOptions = struct {
282286 linker_z_nodelete: bool = false,
283287 linker_z_defs: bool = false,
284288 clang_passthrough_mode: bool = false,
285 debug_cc: bool = false,
286 debug_link: bool = false,
289 verbose_cc: bool = false,
290 verbose_link: bool = false,
291 is_test: bool = false,
287292 stack_size_override: ?u64 = null,
288293 self_exe_path: ?[]const u8 = null,
289294 version: ?std.builtin.Version = null,
......@@ -570,6 +575,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
570575 break :blk link_artifact_directory;
571576 };
572577
578 const error_return_tracing = !options.strip and switch (options.optimize_mode) {
579 .Debug, .ReleaseSafe => true,
580 .ReleaseFast, .ReleaseSmall => false,
581 };
582
573583 const bin_file = try link.File.openPath(gpa, .{
574584 .directory = bin_directory,
575585 .sub_path = emit_bin.basename,
......@@ -612,9 +622,10 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
612622 .valgrind = valgrind,
613623 .stack_check = stack_check,
614624 .single_threaded = single_threaded,
615 .debug_link = options.debug_link,
625 .verbose_link = options.verbose_link,
616626 .machine_code_model = options.machine_code_model,
617627 .dll_export_fns = dll_export_fns,
628 .error_return_tracing = error_return_tracing,
618629 });
619630 errdefer bin_file.destroy();
620631
......@@ -624,7 +635,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
624635 .zig_lib_directory = options.zig_lib_directory,
625636 .zig_cache_directory = options.zig_cache_directory,
626637 .bin_file = bin_file,
627 .work_queue = std.fifo.LinearFifo(WorkItem, .Dynamic).init(gpa),
638 .work_queue = std.fifo.LinearFifo(Job, .Dynamic).init(gpa),
628639 .keep_source_files_loaded = options.keep_source_files_loaded,
629640 .use_clang = use_clang,
630641 .clang_argv = options.clang_argv,
......@@ -635,14 +646,19 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
635646 .sanitize_c = sanitize_c,
636647 .rand = options.rand,
637648 .clang_passthrough_mode = options.clang_passthrough_mode,
638 .debug_cc = options.debug_cc,
649 .verbose_cc = options.verbose_cc,
639650 .disable_c_depfile = options.disable_c_depfile,
640651 .owned_link_dir = owned_link_dir,
652 .is_test = options.is_test,
641653 };
642654 break :comp comp;
643655 };
644656 errdefer comp.destroy();
645657
658 if (comp.bin_file.options.module) |mod| {
659 try comp.work_queue.writeItem(.{ .generate_builtin_zig = {} });
660 }
661
646662 // Add a `CObject` for each `c_source_files`.
647663 try comp.c_object_table.ensureCapacity(gpa, options.c_source_files.len);
648664 for (options.c_source_files) |c_source_file| {
......@@ -659,7 +675,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
659675 // If we need to build glibc for the target, add work items for it.
660676 // We go through the work queue so that building can be done in parallel.
661677 if (comp.wantBuildGLibCFromSource()) {
662 try comp.addBuildingGLibCWorkItems();
678 try comp.addBuildingGLibCJobs();
663679 }
664680 if (comp.wantBuildLibUnwindFromSource()) {
665681 try comp.work_queue.writeItem(.{ .libunwind = {} });
......@@ -715,7 +731,7 @@ pub fn update(self: *Compilation) !void {
715731 defer tracy.end();
716732
717733 // For compiling C objects, we rely on the cache hash system to avoid duplicating work.
718 // Add a WorkItem for each C object.
734 // Add a Job for each C object.
719735 try self.work_queue.ensureUnusedCapacity(self.c_object_table.items().len);
720736 for (self.c_object_table.items()) |entry| {
721737 self.work_queue.writeItemAssumeCapacity(.{ .c_object = entry.key });
......@@ -974,6 +990,13 @@ pub fn performAllTheWork(self: *Compilation) error{OutOfMemory}!void {
974990 fatal("unable to build libunwind: {}", .{@errorName(err)});
975991 };
976992 },
993 .generate_builtin_zig => {
994 // This Job is only queued up if there is a zig module.
995 self.updateBuiltinZigFile(self.bin_file.options.module.?) catch |err| {
996 // TODO Expose this as a normal compile error rather than crashing here.
997 fatal("unable to update builtin.zig file: {}", .{@errorName(err)});
998 };
999 },
9771000 };
9781001}
9791002
......@@ -1057,7 +1080,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject) !void {
10571080 try argv.append(c_object.src.src_path);
10581081 try argv.appendSlice(c_object.src.extra_flags);
10591082
1060 if (comp.debug_cc) {
1083 if (comp.verbose_cc) {
10611084 for (argv.items[0 .. argv.items.len - 1]) |arg| {
10621085 std.debug.print("{} ", .{arg});
10631086 }
......@@ -1616,8 +1639,8 @@ pub fn get_libc_crt_file(comp: *Compilation, arena: *Allocator, basename: []cons
16161639 return full_path;
16171640}
16181641
1619fn addBuildingGLibCWorkItems(comp: *Compilation) !void {
1620 try comp.work_queue.write(&[_]WorkItem{
1642fn addBuildingGLibCJobs(comp: *Compilation) !void {
1643 try comp.work_queue.write(&[_]Job{
16211644 .{ .glibc_crt_file = .crti_o },
16221645 .{ .glibc_crt_file = .crtn_o },
16231646 .{ .glibc_crt_file = .scrt1_o },
......@@ -1646,3 +1669,163 @@ fn wantBuildLibUnwindFromSource(comp: *Compilation) bool {
16461669 return comp.bin_file.options.link_libc and is_exe_or_dyn_lib and
16471670 comp.bin_file.options.libc_installation == null;
16481671}
1672
1673fn updateBuiltinZigFile(comp: *Compilation, mod: *Module) !void {
1674 const source = try comp.generateBuiltinZigSource();
1675 defer comp.gpa.free(source);
1676 try mod.zig_cache_artifact_directory.handle.writeFile("builtin.zig", source);
1677}
1678
1679pub fn generateBuiltinZigSource(comp: *Compilation) ![]u8 {
1680 var buffer = std.ArrayList(u8).init(comp.gpa);
1681 defer buffer.deinit();
1682
1683 const target = comp.getTarget();
1684 const generic_arch_name = target.cpu.arch.genericName();
1685
1686 @setEvalBranchQuota(4000);
1687 try buffer.writer().print(
1688 \\usingnamespace @import("std").builtin;
1689 \\/// Deprecated
1690 \\pub const arch = std.Target.current.cpu.arch;
1691 \\/// Deprecated
1692 \\pub const endian = std.Target.current.cpu.arch.endian();
1693 \\pub const output_mode = OutputMode.{};
1694 \\pub const link_mode = LinkMode.{};
1695 \\pub const is_test = {};
1696 \\pub const single_threaded = {};
1697 \\pub const abi = Abi.{};
1698 \\pub const cpu: Cpu = Cpu{{
1699 \\ .arch = .{},
1700 \\ .model = &Target.{}.cpu.{},
1701 \\ .features = Target.{}.featureSet(&[_]Target.{}.Feature{{
1702 \\
1703 , .{
1704 @tagName(comp.bin_file.options.output_mode),
1705 @tagName(comp.bin_file.options.link_mode),
1706 comp.is_test,
1707 comp.bin_file.options.single_threaded,
1708 @tagName(target.abi),
1709 @tagName(target.cpu.arch),
1710 generic_arch_name,
1711 target.cpu.model.name,
1712 generic_arch_name,
1713 generic_arch_name,
1714 });
1715
1716 for (target.cpu.arch.allFeaturesList()) |feature, index_usize| {
1717 const index = @intCast(std.Target.Cpu.Feature.Set.Index, index_usize);
1718 const is_enabled = target.cpu.features.isEnabled(index);
1719 if (is_enabled) {
1720 // TODO some kind of "zig identifier escape" function rather than
1721 // unconditionally using @"" syntax
1722 try buffer.appendSlice(" .@\"");
1723 try buffer.appendSlice(feature.name);
1724 try buffer.appendSlice("\",\n");
1725 }
1726 }
1727
1728 try buffer.writer().print(
1729 \\ }}),
1730 \\}};
1731 \\pub const os = Os{{
1732 \\ .tag = .{},
1733 \\ .version_range = .{{
1734 ,
1735 .{@tagName(target.os.tag)},
1736 );
1737
1738 switch (target.os.getVersionRange()) {
1739 .none => try buffer.appendSlice(" .none = {} }\n"),
1740 .semver => |semver| try buffer.outStream().print(
1741 \\ .semver = .{{
1742 \\ .min = .{{
1743 \\ .major = {},
1744 \\ .minor = {},
1745 \\ .patch = {},
1746 \\ }},
1747 \\ .max = .{{
1748 \\ .major = {},
1749 \\ .minor = {},
1750 \\ .patch = {},
1751 \\ }},
1752 \\ }}}},
1753 \\
1754 , .{
1755 semver.min.major,
1756 semver.min.minor,
1757 semver.min.patch,
1758
1759 semver.max.major,
1760 semver.max.minor,
1761 semver.max.patch,
1762 }),
1763 .linux => |linux| try buffer.outStream().print(
1764 \\ .linux = .{{
1765 \\ .range = .{{
1766 \\ .min = .{{
1767 \\ .major = {},
1768 \\ .minor = {},
1769 \\ .patch = {},
1770 \\ }},
1771 \\ .max = .{{
1772 \\ .major = {},
1773 \\ .minor = {},
1774 \\ .patch = {},
1775 \\ }},
1776 \\ }},
1777 \\ .glibc = .{{
1778 \\ .major = {},
1779 \\ .minor = {},
1780 \\ .patch = {},
1781 \\ }},
1782 \\ }}}},
1783 \\
1784 , .{
1785 linux.range.min.major,
1786 linux.range.min.minor,
1787 linux.range.min.patch,
1788
1789 linux.range.max.major,
1790 linux.range.max.minor,
1791 linux.range.max.patch,
1792
1793 linux.glibc.major,
1794 linux.glibc.minor,
1795 linux.glibc.patch,
1796 }),
1797 .windows => |windows| try buffer.outStream().print(
1798 \\ .windows = .{{
1799 \\ .min = {s},
1800 \\ .max = {s},
1801 \\ }}}},
1802 \\
1803 ,
1804 .{ windows.min, windows.max },
1805 ),
1806 }
1807 try buffer.appendSlice("};\n");
1808 try buffer.writer().print(
1809 \\pub const object_format = ObjectFormat.{};
1810 \\pub const mode = Mode.{};
1811 \\pub const link_libc = {};
1812 \\pub const link_libcpp = {};
1813 \\pub const have_error_return_tracing = {};
1814 \\pub const valgrind_support = {};
1815 \\pub const position_independent_code = {};
1816 \\pub const strip_debug_info = {};
1817 \\pub const code_model = CodeModel.{};
1818 \\
1819 , .{
1820 @tagName(comp.bin_file.options.object_format),
1821 @tagName(comp.bin_file.options.optimize_mode),
1822 comp.bin_file.options.link_libc,
1823 comp.bin_file.options.link_libcpp,
1824 comp.bin_file.options.error_return_tracing,
1825 comp.bin_file.options.valgrind,
1826 comp.bin_file.options.pic,
1827 comp.bin_file.options.strip,
1828 @tagName(comp.bin_file.options.machine_code_model),
1829 });
1830 return buffer.toOwnedSlice();
1831}
src-self-hosted/glibc.zig+4-4
......@@ -711,8 +711,8 @@ fn build_crt_file(
711711 .is_native_os = comp.bin_file.options.is_native_os,
712712 .self_exe_path = comp.self_exe_path,
713713 .c_source_files = c_source_files,
714 .debug_cc = comp.debug_cc,
715 .debug_link = comp.bin_file.options.debug_link,
714 .verbose_cc = comp.verbose_cc,
715 .verbose_link = comp.bin_file.options.verbose_link,
716716 .clang_passthrough_mode = comp.clang_passthrough_mode,
717717 });
718718 defer sub_compilation.destroy();
......@@ -987,8 +987,8 @@ fn buildSharedLib(
987987 .strip = comp.bin_file.options.strip,
988988 .is_native_os = false,
989989 .self_exe_path = comp.self_exe_path,
990 .debug_cc = comp.debug_cc,
991 .debug_link = comp.bin_file.options.debug_link,
990 .verbose_cc = comp.verbose_cc,
991 .verbose_link = comp.bin_file.options.verbose_link,
992992 .clang_passthrough_mode = comp.clang_passthrough_mode,
993993 .version = version,
994994 .version_script = map_file_path,
src-self-hosted/libunwind.zig+2-2
......@@ -107,8 +107,8 @@ pub fn buildStaticLib(comp: *Compilation) !void {
107107 .is_native_os = comp.bin_file.options.is_native_os,
108108 .self_exe_path = comp.self_exe_path,
109109 .c_source_files = &c_source_files,
110 .debug_cc = comp.debug_cc,
111 .debug_link = comp.bin_file.options.debug_link,
110 .verbose_cc = comp.verbose_cc,
111 .verbose_link = comp.bin_file.options.verbose_link,
112112 .clang_passthrough_mode = comp.clang_passthrough_mode,
113113 .link_libc = true,
114114 });
src-self-hosted/link.zig+3-2
......@@ -61,8 +61,9 @@ pub const Options = struct {
6161 valgrind: bool,
6262 stack_check: bool,
6363 single_threaded: bool,
64 debug_link: bool = false,
64 verbose_link: bool = false,
6565 dll_export_fns: bool,
66 error_return_tracing: bool,
6667 gc_sections: ?bool = null,
6768 allow_shlib_undefined: ?bool = null,
6869 linker_script: ?[]const u8 = null,
......@@ -441,7 +442,7 @@ pub const File = struct {
441442 base.options.sub_path;
442443 const full_out_path_z = try arena.dupeZ(u8, full_out_path);
443444
444 if (base.options.debug_link) {
445 if (base.options.verbose_link) {
445446 std.debug.print("ar rcs {}", .{full_out_path_z});
446447 for (object_files.items) |arg| {
447448 std.debug.print(" {}", .{arg});
src-self-hosted/link/Elf.zig+1-1
......@@ -1569,7 +1569,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
15691569 try argv.append("-Bsymbolic");
15701570 }
15711571
1572 if (self.base.options.debug_link) {
1572 if (self.base.options.verbose_link) {
15731573 for (argv.items[0 .. argv.items.len - 1]) |arg| {
15741574 std.debug.print("{} ", .{arg});
15751575 }
src-self-hosted/main.zig+28-15
......@@ -179,6 +179,7 @@ const usage_build_generic =
179179 \\ --color [auto|off|on] Enable or disable colored error messages
180180 \\ -femit-bin[=path] (default) output machine code
181181 \\ -fno-emit-bin Do not output machine code
182 \\ --show-builtin Output the source of @import("builtin") then exit
182183 \\
183184 \\Compile Options:
184185 \\ -target [name] <arch><sub>-<os>-<abi> see the targets command
......@@ -233,8 +234,8 @@ const usage_build_generic =
233234 \\
234235 \\Debug Options (Zig Compiler Development):
235236 \\ -ftime-report Print timing diagnostics
236 \\ --debug-link Verbose linker invocation
237 \\ --debug-cc Verbose C compiler invocation
237 \\ --verbose-link Display linker invocations
238 \\ --verbose-cc Display C compiler invocations
238239 \\
239240;
240241
......@@ -274,9 +275,10 @@ pub fn buildOutputType(
274275 var strip = false;
275276 var single_threaded = false;
276277 var watch = false;
277 var debug_link = false;
278 var debug_cc = false;
278 var verbose_link = false;
279 var verbose_cc = false;
279280 var time_report = false;
281 var show_builtin = false;
280282 var emit_bin: Emit = .yes_default_path;
281283 var emit_zir: Emit = .no;
282284 var target_arch_os_abi: []const u8 = "native";
......@@ -531,6 +533,8 @@ pub fn buildOutputType(
531533 dll_export_fns = true;
532534 } else if (mem.eql(u8, arg, "-fno-dll-export-fns")) {
533535 dll_export_fns = false;
536 } else if (mem.eql(u8, arg, "--show-builtin")) {
537 show_builtin = true;
534538 } else if (mem.eql(u8, arg, "--strip")) {
535539 strip = true;
536540 } else if (mem.eql(u8, arg, "--single-threaded")) {
......@@ -539,10 +543,10 @@ pub fn buildOutputType(
539543 link_eh_frame_hdr = true;
540544 } else if (mem.eql(u8, arg, "-Bsymbolic")) {
541545 linker_bind_global_refs_locally = true;
542 } else if (mem.eql(u8, arg, "--debug-link")) {
543 debug_link = true;
544 } else if (mem.eql(u8, arg, "--debug-cc")) {
545 debug_cc = true;
546 } else if (mem.eql(u8, arg, "--verbose-link")) {
547 verbose_link = true;
548 } else if (mem.eql(u8, arg, "--verbose-cc")) {
549 verbose_cc = true;
546550 } else if (mem.startsWith(u8, arg, "-T")) {
547551 linker_script = arg[2..];
548552 } else if (mem.startsWith(u8, arg, "-L")) {
......@@ -680,8 +684,8 @@ pub fn buildOutputType(
680684 },
681685 .linker_script => linker_script = it.only_arg,
682686 .verbose_cmds => {
683 debug_cc = true;
684 debug_link = true;
687 verbose_cc = true;
688 verbose_link = true;
685689 },
686690 .for_linker => try linker_args.append(it.only_arg),
687691 .linker_input_z => {
......@@ -873,6 +877,8 @@ pub fn buildOutputType(
873877 } else if (emit_bin == .yes) {
874878 const basename = fs.path.basename(emit_bin.yes);
875879 break :blk mem.split(basename, ".").next().?;
880 } else if (show_builtin) {
881 break :blk "builtin";
876882 } else {
877883 fatal("--name [name] not provided and unable to infer", .{});
878884 }
......@@ -1160,17 +1166,20 @@ pub fn buildOutputType(
11601166 .clang_passthrough_mode = arg_mode != .build,
11611167 .version = if (have_version) version else null,
11621168 .libc_installation = if (libc_installation) |*lci| lci else null,
1163 .debug_cc = debug_cc,
1164 .debug_link = debug_link,
1169 .verbose_cc = verbose_cc,
1170 .verbose_link = verbose_link,
11651171 .machine_code_model = machine_code_model,
11661172 }) catch |err| {
11671173 fatal("unable to create compilation: {}", .{@errorName(err)});
11681174 };
11691175 defer comp.destroy();
11701176
1171 const stdin = std.io.getStdIn().inStream();
1172 const stderr = std.io.getStdErr().outStream();
1173 var repl_buf: [1024]u8 = undefined;
1177 if (show_builtin) {
1178 const source = try comp.generateBuiltinZigSource();
1179 defer comp.gpa.free(source);
1180 try std.io.getStdOut().writeAll(source);
1181 return;
1182 }
11741183
11751184 try updateModule(gpa, comp, zir_out_path);
11761185
......@@ -1179,6 +1188,10 @@ pub fn buildOutputType(
11791188 fatal("TODO: implement `zig cc` when using it as a preprocessor", .{});
11801189 }
11811190
1191 const stdin = std.io.getStdIn().inStream();
1192 const stderr = std.io.getStdErr().outStream();
1193 var repl_buf: [1024]u8 = undefined;
1194
11821195 while (watch) {
11831196 try stderr.print("🦎 ", .{});
11841197 if (output_mode == .Exe) {
src/all_types.hpp-2
......@@ -2161,11 +2161,9 @@ struct CodeGen {
21612161 bool have_err_ret_tracing;
21622162 bool verbose_tokenize;
21632163 bool verbose_ast;
2164 bool verbose_link;
21652164 bool verbose_ir;
21662165 bool verbose_llvm_ir;
21672166 bool verbose_cimport;
2168 bool verbose_cc;
21692167 bool verbose_llvm_cpu_features;
21702168 bool error_during_imports;
21712169 bool generate_error_name_table;
src/stage1.cpp-2
......@@ -104,11 +104,9 @@ void zig_stage1_build_object(struct ZigStage1 *stage1) {
104104
105105 g->verbose_tokenize = stage1->verbose_tokenize;
106106 g->verbose_ast = stage1->verbose_ast;
107 g->verbose_link = stage1->verbose_link;
108107 g->verbose_ir = stage1->verbose_ir;
109108 g->verbose_llvm_ir = stage1->verbose_llvm_ir;
110109 g->verbose_cimport = stage1->verbose_cimport;
111 g->verbose_cc = stage1->verbose_cc;
112110 g->verbose_llvm_cpu_features = stage1->verbose_llvm_cpu_features;
113111
114112 g->err_color = stage1->err_color;
src/stage1.h-2
......@@ -194,11 +194,9 @@ struct ZigStage1 {
194194 bool test_is_evented;
195195 bool verbose_tokenize;
196196 bool verbose_ast;
197 bool verbose_link;
198197 bool verbose_ir;
199198 bool verbose_llvm_ir;
200199 bool verbose_cimport;
201 bool verbose_cc;
202200 bool verbose_llvm_cpu_features;
203201};
204202
src/zig0.cpp-10
......@@ -44,11 +44,9 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
4444 " -mcpu [cpu] specify target CPU and feature set\n"
4545 " --verbose-tokenize enable compiler debug output for tokenization\n"
4646 " --verbose-ast enable compiler debug output for AST parsing\n"
47 " --verbose-link enable compiler debug output for linking\n"
4847 " --verbose-ir enable compiler debug output for Zig IR\n"
4948 " --verbose-llvm-ir enable compiler debug output for LLVM IR\n"
5049 " --verbose-cimport enable compiler debug output for C imports\n"
51 " --verbose-cc enable compiler debug output for C compilation\n"
5250 " --verbose-llvm-cpu-features enable compiler debug output for LLVM CPU features\n"
5351 "\n"
5452 , arg0);
......@@ -82,11 +80,9 @@ int main(int argc, char **argv) {
8280 const char *out_name = nullptr;
8381 bool verbose_tokenize = false;
8482 bool verbose_ast = false;
85 bool verbose_link = false;
8683 bool verbose_ir = false;
8784 bool verbose_llvm_ir = false;
8885 bool verbose_cimport = false;
89 bool verbose_cc = false;
9086 bool verbose_llvm_cpu_features = false;
9187 ErrColor color = ErrColorAuto;
9288 const char *dynamic_linker = nullptr;
......@@ -120,16 +116,12 @@ int main(int argc, char **argv) {
120116 verbose_tokenize = true;
121117 } else if (strcmp(arg, "--verbose-ast") == 0) {
122118 verbose_ast = true;
123 } else if (strcmp(arg, "--verbose-link") == 0) {
124 verbose_link = true;
125119 } else if (strcmp(arg, "--verbose-ir") == 0) {
126120 verbose_ir = true;
127121 } else if (strcmp(arg, "--verbose-llvm-ir") == 0) {
128122 verbose_llvm_ir = true;
129123 } else if (strcmp(arg, "--verbose-cimport") == 0) {
130124 verbose_cimport = true;
131 } else if (strcmp(arg, "--verbose-cc") == 0) {
132 verbose_cc = true;
133125 } else if (strcmp(arg, "--verbose-llvm-cpu-features") == 0) {
134126 verbose_llvm_cpu_features = true;
135127 } else if (arg[1] == 'l' && arg[2] != 0) {
......@@ -283,11 +275,9 @@ int main(int argc, char **argv) {
283275 stage1->strip = strip;
284276 stage1->verbose_tokenize = verbose_tokenize;
285277 stage1->verbose_ast = verbose_ast;
286 stage1->verbose_link = verbose_link;
287278 stage1->verbose_ir = verbose_ir;
288279 stage1->verbose_llvm_ir = verbose_llvm_ir;
289280 stage1->verbose_cimport = verbose_cimport;
290 stage1->verbose_cc = verbose_cc;
291281 stage1->verbose_llvm_cpu_features = verbose_llvm_cpu_features;
292282 stage1->output_dir_ptr = output_dir;
293283 stage1->output_dir_len = strlen(output_dir);