| author | |
| committer | |
| log | 0c5ad335d293be638b8d34e671cf62f84b0babce |
| tree | fb06d4122b52921129470cb07e3c1a883d74188e |
| parent | 9c2cbe39c2caa9137e1123fcdf2f326282cad1b5 |
So that people can start experimenting with compiling their projects
with the self-hosted compiler.
I expect this commit to be reverted after #89 is closed.3 files changed, 44 insertions(+), 7 deletions(-)
lib/std/build.zig+16| ... | ... | @@ -44,6 +44,7 @@ pub const Builder = struct { |
| 44 | 44 | /// The purpose of executing the command is for a human to read compile errors from the terminal |
| 45 | 45 | prominent_compile_errors: bool, |
| 46 | 46 | color: enum { auto, on, off } = .auto, |
| 47 | use_stage1: ?bool = null, | |
| 47 | 48 | invalid_user_input: bool, |
| 48 | 49 | zig_exe: []const u8, |
| 49 | 50 | default_step: *Step, |
| ... | ... | @@ -1591,6 +1592,7 @@ pub const LibExeObjStep = struct { |
| 1591 | 1592 | stack_size: ?u64 = null, |
| 1592 | 1593 | |
| 1593 | 1594 | want_lto: ?bool = null, |
| 1595 | use_stage1: ?bool = null, | |
| 1594 | 1596 | |
| 1595 | 1597 | output_path_source: GeneratedFile, |
| 1596 | 1598 | output_lib_path_source: GeneratedFile, |
| ... | ... | @@ -2338,6 +2340,20 @@ pub const LibExeObjStep = struct { |
| 2338 | 2340 | try zig_args.append(@tagName(builder.color)); |
| 2339 | 2341 | } |
| 2340 | 2342 | |
| 2343 | if (self.use_stage1) |stage1| { | |
| 2344 | if (stage1) { | |
| 2345 | try zig_args.append("-fstage1"); | |
| 2346 | } else { | |
| 2347 | try zig_args.append("-fno-stage1"); | |
| 2348 | } | |
| 2349 | } else if (builder.use_stage1) |stage1| { | |
| 2350 | if (stage1) { | |
| 2351 | try zig_args.append("-fstage1"); | |
| 2352 | } else { | |
| 2353 | try zig_args.append("-fno-stage1"); | |
| 2354 | } | |
| 2355 | } | |
| 2356 | ||
| 2341 | 2357 | if (self.entry_symbol_name) |entry| { |
| 2342 | 2358 | try zig_args.append("--entry"); |
| 2343 | 2359 | try zig_args.append(entry); |
lib/std/special/build_runner.zig+12-5| ... | ... | @@ -24,19 +24,19 @@ pub fn main() !void { |
| 24 | 24 | var arg_idx: usize = 1; |
| 25 | 25 | |
| 26 | 26 | const zig_exe = nextArg(args, &arg_idx) orelse { |
| 27 | std.debug.print("Expected first argument to be path to zig compiler\n", .{}); | |
| 27 | std.debug.print("Expected path to zig compiler\n", .{}); | |
| 28 | 28 | return error.InvalidArgs; |
| 29 | 29 | }; |
| 30 | 30 | const build_root = nextArg(args, &arg_idx) orelse { |
| 31 | std.debug.print("Expected second argument to be build root directory path\n", .{}); | |
| 31 | std.debug.print("Expected build root directory path\n", .{}); | |
| 32 | 32 | return error.InvalidArgs; |
| 33 | 33 | }; |
| 34 | 34 | const cache_root = nextArg(args, &arg_idx) orelse { |
| 35 | std.debug.print("Expected third argument to be cache root directory path\n", .{}); | |
| 35 | std.debug.print("Expected cache root directory path\n", .{}); | |
| 36 | 36 | return error.InvalidArgs; |
| 37 | 37 | }; |
| 38 | 38 | const global_cache_root = nextArg(args, &arg_idx) orelse { |
| 39 | std.debug.print("Expected third argument to be global cache root directory path\n", .{}); | |
| 39 | std.debug.print("Expected global cache root directory path\n", .{}); | |
| 40 | 40 | return error.InvalidArgs; |
| 41 | 41 | }; |
| 42 | 42 | |
| ... | ... | @@ -181,6 +181,10 @@ pub fn main() !void { |
| 181 | 181 | builder.enable_darling = true; |
| 182 | 182 | } else if (mem.eql(u8, arg, "-fno-darling")) { |
| 183 | 183 | builder.enable_darling = false; |
| 184 | } else if (mem.eql(u8, arg, "-fstage1")) { | |
| 185 | builder.use_stage1 = true; | |
| 186 | } else if (mem.eql(u8, arg, "-fno-stage1")) { | |
| 187 | builder.use_stage1 = false; | |
| 184 | 188 | } else if (mem.eql(u8, arg, "--")) { |
| 185 | 189 | builder.args = argsRest(args, arg_idx); |
| 186 | 190 | break; |
| ... | ... | @@ -302,8 +306,11 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void |
| 302 | 306 | try out_stream.writeAll( |
| 303 | 307 | \\ |
| 304 | 308 | \\Advanced Options: |
| 309 | \\ -fstage1 Force using bootstrap compiler as the codegen backend | |
| 310 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend | |
| 305 | 311 | \\ --build-file [file] Override path to build.zig |
| 306 | \\ --cache-dir [path] Override path to zig cache directory | |
| 312 | \\ --cache-dir [path] Override path to local Zig cache directory | |
| 313 | \\ --global-cache-dir [path] Override path to global Zig cache directory | |
| 307 | 314 | \\ --zig-lib-dir [arg] Override path to Zig lib directory |
| 308 | 315 | \\ --debug-log [scope] Enable debugging the compiler |
| 309 | 316 | \\ --verbose-link Enable compiler debug output for linking |
src/main.zig+16-2| ... | ... | @@ -3464,13 +3464,20 @@ pub const usage_build = |
| 3464 | 3464 | \\ Build a project from build.zig. |
| 3465 | 3465 | \\ |
| 3466 | 3466 | \\Options: |
| 3467 | \\ -h, --help Print this help and exit | |
| 3468 | \\ | |
| 3467 | \\ -fstage1 Force using bootstrap compiler as the codegen backend | |
| 3468 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend | |
| 3469 | \\ --build-file [file] Override path to build.zig | |
| 3470 | \\ --cache-dir [path] Override path to local Zig cache directory | |
| 3471 | \\ --global-cache-dir [path] Override path to global Zig cache directory | |
| 3472 | \\ --zig-lib-dir [arg] Override path to Zig lib directory | |
| 3473 | \\ --prominent-compile-errors Output compile errors formatted for a human to read | |
| 3474 | \\ -h, --help Print this help and exit | |
| 3469 | 3475 | \\ |
| 3470 | 3476 | ; |
| 3471 | 3477 | |
| 3472 | 3478 | pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 3473 | 3479 | var prominent_compile_errors: bool = false; |
| 3480 | var use_stage1: ?bool = null; | |
| 3474 | 3481 | |
| 3475 | 3482 | // We want to release all the locks before executing the child process, so we make a nice |
| 3476 | 3483 | // big block here to ensure the cleanup gets run when we extract out our argv. |
| ... | ... | @@ -3525,6 +3532,12 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3525 | 3532 | continue; |
| 3526 | 3533 | } else if (mem.eql(u8, arg, "--prominent-compile-errors")) { |
| 3527 | 3534 | prominent_compile_errors = true; |
| 3535 | } else if (mem.eql(u8, arg, "-fstage1")) { | |
| 3536 | use_stage1 = true; | |
| 3537 | try child_argv.append(arg); | |
| 3538 | } else if (mem.eql(u8, arg, "-fno-stage1")) { | |
| 3539 | use_stage1 = false; | |
| 3540 | try child_argv.append(arg); | |
| 3528 | 3541 | } |
| 3529 | 3542 | } |
| 3530 | 3543 | try child_argv.append(arg); |
| ... | ... | @@ -3665,6 +3678,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3665 | 3678 | .optimize_mode = .Debug, |
| 3666 | 3679 | .self_exe_path = self_exe_path, |
| 3667 | 3680 | .thread_pool = &thread_pool, |
| 3681 | .use_stage1 = use_stage1, | |
| 3668 | 3682 | }) catch |err| { |
| 3669 | 3683 | fatal("unable to create compilation: {s}", .{@errorName(err)}); |
| 3670 | 3684 | }; |