aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-12-03 12:29:55 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-12-03 12:50:42 -0500
commit6a046c1bcda1d02d4f9a05ea125ef56b50cf6e7c (patch)
tree7a92c39cf94ac84b9a9ff8a48b91a214f1ca806f /lib
parentffd21c586dbed40b991c5578b2b2ba7d12c72a8e (diff)
downloadzig-6a046c1bcda1d02d4f9a05ea125ef56b50cf6e7c.tar.gz
zig-6a046c1bcda1d02d4f9a05ea125ef56b50cf6e7c.zip
activate start code when pub main exists
and rename LinkType->LinkMode, OutType->OutputMode
Diffstat (limited to 'lib')
-rw-r--r--lib/std/builtin.zig5
-rw-r--r--lib/std/special/start.zig51
2 files changed, 23 insertions, 33 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig
index 789880dd88..b073d7300b 100644
--- a/lib/std/builtin.zig
+++ b/lib/std/builtin.zig
@@ -350,8 +350,7 @@ pub const Endian = enum {
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
-pub const OutType = enum {
- Unknown,
+pub const OutputMode = enum {
Exe,
Lib,
Obj,
@@ -359,7 +358,7 @@ pub const OutType = enum {
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
-pub const LinkType = enum {
+pub const LinkMode = enum {
Static,
Dynamic,
};
diff --git a/lib/std/special/start.zig b/lib/std/special/start.zig
index 33ecc6f1f0..5d168490fc 100644
--- a/lib/std/special/start.zig
+++ b/lib/std/special/start.zig
@@ -19,37 +19,28 @@ const is_mips = switch (builtin.arch) {
};
comptime {
- switch (builtin.output_type) {
- .Unknown => unreachable,
- .Exe => {
- if (builtin.link_libc) {
- if (@hasDecl(root, "main") and
- @typeInfo(@typeOf(root.main)).Fn.calling_convention != .C)
- {
- @export("main", main, .Weak);
- }
- } else if (builtin.os == .windows) {
- if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) {
- @export("WinMainCRTStartup", WinMainCRTStartup, .Strong);
- }
- } else if (is_wasm and builtin.os == .freestanding) {
- if (!@hasDecl(root, "_start")) @export("_start", wasm_freestanding_start, .Strong);
- } else if (builtin.os == .uefi) {
- if (!@hasDecl(root, "EfiMain")) @export("EfiMain", EfiMain, .Strong);
- } else if (is_mips) {
- if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong);
- } else {
- if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);
- }
- },
- .Lib => {
- if (builtin.os == .windows and builtin.link_type == .Dynamic and
- !@hasDecl(root, "_DllMainCRTStartup"))
- {
- @export("_DllMainCRTStartup", _DllMainCRTStartup, .Strong);
+ if (builtin.output_mode == .Lib and builtin.link_mode == .Dynamic) {
+ if (builtin.os == .windows and !@hasDecl(root, "_DllMainCRTStartup")) {
+ @export("_DllMainCRTStartup", _DllMainCRTStartup, .Strong);
+ }
+ } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
+ if (builtin.link_libc and @hasDecl(root, "main") and
+ @typeInfo(@typeOf(root.main)).Fn.calling_convention != .C)
+ {
+ @export("main", main, .Weak);
+ } else if (builtin.os == .windows) {
+ if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup")) {
+ @export("WinMainCRTStartup", WinMainCRTStartup, .Strong);
}
- },
- .Obj => {},
+ } else if (is_wasm and builtin.os == .freestanding) {
+ if (!@hasDecl(root, "_start")) @export("_start", wasm_freestanding_start, .Strong);
+ } else if (builtin.os == .uefi) {
+ if (!@hasDecl(root, "EfiMain")) @export("EfiMain", EfiMain, .Strong);
+ } else if (is_mips) {
+ if (!@hasDecl(root, "__start")) @export("__start", _start, .Strong);
+ } else {
+ if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);
+ }
}
}