@@ -69,9 +69,8 @@ pub fn build(b: *Builder) !void {
69
69
70
70
const only_install_lib_files = b .option (bool , "lib-files-only" , "Only install library files" ) orelse false ;
71
71
72
- const have_stage1 = b .option (bool , "enable-stage1" , "Include the stage1 compiler behind a feature flag" ) orelse false ;
73
72
const static_llvm = b .option (bool , "static-llvm" , "Disable integration with system-installed LLVM, Clang, LLD, and libc++" ) orelse false ;
74
- const enable_llvm = b .option (bool , "enable-llvm" , "Build self-hosted compiler with LLVM backend enabled" ) orelse ( have_stage1 or static_llvm ) ;
73
+ const enable_llvm = b .option (bool , "enable-llvm" , "Build self-hosted compiler with LLVM backend enabled" ) orelse static_llvm ;
75
74
const llvm_has_m68k = b .option (
76
75
bool ,
77
76
"llvm-has-m68k" ,
@@ -132,7 +131,6 @@ pub fn build(b: *Builder) !void {
132
131
const link_libc = b .option (bool , "force-link-libc" , "Force self-hosted compiler to link libc" ) orelse (enable_llvm or only_c );
133
132
const sanitize_thread = b .option (bool , "sanitize-thread" , "Enable thread-sanitization" ) orelse false ;
134
133
const strip = b .option (bool , "strip" , "Omit debug information" ) orelse false ;
135
- const use_zig0 = b .option (bool , "zig0" , "Bootstrap using zig0" ) orelse false ;
136
134
const value_tracing = b .option (bool , "value-tracing" , "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)" ) orelse false ;
137
135
138
136
const mem_leak_frames : u32 = b .option (u32 , "mem-leak-frames" , "How many stack frames to print when a memory leak occurs. Tests get 2x this amount." ) orelse blk : {
@@ -145,11 +143,7 @@ pub fn build(b: *Builder) !void {
145
143
target .ofmt = .c ;
146
144
}
147
145
148
- const main_file : ? []const u8 = mf : {
149
- if (! have_stage1 ) break :mf "src/main.zig" ;
150
- if (use_zig0 ) break :mf null ;
151
- break :mf "src/stage1.zig" ;
152
- };
146
+ const main_file : ? []const u8 = "src/main.zig" ;
153
147
154
148
const exe = b .addExecutable ("zig" , main_file );
155
149
@@ -263,92 +257,6 @@ pub fn build(b: *Builder) !void {
263
257
}
264
258
};
265
259
266
- if (have_stage1 ) {
267
- const softfloat = b .addStaticLibrary ("softfloat" , null );
268
- softfloat .setBuildMode (.ReleaseFast );
269
- softfloat .setTarget (target );
270
- softfloat .addIncludePath ("deps/SoftFloat-3e-prebuilt" );
271
- softfloat .addIncludePath ("deps/SoftFloat-3e/source/8086" );
272
- softfloat .addIncludePath ("deps/SoftFloat-3e/source/include" );
273
- softfloat .addCSourceFiles (& softfloat_sources , &[_ ][]const u8 { "-std=c99" , "-O3" });
274
- softfloat .single_threaded = single_threaded ;
275
-
276
- const zig0 = b .addExecutable ("zig0" , null );
277
- zig0 .addCSourceFiles (&.{"src/stage1/zig0.cpp" }, & exe_cflags );
278
- zig0 .addIncludePath ("zig-cache/tmp" ); // for config.h
279
- zig0 .defineCMacro ("ZIG_VERSION_MAJOR" , b .fmt ("{d}" , .{zig_version .major }));
280
- zig0 .defineCMacro ("ZIG_VERSION_MINOR" , b .fmt ("{d}" , .{zig_version .minor }));
281
- zig0 .defineCMacro ("ZIG_VERSION_PATCH" , b .fmt ("{d}" , .{zig_version .patch }));
282
- zig0 .defineCMacro ("ZIG_VERSION_STRING" , b .fmt ("\" {s}\" " , .{version }));
283
-
284
- for ([_ ]* std.build.LibExeObjStep { zig0 , exe , test_cases }) | artifact | {
285
- artifact .addIncludePath ("src" );
286
- artifact .addIncludePath ("deps/SoftFloat-3e/source/include" );
287
- artifact .addIncludePath ("deps/SoftFloat-3e-prebuilt" );
288
-
289
- artifact .defineCMacro ("ZIG_LINK_MODE" , "Static" );
290
-
291
- artifact .addCSourceFiles (& stage1_sources , & exe_cflags );
292
- artifact .addCSourceFiles (& optimized_c_sources , &[_ ][]const u8 { "-std=c99" , "-O3" });
293
-
294
- artifact .linkLibrary (softfloat );
295
- artifact .linkLibCpp ();
296
- }
297
-
298
- try addStaticLlvmOptionsToExe (zig0 );
299
-
300
- const zig1_obj_ext = target .getObjectFormat ().fileExt (target .getCpuArch ());
301
- const zig1_obj_path = b .pathJoin (&.{ "zig-cache" , "tmp" , b .fmt ("zig1{s}" , .{zig1_obj_ext }) });
302
- const zig1_compiler_rt_path = b .pathJoin (&.{ b .pathFromRoot ("lib" ), "std" , "special" , "compiler_rt.zig" });
303
-
304
- const zig1_obj = zig0 .run ();
305
- zig1_obj .addArgs (&.{
306
- "src/stage1.zig" ,
307
- "-target" ,
308
- try target .zigTriple (b .allocator ),
309
- "-mcpu=baseline" ,
310
- "--name" ,
311
- "zig1" ,
312
- "--zig-lib-dir" ,
313
- b .pathFromRoot ("lib" ),
314
- b .fmt ("-femit-bin={s}" , .{b .pathFromRoot (zig1_obj_path )}),
315
- "-fcompiler-rt" ,
316
- "-lc" ,
317
- });
318
- {
319
- zig1_obj .addArgs (&.{ "--pkg-begin" , "build_options" });
320
- zig1_obj .addFileSourceArg (exe_options .getSource ());
321
- zig1_obj .addArgs (&.{ "--pkg-end" , "--pkg-begin" , "compiler_rt" , zig1_compiler_rt_path , "--pkg-end" });
322
- }
323
- switch (mode ) {
324
- .Debug = > {},
325
- .ReleaseFast = > {
326
- zig1_obj .addArg ("-OReleaseFast" );
327
- zig1_obj .addArg ("-fstrip" );
328
- },
329
- .ReleaseSafe = > {
330
- zig1_obj .addArg ("-OReleaseSafe" );
331
- zig1_obj .addArg ("-fstrip" );
332
- },
333
- .ReleaseSmall = > {
334
- zig1_obj .addArg ("-OReleaseSmall" );
335
- zig1_obj .addArg ("-fstrip" );
336
- },
337
- }
338
- if (single_threaded orelse false ) {
339
- zig1_obj .addArg ("-fsingle-threaded" );
340
- }
341
-
342
- if (use_zig0 ) {
343
- exe .step .dependOn (& zig1_obj .step );
344
- exe .addObjectFile (zig1_obj_path );
345
- }
346
-
347
- // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case
348
- // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that
349
- // is pointless.
350
- exe .addPackagePath ("compiler_rt" , "src/empty.zig" );
351
- }
352
260
if (cmake_cfg ) | cfg | {
353
261
// Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD.
354
262
// That means we also have to rely on stage1 compiled c++ files. We parse config.h to find
@@ -378,7 +286,6 @@ pub fn build(b: *Builder) !void {
378
286
exe_options .addOption (bool , "enable_tracy_callstack" , tracy_callstack );
379
287
exe_options .addOption (bool , "enable_tracy_allocation" , tracy_allocation );
380
288
exe_options .addOption (bool , "value_tracing" , value_tracing );
381
- exe_options .addOption (bool , "have_stage1" , have_stage1 );
382
289
if (tracy ) | tracy_path | {
383
290
const client_cpp = fs .path .join (
384
291
b .allocator ,
@@ -413,7 +320,6 @@ pub fn build(b: *Builder) !void {
413
320
test_cases_options .addOption (bool , "enable_link_snapshots" , enable_link_snapshots );
414
321
test_cases_options .addOption (bool , "skip_non_native" , skip_non_native );
415
322
test_cases_options .addOption (bool , "skip_stage1" , skip_stage1 );
416
- test_cases_options .addOption (bool , "have_stage1" , have_stage1 );
417
323
test_cases_options .addOption (bool , "have_llvm" , enable_llvm );
418
324
test_cases_options .addOption (bool , "llvm_has_m68k" , llvm_has_m68k );
419
325
test_cases_options .addOption (bool , "llvm_has_csky" , llvm_has_csky );
@@ -1008,31 +914,6 @@ const softfloat_sources = [_][]const u8{
1008
914
"deps/SoftFloat-3e/source/ui64_to_extF80M.c" ,
1009
915
};
1010
916
1011
- const stage1_sources = [_ ][]const u8 {
1012
- "src/stage1/analyze.cpp" ,
1013
- "src/stage1/astgen.cpp" ,
1014
- "src/stage1/bigfloat.cpp" ,
1015
- "src/stage1/bigint.cpp" ,
1016
- "src/stage1/buffer.cpp" ,
1017
- "src/stage1/codegen.cpp" ,
1018
- "src/stage1/errmsg.cpp" ,
1019
- "src/stage1/error.cpp" ,
1020
- "src/stage1/heap.cpp" ,
1021
- "src/stage1/ir.cpp" ,
1022
- "src/stage1/ir_print.cpp" ,
1023
- "src/stage1/mem.cpp" ,
1024
- "src/stage1/os.cpp" ,
1025
- "src/stage1/parser.cpp" ,
1026
- "src/stage1/range_set.cpp" ,
1027
- "src/stage1/stage1.cpp" ,
1028
- "src/stage1/target.cpp" ,
1029
- "src/stage1/tokenizer.cpp" ,
1030
- "src/stage1/util.cpp" ,
1031
- "src/stage1/softfloat_ext.cpp" ,
1032
- };
1033
- const optimized_c_sources = [_ ][]const u8 {
1034
- "src/stage1/parse_f128.c" ,
1035
- };
1036
917
const zig_cpp_sources = [_ ][]const u8 {
1037
918
// These are planned to stay even when we are self-hosted.
1038
919
"src/zig_llvm.cpp" ,
0 commit comments