aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/start.zig6
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" });