authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-02 23:46:25-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
logd6f7766da298accfa84120dbc7f770a6ab5b25e0
tree6701864e29a640f6b6bbeb9b423f196e1785ddbc
parentdcec4d55e36f48e459f4e8f218b8619d9be925db

stage2: avoid networking when generating zig2.c

Avoid dragging networking into zig2.c because it adds dependencies on some linker symbols that are annoying to satisfy while bootstrapping.

1 files changed, 8 insertions(+), 1 deletions(-)

src/main.zig+8-1
...@@ -668,9 +668,13 @@ const ArgMode = union(enum) {...@@ -668,9 +668,13 @@ const ArgMode = union(enum) {
668 run,668 run,
669};669};
670670
671/// Avoid dragging networking into zig2.c because it adds dependencies on some
672/// linker symbols that are annoying to satisfy while bootstrapping.
673const Ip4Address = if (build_options.omit_pkg_fetching_code) void else std.net.Ip4Address;
674
671const Listen = union(enum) {675const Listen = union(enum) {
672 none,676 none,
673 ip4: std.net.Ip4Address,677 ip4: Ip4Address,
674 stdio,678 stdio,
675};679};
676680
...@@ -1159,6 +1163,7 @@ fn buildOutputType(...@@ -1159,6 +1163,7 @@ fn buildOutputType(
1159 listen = .stdio;1163 listen = .stdio;
1160 watch = true;1164 watch = true;
1161 } else {1165 } else {
1166 if (build_options.omit_pkg_fetching_code) unreachable;
1162 // example: --listen 127.0.0.1:90001167 // example: --listen 127.0.0.1:9000
1163 var it = std.mem.split(u8, next_arg, ":");1168 var it = std.mem.split(u8, next_arg, ":");
1164 const host = it.next().?;1169 const host = it.next().?;
...@@ -3303,6 +3308,8 @@ fn buildOutputType(...@@ -3303,6 +3308,8 @@ fn buildOutputType(
3303 return cleanExit();3308 return cleanExit();
3304 },3309 },
3305 .ip4 => |ip4_addr| {3310 .ip4 => |ip4_addr| {
3311 if (build_options.omit_pkg_fetching_code) unreachable;
3312
3306 var server = std.net.StreamServer.init(.{3313 var server = std.net.StreamServer.init(.{
3307 .reuse_address = true,3314 .reuse_address = true,
3308 });3315 });