@@ -285,6 +285,7 @@ const Code = struct {
285285 link_objects : []const []const u8 ,
286286 target_str : ? []const u8 ,
287287 link_libc : bool ,
288+ backend_stage1 : bool ,
288289 link_mode : ? std.builtin.LinkMode ,
289290 disable_cache : bool ,
290291 verbose_cimport : bool ,
@@ -554,6 +555,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
554555 var link_mode : ? std.builtin.LinkMode = null ;
555556 var disable_cache = false ;
556557 var verbose_cimport = false ;
558+ var backend_stage1 = false ;
557559
558560 const source_token = while (true ) {
559561 const content_tok = try eatToken (tokenizer , Token .Id .Content );
@@ -586,6 +588,8 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
586588 link_libc = true ;
587589 } else if (mem .eql (u8 , end_tag_name , "link_mode_dynamic" )) {
588590 link_mode = .Dynamic ;
591+ } else if (mem .eql (u8 , end_tag_name , "backend_stage1" )) {
592+ backend_stage1 = true ;
589593 } else if (mem .eql (u8 , end_tag_name , "code_end" )) {
590594 _ = try eatToken (tokenizer , Token .Id .BracketClose );
591595 break content_tok ;
@@ -609,6 +613,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
609613 .link_objects = link_objects .toOwnedSlice (),
610614 .target_str = target_str ,
611615 .link_libc = link_libc ,
616+ .backend_stage1 = backend_stage1 ,
612617 .link_mode = link_mode ,
613618 .disable_cache = disable_cache ,
614619 .verbose_cimport = verbose_cimport ,
@@ -1187,6 +1192,9 @@ fn printShell(out: anytype, shell_content: []const u8) !void {
11871192 try out .writeAll ("</samp></pre></figure>" );
11881193}
11891194
1195+ // Override this to skip to later tests
1196+ const debug_start_line = 0 ;
1197+
11901198fn genHtml (
11911199 allocator : Allocator ,
11921200 tokenizer : * Tokenizer ,
@@ -1266,6 +1274,13 @@ fn genHtml(
12661274 continue ;
12671275 }
12681276
1277+ if (debug_start_line > 0 ) {
1278+ const loc = tokenizer .getTokenLocation (code .source_token );
1279+ if (debug_start_line > loc .line ) {
1280+ continue ;
1281+ }
1282+ }
1283+
12691284 const raw_source = tokenizer .buffer [code .source_token .start .. code .source_token .end ];
12701285 const trimmed_raw_source = mem .trim (u8 , raw_source , " \n " );
12711286 const tmp_source_file_name = try fs .path .join (
@@ -1311,6 +1326,10 @@ fn genHtml(
13111326 try build_args .append ("-lc" );
13121327 try shell_out .print ("-lc " , .{});
13131328 }
1329+ if (code .backend_stage1 ) {
1330+ try build_args .append ("-fstage1" );
1331+ try shell_out .print ("-fstage1" , .{});
1332+ }
13141333 const target = try std .zig .CrossTarget .parse (.{
13151334 .arch_os_abi = code .target_str orelse "native" ,
13161335 });
@@ -1443,6 +1462,10 @@ fn genHtml(
14431462 try test_args .append ("-lc" );
14441463 try shell_out .print ("-lc " , .{});
14451464 }
1465+ if (code .backend_stage1 ) {
1466+ try test_args .append ("-fstage1" );
1467+ try shell_out .print ("-fstage1" , .{});
1468+ }
14461469 if (code .target_str ) | triple | {
14471470 try test_args .appendSlice (&[_ ][]const u8 { "-target" , triple });
14481471 try shell_out .print ("-target {s} " , .{triple });
@@ -1490,6 +1513,14 @@ fn genHtml(
14901513 try shell_out .print ("-O {s} " , .{@tagName (code .mode )});
14911514 },
14921515 }
1516+ if (code .link_libc ) {
1517+ try test_args .append ("-lc" );
1518+ try shell_out .print ("-lc " , .{});
1519+ }
1520+ if (code .backend_stage1 ) {
1521+ try test_args .append ("-fstage1" );
1522+ try shell_out .print ("-fstage1" , .{});
1523+ }
14931524 const result = try ChildProcess .exec (.{
14941525 .allocator = allocator ,
14951526 .argv = test_args .items ,
0 commit comments