diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-05-06 22:30:44 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-05-06 22:30:44 -0700 |
| commit | a7221ef4e902e63e72524559a067afcf6c1dfd17 (patch) | |
| tree | e3cbbbd7bd87409c8da573ecefa7174939ed8020 /lib/std | |
| parent | 3acd98fa3423d67cdce7118bc6abe736309e71df (diff) | |
| download | zig-a7221ef4e902e63e72524559a067afcf6c1dfd17.tar.gz zig-a7221ef4e902e63e72524559a067afcf6c1dfd17.zip | |
Sema: implement `@typeInfo` for functions
The goal is to get start code to be able to inspect the calling
convention of `main` in order to determine whether to export a main for
libc to call, or to allow the root source file to do it.
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/start.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index d34c7365a9..d9ec173bbc 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -28,8 +28,10 @@ comptime { // self-hosted is capable enough to handle all of the real start.zig logic. if (builtin.zig_is_stage2) { if (builtin.output_mode == .Exe) { - if (builtin.link_libc or builtin.object_format == .c) { - @export(main2, .{ .name = "main" }); + if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) { + if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { + @export(main2, .{ .name = "main" }); + } } else { if (!@hasDecl(root, "_start")) { @export(_start2, .{ .name = "_start" }); |
