File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1379,7 +1379,7 @@ fn resolveConfiguration(
13791379
13801380 if (config .zig_lib_path ) | zig_lib_path | blk : {
13811381 if (zig_builtin .target .os .tag == .wasi ) {
1382- std . log .warn ("The 'zig_lib_path' config option is ignored on WASI in favor of preopens." , .{});
1382+ log .warn ("The 'zig_lib_path' config option is ignored on WASI in favor of preopens." , .{});
13831383 break :blk ;
13841384 }
13851385 if (std .fs .openDirAbsolute (zig_lib_path , .{})) | zig_lib_dir | {
@@ -1408,7 +1408,7 @@ fn resolveConfiguration(
14081408
14091409 if (config .global_cache_path ) | global_cache_path | blk : {
14101410 if (zig_builtin .target .os .tag == .wasi ) {
1411- std . log .warn ("The 'global_cache_path' config option is ignored on WASI in favor of preopens." , .{});
1411+ log .warn ("The 'global_cache_path' config option is ignored on WASI in favor of preopens." , .{});
14121412 break :blk ;
14131413 }
14141414 if (std .fs .cwd ().makeOpenPath (global_cache_path , .{})) | global_cache_dir | {
Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ pub fn main() Error!void {
6363 };
6464 config .zig_exe_path = try arena .dupe (u8 , zig_exe_path );
6565 } else if (std .mem .eql (u8 , arg , "--zig-lib-path" )) {
66+ if (builtin .target .os .tag == .wasi ) {
67+ std .log .warn ("The 'zig_lib_path' config option is ignored on WASI in favor of preopens." , .{});
68+ continue ;
69+ }
6670 const zig_lib_path = arg_it .next () orelse {
6771 std .log .err ("expected argument after '--zig-lib-path'." , .{});
6872 std .process .exit (1 );
@@ -83,6 +87,20 @@ pub fn main() Error!void {
8387 }
8488 }
8589
90+ if (builtin .target .os .tag == .wasi ) {
91+ const wasi_preopens = try std .fs .wasi .preopensAlloc (gpa );
92+ defer {
93+ for (wasi_preopens .names [3.. ]) | name | gpa .free (name );
94+ gpa .free (wasi_preopens .names );
95+ }
96+
97+ const zig_lib_dir_fd = wasi_preopens .find ("/lib" ) orelse {
98+ std .log .err ("failed to resolve '/lib' WASI preopen" , .{});
99+ std .process .exit (1 );
100+ };
101+ config .zig_lib_dir = .{ .handle = .{ .fd = zig_lib_dir_fd }, .path = "/lib" };
102+ }
103+
86104 var thread_pool : if (builtin .single_threaded ) void else std.Thread.Pool = undefined ;
87105 if (builtin .single_threaded ) {
88106 thread_pool = {};
You can’t perform that action at this time.
0 commit comments