authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-30 11:24:15-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-04-30 11:24:15-07:00
logfb95fd84431e399d79266d5c9c4acd8ea124399a
treeee18dff0451955be7115b94bdf725dc92ae1163e
parent2d8d681b5ee34663aa87f0583f7b1a012b17d5b4

start.zig: unconditionally import the root source file

stage1 did this by accident by unconditionally semantically analyzing std.builtin.panic, which imports the root source file to look for a panic handler override. But stage2 is smarter; it will only semantically analyze std.builtin.panic if any panic calls are emitted. So for very simple compilations, the root source file was being ignored, even if it contained `export` functions in it.

1 files changed, 4 insertions(+), 0 deletions(-)

lib/std/start.zig+4
......@@ -19,6 +19,10 @@ var argc_argv_ptr: [*]usize = undefined;
1919const start_sym_name = if (native_arch.isMIPS()) "__start" else "_start";
2020
2121comptime {
22 // No matter what, we import the root file, so that any export, test, comptime
23 // decls there get run.
24 _ = root;
25
2226 // The self-hosted compiler is not fully capable of handling all of this start.zig file.
2327 // Until then, we have simplified logic here for self-hosted. TODO remove this once
2428 // self-hosted is capable enough to handle all of the real start.zig logic.