| author | |
| committer | |
| log | 28514476ef8c824c3d189d98f23d0f8d23e496ea |
| tree | 537631080e7c99fb582738d3be96ac48c5941bb7 |
| parent | bf316e550671cc71eb498b3cf799493627bb0fdc |
After this commit, the self-hosted compiler does not offer the option to
use stage1 as a backend anymore.25 files changed, 95 insertions(+), 461 deletions(-)
CMakeLists.txt-1| ... | @@ -1084,7 +1084,6 @@ set(ZIG_BUILD_ARGS | ... | @@ -1084,7 +1084,6 @@ set(ZIG_BUILD_ARGS |
| 1084 | --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib" | 1084 | --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib" |
| 1085 | "-Dconfig_h=${ZIG_CONFIG_H_OUT}" | 1085 | "-Dconfig_h=${ZIG_CONFIG_H_OUT}" |
| 1086 | "-Denable-llvm" | 1086 | "-Denable-llvm" |
| 1087 | "-Denable-stage1" | ||
| 1088 | ${ZIG_RELEASE_ARG} | 1087 | ${ZIG_RELEASE_ARG} |
| 1089 | ${ZIG_STATIC_ARG} | 1088 | ${ZIG_STATIC_ARG} |
| 1090 | ${ZIG_NO_LIB_ARG} | 1089 | ${ZIG_NO_LIB_ARG} |
build.zig+2-121| ... | @@ -69,9 +69,8 @@ pub fn build(b: *Builder) !void { | ... | @@ -69,9 +69,8 @@ pub fn build(b: *Builder) !void { |
| 69 | 69 | ||
| 70 | const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; | 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 | const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false; | 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 | const llvm_has_m68k = b.option( | 74 | const llvm_has_m68k = b.option( |
| 76 | bool, | 75 | bool, |
| 77 | "llvm-has-m68k", | 76 | "llvm-has-m68k", |
| ... | @@ -133,7 +132,6 @@ pub fn build(b: *Builder) !void { | ... | @@ -133,7 +132,6 @@ pub fn build(b: *Builder) !void { |
| 133 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c); | 132 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c); |
| 134 | const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false; | 133 | const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false; |
| 135 | const strip = b.option(bool, "strip", "Omit debug information") orelse false; | 134 | const strip = b.option(bool, "strip", "Omit debug information") orelse false; |
| 136 | const use_zig0 = b.option(bool, "zig0", "Bootstrap using zig0") orelse false; | ||
| 137 | 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; | 135 | 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; |
| 138 | 136 | ||
| 139 | 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: { | 137 | 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: { |
| ... | @@ -146,11 +144,7 @@ pub fn build(b: *Builder) !void { | ... | @@ -146,11 +144,7 @@ pub fn build(b: *Builder) !void { |
| 146 | target.ofmt = .c; | 144 | target.ofmt = .c; |
| 147 | } | 145 | } |
| 148 | 146 | ||
| 149 | const main_file: ?[]const u8 = mf: { | 147 | const main_file: ?[]const u8 = "src/main.zig"; |
| 150 | if (!have_stage1) break :mf "src/main.zig"; | ||
| 151 | if (use_zig0) break :mf null; | ||
| 152 | break :mf "src/stage1.zig"; | ||
| 153 | }; | ||
| 154 | 148 | ||
| 155 | const exe = b.addExecutable("zig", main_file); | 149 | const exe = b.addExecutable("zig", main_file); |
| 156 | 150 | ||
| ... | @@ -264,92 +258,6 @@ pub fn build(b: *Builder) !void { | ... | @@ -264,92 +258,6 @@ pub fn build(b: *Builder) !void { |
| 264 | } | 258 | } |
| 265 | }; | 259 | }; |
| 266 | 260 | ||
| 267 | if (have_stage1) { | ||
| 268 | const softfloat = b.addStaticLibrary("softfloat", null); | ||
| 269 | softfloat.setBuildMode(.ReleaseFast); | ||
| 270 | softfloat.setTarget(target); | ||
| 271 | softfloat.addIncludePath("deps/SoftFloat-3e-prebuilt"); | ||
| 272 | softfloat.addIncludePath("deps/SoftFloat-3e/source/8086"); | ||
| 273 | softfloat.addIncludePath("deps/SoftFloat-3e/source/include"); | ||
| 274 | softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); | ||
| 275 | softfloat.single_threaded = single_threaded; | ||
| 276 | |||
| 277 | const zig0 = b.addExecutable("zig0", null); | ||
| 278 | zig0.addCSourceFiles(&.{"src/stage1/zig0.cpp"}, &exe_cflags); | ||
| 279 | zig0.addIncludePath("zig-cache/tmp"); // for config.h | ||
| 280 | zig0.defineCMacro("ZIG_VERSION_MAJOR", b.fmt("{d}", .{zig_version.major})); | ||
| 281 | zig0.defineCMacro("ZIG_VERSION_MINOR", b.fmt("{d}", .{zig_version.minor})); | ||
| 282 | zig0.defineCMacro("ZIG_VERSION_PATCH", b.fmt("{d}", .{zig_version.patch})); | ||
| 283 | zig0.defineCMacro("ZIG_VERSION_STRING", b.fmt("\"{s}\"", .{version})); | ||
| 284 | |||
| 285 | for ([_]*std.build.LibExeObjStep{ zig0, exe, test_cases }) |artifact| { | ||
| 286 | artifact.addIncludePath("src"); | ||
| 287 | artifact.addIncludePath("deps/SoftFloat-3e/source/include"); | ||
| 288 | artifact.addIncludePath("deps/SoftFloat-3e-prebuilt"); | ||
| 289 | |||
| 290 | artifact.defineCMacro("ZIG_LINK_MODE", "Static"); | ||
| 291 | |||
| 292 | artifact.addCSourceFiles(&stage1_sources, &exe_cflags); | ||
| 293 | artifact.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); | ||
| 294 | |||
| 295 | artifact.linkLibrary(softfloat); | ||
| 296 | artifact.linkLibCpp(); | ||
| 297 | } | ||
| 298 | |||
| 299 | try addStaticLlvmOptionsToExe(zig0); | ||
| 300 | |||
| 301 | const zig1_obj_ext = target.getObjectFormat().fileExt(target.getCpuArch()); | ||
| 302 | const zig1_obj_path = b.pathJoin(&.{ "zig-cache", "tmp", b.fmt("zig1{s}", .{zig1_obj_ext}) }); | ||
| 303 | const zig1_compiler_rt_path = b.pathJoin(&.{ b.pathFromRoot("lib"), "std", "special", "compiler_rt.zig" }); | ||
| 304 | |||
| 305 | const zig1_obj = zig0.run(); | ||
| 306 | zig1_obj.addArgs(&.{ | ||
| 307 | "src/stage1.zig", | ||
| 308 | "-target", | ||
| 309 | try target.zigTriple(b.allocator), | ||
| 310 | "-mcpu=baseline", | ||
| 311 | "--name", | ||
| 312 | "zig1", | ||
| 313 | "--zig-lib-dir", | ||
| 314 | b.pathFromRoot("lib"), | ||
| 315 | b.fmt("-femit-bin={s}", .{b.pathFromRoot(zig1_obj_path)}), | ||
| 316 | "-fcompiler-rt", | ||
| 317 | "-lc", | ||
| 318 | }); | ||
| 319 | { | ||
| 320 | zig1_obj.addArgs(&.{ "--pkg-begin", "build_options" }); | ||
| 321 | zig1_obj.addFileSourceArg(exe_options.getSource()); | ||
| 322 | zig1_obj.addArgs(&.{ "--pkg-end", "--pkg-begin", "compiler_rt", zig1_compiler_rt_path, "--pkg-end" }); | ||
| 323 | } | ||
| 324 | switch (mode) { | ||
| 325 | .Debug => {}, | ||
| 326 | .ReleaseFast => { | ||
| 327 | zig1_obj.addArg("-OReleaseFast"); | ||
| 328 | zig1_obj.addArg("-fstrip"); | ||
| 329 | }, | ||
| 330 | .ReleaseSafe => { | ||
| 331 | zig1_obj.addArg("-OReleaseSafe"); | ||
| 332 | zig1_obj.addArg("-fstrip"); | ||
| 333 | }, | ||
| 334 | .ReleaseSmall => { | ||
| 335 | zig1_obj.addArg("-OReleaseSmall"); | ||
| 336 | zig1_obj.addArg("-fstrip"); | ||
| 337 | }, | ||
| 338 | } | ||
| 339 | if (single_threaded orelse false) { | ||
| 340 | zig1_obj.addArg("-fsingle-threaded"); | ||
| 341 | } | ||
| 342 | |||
| 343 | if (use_zig0) { | ||
| 344 | exe.step.dependOn(&zig1_obj.step); | ||
| 345 | exe.addObjectFile(zig1_obj_path); | ||
| 346 | } | ||
| 347 | |||
| 348 | // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case | ||
| 349 | // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that | ||
| 350 | // is pointless. | ||
| 351 | exe.addPackagePath("compiler_rt", "src/empty.zig"); | ||
| 352 | } | ||
| 353 | if (cmake_cfg) |cfg| { | 261 | if (cmake_cfg) |cfg| { |
| 354 | // Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD. | 262 | // Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD. |
| 355 | // That means we also have to rely on stage1 compiled c++ files. We parse config.h to find | 263 | // That means we also have to rely on stage1 compiled c++ files. We parse config.h to find |
| ... | @@ -379,7 +287,6 @@ pub fn build(b: *Builder) !void { | ... | @@ -379,7 +287,6 @@ pub fn build(b: *Builder) !void { |
| 379 | exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); | 287 | exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack); |
| 380 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); | 288 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); |
| 381 | exe_options.addOption(bool, "value_tracing", value_tracing); | 289 | exe_options.addOption(bool, "value_tracing", value_tracing); |
| 382 | exe_options.addOption(bool, "have_stage1", have_stage1); | ||
| 383 | if (tracy) |tracy_path| { | 290 | if (tracy) |tracy_path| { |
| 384 | const client_cpp = fs.path.join( | 291 | const client_cpp = fs.path.join( |
| 385 | b.allocator, | 292 | b.allocator, |
| ... | @@ -414,7 +321,6 @@ pub fn build(b: *Builder) !void { | ... | @@ -414,7 +321,6 @@ pub fn build(b: *Builder) !void { |
| 414 | test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); | 321 | test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); |
| 415 | test_cases_options.addOption(bool, "skip_non_native", skip_non_native); | 322 | test_cases_options.addOption(bool, "skip_non_native", skip_non_native); |
| 416 | test_cases_options.addOption(bool, "skip_stage1", skip_stage1); | 323 | test_cases_options.addOption(bool, "skip_stage1", skip_stage1); |
| 417 | test_cases_options.addOption(bool, "have_stage1", have_stage1); | ||
| 418 | test_cases_options.addOption(bool, "have_llvm", enable_llvm); | 324 | test_cases_options.addOption(bool, "have_llvm", enable_llvm); |
| 419 | test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); | 325 | test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); |
| 420 | test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky); | 326 | test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky); |
| ... | @@ -1010,31 +916,6 @@ const softfloat_sources = [_][]const u8{ | ... | @@ -1010,31 +916,6 @@ const softfloat_sources = [_][]const u8{ |
| 1010 | "deps/SoftFloat-3e/source/ui64_to_extF80M.c", | 916 | "deps/SoftFloat-3e/source/ui64_to_extF80M.c", |
| 1011 | }; | 917 | }; |
| 1012 | 918 | ||
| 1013 | const stage1_sources = [_][]const u8{ | ||
| 1014 | "src/stage1/analyze.cpp", | ||
| 1015 | "src/stage1/astgen.cpp", | ||
| 1016 | "src/stage1/bigfloat.cpp", | ||
| 1017 | "src/stage1/bigint.cpp", | ||
| 1018 | "src/stage1/buffer.cpp", | ||
| 1019 | "src/stage1/codegen.cpp", | ||
| 1020 | "src/stage1/errmsg.cpp", | ||
| 1021 | "src/stage1/error.cpp", | ||
| 1022 | "src/stage1/heap.cpp", | ||
| 1023 | "src/stage1/ir.cpp", | ||
| 1024 | "src/stage1/ir_print.cpp", | ||
| 1025 | "src/stage1/mem.cpp", | ||
| 1026 | "src/stage1/os.cpp", | ||
| 1027 | "src/stage1/parser.cpp", | ||
| 1028 | "src/stage1/range_set.cpp", | ||
| 1029 | "src/stage1/stage1.cpp", | ||
| 1030 | "src/stage1/target.cpp", | ||
| 1031 | "src/stage1/tokenizer.cpp", | ||
| 1032 | "src/stage1/util.cpp", | ||
| 1033 | "src/stage1/softfloat_ext.cpp", | ||
| 1034 | }; | ||
| 1035 | const optimized_c_sources = [_][]const u8{ | ||
| 1036 | "src/stage1/parse_f128.c", | ||
| 1037 | }; | ||
| 1038 | const zig_cpp_sources = [_][]const u8{ | 919 | const zig_cpp_sources = [_][]const u8{ |
| 1039 | // These are planned to stay even when we are self-hosted. | 920 | // These are planned to stay even when we are self-hosted. |
| 1040 | "src/zig_llvm.cpp", | 921 | "src/zig_llvm.cpp", |
lib/build_runner.zig-6| ... | @@ -183,10 +183,6 @@ pub fn main() !void { | ... | @@ -183,10 +183,6 @@ pub fn main() !void { |
| 183 | builder.enable_darling = true; | 183 | builder.enable_darling = true; |
| 184 | } else if (mem.eql(u8, arg, "-fno-darling")) { | 184 | } else if (mem.eql(u8, arg, "-fno-darling")) { |
| 185 | builder.enable_darling = false; | 185 | builder.enable_darling = false; |
| 186 | } else if (mem.eql(u8, arg, "-fstage1")) { | ||
| 187 | builder.use_stage1 = true; | ||
| 188 | } else if (mem.eql(u8, arg, "-fno-stage1")) { | ||
| 189 | builder.use_stage1 = false; | ||
| 190 | } else if (mem.eql(u8, arg, "-freference-trace")) { | 186 | } else if (mem.eql(u8, arg, "-freference-trace")) { |
| 191 | builder.reference_trace = 256; | 187 | builder.reference_trace = 256; |
| 192 | } else if (mem.startsWith(u8, arg, "-freference-trace=")) { | 188 | } else if (mem.startsWith(u8, arg, "-freference-trace=")) { |
| ... | @@ -318,8 +314,6 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void | ... | @@ -318,8 +314,6 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void |
| 318 | try out_stream.writeAll( | 314 | try out_stream.writeAll( |
| 319 | \\ | 315 | \\ |
| 320 | \\Advanced Options: | 316 | \\Advanced Options: |
| 321 | \\ -fstage1 Force using bootstrap compiler as the codegen backend | ||
| 322 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend | ||
| 323 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error | 317 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error |
| 324 | \\ -fno-reference-trace Disable reference trace | 318 | \\ -fno-reference-trace Disable reference trace |
| 325 | \\ --build-file [file] Override path to build.zig | 319 | \\ --build-file [file] Override path to build.zig |
lib/std/build.zig-16| ... | @@ -46,7 +46,6 @@ pub const Builder = struct { | ... | @@ -46,7 +46,6 @@ pub const Builder = struct { |
| 46 | prominent_compile_errors: bool, | 46 | prominent_compile_errors: bool, |
| 47 | color: enum { auto, on, off } = .auto, | 47 | color: enum { auto, on, off } = .auto, |
| 48 | reference_trace: ?u32 = null, | 48 | reference_trace: ?u32 = null, |
| 49 | use_stage1: ?bool = null, | ||
| 50 | invalid_user_input: bool, | 49 | invalid_user_input: bool, |
| 51 | zig_exe: []const u8, | 50 | zig_exe: []const u8, |
| 52 | default_step: *Step, | 51 | default_step: *Step, |
| ... | @@ -1621,7 +1620,6 @@ pub const LibExeObjStep = struct { | ... | @@ -1621,7 +1620,6 @@ pub const LibExeObjStep = struct { |
| 1621 | stack_size: ?u64 = null, | 1620 | stack_size: ?u64 = null, |
| 1622 | 1621 | ||
| 1623 | want_lto: ?bool = null, | 1622 | want_lto: ?bool = null, |
| 1624 | use_stage1: ?bool = null, | ||
| 1625 | use_llvm: ?bool = null, | 1623 | use_llvm: ?bool = null, |
| 1626 | use_lld: ?bool = null, | 1624 | use_lld: ?bool = null, |
| 1627 | 1625 | ||
| ... | @@ -2467,20 +2465,6 @@ pub const LibExeObjStep = struct { | ... | @@ -2467,20 +2465,6 @@ pub const LibExeObjStep = struct { |
| 2467 | try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-freference-trace={d}", .{some})); | 2465 | try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-freference-trace={d}", .{some})); |
| 2468 | } | 2466 | } |
| 2469 | 2467 | ||
| 2470 | if (self.use_stage1) |stage1| { | ||
| 2471 | if (stage1) { | ||
| 2472 | try zig_args.append("-fstage1"); | ||
| 2473 | } else { | ||
| 2474 | try zig_args.append("-fno-stage1"); | ||
| 2475 | } | ||
| 2476 | } else if (builder.use_stage1) |stage1| { | ||
| 2477 | if (stage1) { | ||
| 2478 | try zig_args.append("-fstage1"); | ||
| 2479 | } else { | ||
| 2480 | try zig_args.append("-fno-stage1"); | ||
| 2481 | } | ||
| 2482 | } | ||
| 2483 | |||
| 2484 | if (self.use_llvm) |use_llvm| { | 2468 | if (self.use_llvm) |use_llvm| { |
| 2485 | if (use_llvm) { | 2469 | if (use_llvm) { |
| 2486 | try zig_args.append("-fLLVM"); | 2470 | try zig_args.append("-fLLVM"); |
lib/std/build/TranslateCStep.zig-14| ... | @@ -21,7 +21,6 @@ output_dir: ?[]const u8, | ... | @@ -21,7 +21,6 @@ output_dir: ?[]const u8, |
| 21 | out_basename: []const u8, | 21 | out_basename: []const u8, |
| 22 | target: CrossTarget = CrossTarget{}, | 22 | target: CrossTarget = CrossTarget{}, |
| 23 | output_file: build.GeneratedFile, | 23 | output_file: build.GeneratedFile, |
| 24 | use_stage1: ?bool = null, | ||
| 25 | 24 | ||
| 26 | pub fn create(builder: *Builder, source: build.FileSource) *TranslateCStep { | 25 | pub fn create(builder: *Builder, source: build.FileSource) *TranslateCStep { |
| 27 | const self = builder.allocator.create(TranslateCStep) catch unreachable; | 26 | const self = builder.allocator.create(TranslateCStep) catch unreachable; |
| ... | @@ -92,19 +91,6 @@ fn make(step: *Step) !void { | ... | @@ -92,19 +91,6 @@ fn make(step: *Step) !void { |
| 92 | try argv_list.append("-D"); | 91 | try argv_list.append("-D"); |
| 93 | try argv_list.append(c_macro); | 92 | try argv_list.append(c_macro); |
| 94 | } | 93 | } |
| 95 | if (self.use_stage1) |stage1| { | ||
| 96 | if (stage1) { | ||
| 97 | try argv_list.append("-fstage1"); | ||
| 98 | } else { | ||
| 99 | try argv_list.append("-fno-stage1"); | ||
| 100 | } | ||
| 101 | } else if (self.builder.use_stage1) |stage1| { | ||
| 102 | if (stage1) { | ||
| 103 | try argv_list.append("-fstage1"); | ||
| 104 | } else { | ||
| 105 | try argv_list.append("-fno-stage1"); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | 94 | ||
| 109 | try argv_list.append(self.source.getPath(self.builder)); | 95 | try argv_list.append(self.source.getPath(self.builder)); |
| 110 | 96 |
src/Compilation.zig+44-83| ... | @@ -935,7 +935,6 @@ pub const InitOptions = struct { | ... | @@ -935,7 +935,6 @@ pub const InitOptions = struct { |
| 935 | use_llvm: ?bool = null, | 935 | use_llvm: ?bool = null, |
| 936 | use_lld: ?bool = null, | 936 | use_lld: ?bool = null, |
| 937 | use_clang: ?bool = null, | 937 | use_clang: ?bool = null, |
| 938 | use_stage1: ?bool = null, | ||
| 939 | single_threaded: ?bool = null, | 938 | single_threaded: ?bool = null, |
| 940 | strip: ?bool = null, | 939 | strip: ?bool = null, |
| 941 | formatted_panics: ?bool = null, | 940 | formatted_panics: ?bool = null, |
| ... | @@ -1133,9 +1132,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1133,9 +1132,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1133 | const comp = try arena.create(Compilation); | 1132 | const comp = try arena.create(Compilation); |
| 1134 | const root_name = try arena.dupeZ(u8, options.root_name); | 1133 | const root_name = try arena.dupeZ(u8, options.root_name); |
| 1135 | 1134 | ||
| 1136 | const use_stage1 = options.use_stage1 orelse false; | ||
| 1137 | if (use_stage1 and !build_options.have_stage1) return error.ZigCompilerBuiltWithoutStage1; | ||
| 1138 | |||
| 1139 | // Make a decision on whether to use LLVM or our own backend. | 1135 | // Make a decision on whether to use LLVM or our own backend. |
| 1140 | const use_llvm = build_options.have_llvm and blk: { | 1136 | const use_llvm = build_options.have_llvm and blk: { |
| 1141 | if (options.use_llvm) |explicit| | 1137 | if (options.use_llvm) |explicit| |
| ... | @@ -1149,11 +1145,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1149,11 +1145,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1149 | if (options.main_pkg == null) | 1145 | if (options.main_pkg == null) |
| 1150 | break :blk false; | 1146 | break :blk false; |
| 1151 | 1147 | ||
| 1152 | // The stage1 compiler depends on the stage1 C++ LLVM backend | ||
| 1153 | // to compile zig code. | ||
| 1154 | if (use_stage1) | ||
| 1155 | break :blk true; | ||
| 1156 | |||
| 1157 | // If LLVM does not support the target, then we can't use it. | 1148 | // If LLVM does not support the target, then we can't use it. |
| 1158 | if (!target_util.hasLlvmSupport(options.target, options.target.ofmt)) | 1149 | if (!target_util.hasLlvmSupport(options.target, options.target.ofmt)) |
| 1159 | break :blk false; | 1150 | break :blk false; |
| ... | @@ -1181,8 +1172,10 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1181,8 +1172,10 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1181 | // compiler state, the second clause here can be removed so that incremental | 1172 | // compiler state, the second clause here can be removed so that incremental |
| 1182 | // cache mode is used for LLVM backend too. We need some fuzz testing before | 1173 | // cache mode is used for LLVM backend too. We need some fuzz testing before |
| 1183 | // that can be enabled. | 1174 | // that can be enabled. |
| 1184 | const cache_mode = if ((use_stage1 and !options.disable_lld_caching) or | 1175 | const cache_mode = if (use_llvm and !options.disable_lld_caching) |
| 1185 | (use_llvm and !options.disable_lld_caching)) CacheMode.whole else options.cache_mode; | 1176 | CacheMode.whole |
| 1177 | else | ||
| 1178 | options.cache_mode; | ||
| 1186 | 1179 | ||
| 1187 | const tsan = options.want_tsan orelse false; | 1180 | const tsan = options.want_tsan orelse false; |
| 1188 | // TSAN is implemented in C++ so it requires linking libc++. | 1181 | // TSAN is implemented in C++ so it requires linking libc++. |
| ... | @@ -1545,7 +1538,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1545,7 +1538,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1545 | // Synchronize with other matching comments: ZigOnlyHashStuff | 1538 | // Synchronize with other matching comments: ZigOnlyHashStuff |
| 1546 | hash.add(valgrind); | 1539 | hash.add(valgrind); |
| 1547 | hash.add(single_threaded); | 1540 | hash.add(single_threaded); |
| 1548 | hash.add(use_stage1); | ||
| 1549 | hash.add(use_llvm); | 1541 | hash.add(use_llvm); |
| 1550 | hash.add(dll_export_fns); | 1542 | hash.add(dll_export_fns); |
| 1551 | hash.add(options.is_test); | 1543 | hash.add(options.is_test); |
| ... | @@ -1587,9 +1579,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1587,9 +1579,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1587 | .handle = artifact_dir, | 1579 | .handle = artifact_dir, |
| 1588 | .path = try options.local_cache_directory.join(arena, &[_][]const u8{artifact_sub_dir}), | 1580 | .path = try options.local_cache_directory.join(arena, &[_][]const u8{artifact_sub_dir}), |
| 1589 | }; | 1581 | }; |
| 1590 | log.debug("zig_cache_artifact_directory='{?s}' use_stage1={}", .{ | ||
| 1591 | zig_cache_artifact_directory.path, use_stage1, | ||
| 1592 | }); | ||
| 1593 | 1582 | ||
| 1594 | const builtin_pkg = try Package.createWithDir( | 1583 | const builtin_pkg = try Package.createWithDir( |
| 1595 | gpa, | 1584 | gpa, |
| ... | @@ -1907,7 +1896,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1907,7 +1896,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1907 | .subsystem = options.subsystem, | 1896 | .subsystem = options.subsystem, |
| 1908 | .is_test = options.is_test, | 1897 | .is_test = options.is_test, |
| 1909 | .wasi_exec_model = wasi_exec_model, | 1898 | .wasi_exec_model = wasi_exec_model, |
| 1910 | .use_stage1 = use_stage1, | ||
| 1911 | .hash_style = options.hash_style, | 1899 | .hash_style = options.hash_style, |
| 1912 | .enable_link_snapshots = options.enable_link_snapshots, | 1900 | .enable_link_snapshots = options.enable_link_snapshots, |
| 1913 | .native_darwin_sdk = options.native_darwin_sdk, | 1901 | .native_darwin_sdk = options.native_darwin_sdk, |
| ... | @@ -2344,7 +2332,6 @@ pub fn update(comp: *Compilation) !void { | ... | @@ -2344,7 +2332,6 @@ pub fn update(comp: *Compilation) !void { |
| 2344 | comp.c_object_work_queue.writeItemAssumeCapacity(key); | 2332 | comp.c_object_work_queue.writeItemAssumeCapacity(key); |
| 2345 | } | 2333 | } |
| 2346 | 2334 | ||
| 2347 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | ||
| 2348 | if (comp.bin_file.options.module) |module| { | 2335 | if (comp.bin_file.options.module) |module| { |
| 2349 | module.compile_log_text.shrinkAndFree(module.gpa, 0); | 2336 | module.compile_log_text.shrinkAndFree(module.gpa, 0); |
| 2350 | module.generation += 1; | 2337 | module.generation += 1; |
| ... | @@ -2360,7 +2347,7 @@ pub fn update(comp: *Compilation) !void { | ... | @@ -2360,7 +2347,7 @@ pub fn update(comp: *Compilation) !void { |
| 2360 | // import_table here. | 2347 | // import_table here. |
| 2361 | // Likewise, in the case of `zig test`, the test runner is the root source file, | 2348 | // Likewise, in the case of `zig test`, the test runner is the root source file, |
| 2362 | // and so there is nothing to import the main file. | 2349 | // and so there is nothing to import the main file. |
| 2363 | if (use_stage1 or comp.bin_file.options.is_test) { | 2350 | if (comp.bin_file.options.is_test) { |
| 2364 | _ = try module.importPkg(module.main_pkg); | 2351 | _ = try module.importPkg(module.main_pkg); |
| 2365 | } | 2352 | } |
| 2366 | 2353 | ||
| ... | @@ -2374,21 +2361,19 @@ pub fn update(comp: *Compilation) !void { | ... | @@ -2374,21 +2361,19 @@ pub fn update(comp: *Compilation) !void { |
| 2374 | comp.astgen_work_queue.writeItemAssumeCapacity(value); | 2361 | comp.astgen_work_queue.writeItemAssumeCapacity(value); |
| 2375 | } | 2362 | } |
| 2376 | 2363 | ||
| 2377 | if (!use_stage1) { | 2364 | // Put a work item in for checking if any files used with `@embedFile` changed. |
| 2378 | // Put a work item in for checking if any files used with `@embedFile` changed. | 2365 | { |
| 2379 | { | 2366 | try comp.embed_file_work_queue.ensureUnusedCapacity(module.embed_table.count()); |
| 2380 | try comp.embed_file_work_queue.ensureUnusedCapacity(module.embed_table.count()); | 2367 | var it = module.embed_table.iterator(); |
| 2381 | var it = module.embed_table.iterator(); | 2368 | while (it.next()) |entry| { |
| 2382 | while (it.next()) |entry| { | 2369 | const embed_file = entry.value_ptr.*; |
| 2383 | const embed_file = entry.value_ptr.*; | 2370 | comp.embed_file_work_queue.writeItemAssumeCapacity(embed_file); |
| 2384 | comp.embed_file_work_queue.writeItemAssumeCapacity(embed_file); | ||
| 2385 | } | ||
| 2386 | } | 2371 | } |
| 2372 | } | ||
| 2387 | 2373 | ||
| 2388 | try comp.work_queue.writeItem(.{ .analyze_pkg = std_pkg }); | 2374 | try comp.work_queue.writeItem(.{ .analyze_pkg = std_pkg }); |
| 2389 | if (comp.bin_file.options.is_test) { | 2375 | if (comp.bin_file.options.is_test) { |
| 2390 | try comp.work_queue.writeItem(.{ .analyze_pkg = module.main_pkg }); | 2376 | try comp.work_queue.writeItem(.{ .analyze_pkg = module.main_pkg }); |
| 2391 | } | ||
| 2392 | } | 2377 | } |
| 2393 | } | 2378 | } |
| 2394 | 2379 | ||
| ... | @@ -2400,36 +2385,34 @@ pub fn update(comp: *Compilation) !void { | ... | @@ -2400,36 +2385,34 @@ pub fn update(comp: *Compilation) !void { |
| 2400 | 2385 | ||
| 2401 | try comp.performAllTheWork(main_progress_node); | 2386 | try comp.performAllTheWork(main_progress_node); |
| 2402 | 2387 | ||
| 2403 | if (!use_stage1) { | 2388 | if (comp.bin_file.options.module) |module| { |
| 2404 | if (comp.bin_file.options.module) |module| { | 2389 | if (comp.bin_file.options.is_test and comp.totalErrorCount() == 0) { |
| 2405 | if (comp.bin_file.options.is_test and comp.totalErrorCount() == 0) { | 2390 | // The `test_functions` decl has been intentionally postponed until now, |
| 2406 | // The `test_functions` decl has been intentionally postponed until now, | 2391 | // at which point we must populate it with the list of test functions that |
| 2407 | // at which point we must populate it with the list of test functions that | 2392 | // have been discovered and not filtered out. |
| 2408 | // have been discovered and not filtered out. | 2393 | try module.populateTestFunctions(main_progress_node); |
| 2409 | try module.populateTestFunctions(main_progress_node); | 2394 | } |
| 2410 | } | ||
| 2411 | 2395 | ||
| 2412 | // Process the deletion set. We use a while loop here because the | 2396 | // Process the deletion set. We use a while loop here because the |
| 2413 | // deletion set may grow as we call `clearDecl` within this loop, | 2397 | // deletion set may grow as we call `clearDecl` within this loop, |
| 2414 | // and more unreferenced Decls are revealed. | 2398 | // and more unreferenced Decls are revealed. |
| 2415 | while (module.deletion_set.count() != 0) { | 2399 | while (module.deletion_set.count() != 0) { |
| 2416 | const decl_index = module.deletion_set.keys()[0]; | 2400 | const decl_index = module.deletion_set.keys()[0]; |
| 2417 | const decl = module.declPtr(decl_index); | 2401 | const decl = module.declPtr(decl_index); |
| 2418 | assert(decl.deletion_flag); | 2402 | assert(decl.deletion_flag); |
| 2419 | assert(decl.dependants.count() == 0); | 2403 | assert(decl.dependants.count() == 0); |
| 2420 | const is_anon = if (decl.zir_decl_index == 0) blk: { | 2404 | const is_anon = if (decl.zir_decl_index == 0) blk: { |
| 2421 | break :blk decl.src_namespace.anon_decls.swapRemove(decl_index); | 2405 | break :blk decl.src_namespace.anon_decls.swapRemove(decl_index); |
| 2422 | } else false; | 2406 | } else false; |
| 2423 | 2407 | ||
| 2424 | try module.clearDecl(decl_index, null); | 2408 | try module.clearDecl(decl_index, null); |
| 2425 | |||
| 2426 | if (is_anon) { | ||
| 2427 | module.destroyDecl(decl_index); | ||
| 2428 | } | ||
| 2429 | } | ||
| 2430 | 2409 | ||
| 2431 | try module.processExports(); | 2410 | if (is_anon) { |
| 2411 | module.destroyDecl(decl_index); | ||
| 2412 | } | ||
| 2432 | } | 2413 | } |
| 2414 | |||
| 2415 | try module.processExports(); | ||
| 2433 | } | 2416 | } |
| 2434 | 2417 | ||
| 2435 | if (comp.totalErrorCount() != 0) { | 2418 | if (comp.totalErrorCount() != 0) { |
| ... | @@ -2536,11 +2519,8 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void { | ... | @@ -2536,11 +2519,8 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 2536 | }; | 2519 | }; |
| 2537 | comp.link_error_flags = comp.bin_file.errorFlags(); | 2520 | comp.link_error_flags = comp.bin_file.errorFlags(); |
| 2538 | 2521 | ||
| 2539 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | 2522 | if (comp.bin_file.options.module) |module| { |
| 2540 | if (!use_stage1) { | 2523 | try link.File.C.flushEmitH(module); |
| 2541 | if (comp.bin_file.options.module) |module| { | ||
| 2542 | try link.File.C.flushEmitH(module); | ||
| 2543 | } | ||
| 2544 | } | 2524 | } |
| 2545 | } | 2525 | } |
| 2546 | 2526 | ||
| ... | @@ -2610,7 +2590,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes | ... | @@ -2610,7 +2590,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes |
| 2610 | // Synchronize with other matching comments: ZigOnlyHashStuff | 2590 | // Synchronize with other matching comments: ZigOnlyHashStuff |
| 2611 | man.hash.add(comp.bin_file.options.valgrind); | 2591 | man.hash.add(comp.bin_file.options.valgrind); |
| 2612 | man.hash.add(comp.bin_file.options.single_threaded); | 2592 | man.hash.add(comp.bin_file.options.single_threaded); |
| 2613 | man.hash.add(comp.bin_file.options.use_stage1); | ||
| 2614 | man.hash.add(comp.bin_file.options.use_llvm); | 2593 | man.hash.add(comp.bin_file.options.use_llvm); |
| 2615 | man.hash.add(comp.bin_file.options.dll_export_fns); | 2594 | man.hash.add(comp.bin_file.options.dll_export_fns); |
| 2616 | man.hash.add(comp.bin_file.options.is_test); | 2595 | man.hash.add(comp.bin_file.options.is_test); |
| ... | @@ -3010,8 +2989,6 @@ pub fn performAllTheWork( | ... | @@ -3010,8 +2989,6 @@ pub fn performAllTheWork( |
| 3010 | comp.work_queue_wait_group.reset(); | 2989 | comp.work_queue_wait_group.reset(); |
| 3011 | defer comp.work_queue_wait_group.wait(); | 2990 | defer comp.work_queue_wait_group.wait(); |
| 3012 | 2991 | ||
| 3013 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | ||
| 3014 | |||
| 3015 | { | 2992 | { |
| 3016 | const astgen_frame = tracy.namedFrame("astgen"); | 2993 | const astgen_frame = tracy.namedFrame("astgen"); |
| 3017 | defer astgen_frame.end(); | 2994 | defer astgen_frame.end(); |
| ... | @@ -3056,7 +3033,7 @@ pub fn performAllTheWork( | ... | @@ -3056,7 +3033,7 @@ pub fn performAllTheWork( |
| 3056 | } | 3033 | } |
| 3057 | } | 3034 | } |
| 3058 | 3035 | ||
| 3059 | if (!use_stage1) { | 3036 | { |
| 3060 | const outdated_and_deleted_decls_frame = tracy.namedFrame("outdated_and_deleted_decls"); | 3037 | const outdated_and_deleted_decls_frame = tracy.namedFrame("outdated_and_deleted_decls"); |
| 3061 | defer outdated_and_deleted_decls_frame.end(); | 3038 | defer outdated_and_deleted_decls_frame.end(); |
| 3062 | 3039 | ||
| ... | @@ -3064,15 +3041,6 @@ pub fn performAllTheWork( | ... | @@ -3064,15 +3041,6 @@ pub fn performAllTheWork( |
| 3064 | if (comp.bin_file.options.module) |mod| { | 3041 | if (comp.bin_file.options.module) |mod| { |
| 3065 | try mod.processOutdatedAndDeletedDecls(); | 3042 | try mod.processOutdatedAndDeletedDecls(); |
| 3066 | } | 3043 | } |
| 3067 | } else if (comp.bin_file.options.module) |mod| { | ||
| 3068 | // If there are any AstGen compile errors, report them now to avoid | ||
| 3069 | // hitting stage1 bugs. | ||
| 3070 | if (mod.failed_files.count() != 0) { | ||
| 3071 | return; | ||
| 3072 | } | ||
| 3073 | comp.updateStage1Module(main_progress_node) catch |err| { | ||
| 3074 | fatal("unable to build stage1 zig object: {s}", .{@errorName(err)}); | ||
| 3075 | }; | ||
| 3076 | } | 3044 | } |
| 3077 | 3045 | ||
| 3078 | if (comp.bin_file.options.module) |mod| { | 3046 | if (comp.bin_file.options.module) |mod| { |
| ... | @@ -3598,10 +3566,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { | ... | @@ -3598,10 +3566,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 3598 | var man = comp.obtainCObjectCacheManifest(); | 3566 | var man = comp.obtainCObjectCacheManifest(); |
| 3599 | defer man.deinit(); | 3567 | defer man.deinit(); |
| 3600 | 3568 | ||
| 3601 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | ||
| 3602 | |||
| 3603 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects | 3569 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects |
| 3604 | man.hash.add(use_stage1); | ||
| 3605 | man.hash.addBytes(c_src); | 3570 | man.hash.addBytes(c_src); |
| 3606 | 3571 | ||
| 3607 | // If the previous invocation resulted in clang errors, we will see a hit | 3572 | // If the previous invocation resulted in clang errors, we will see a hit |
| ... | @@ -3665,7 +3630,6 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { | ... | @@ -3665,7 +3630,6 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 3665 | new_argv.ptr + new_argv.len, | 3630 | new_argv.ptr + new_argv.len, |
| 3666 | &clang_errors, | 3631 | &clang_errors, |
| 3667 | c_headers_dir_path_z, | 3632 | c_headers_dir_path_z, |
| 3668 | use_stage1, | ||
| 3669 | ) catch |err| switch (err) { | 3633 | ) catch |err| switch (err) { |
| 3670 | error.OutOfMemory => return error.OutOfMemory, | 3634 | error.OutOfMemory => return error.OutOfMemory, |
| 3671 | error.ASTUnitFailure => { | 3635 | error.ASTUnitFailure => { |
| ... | @@ -5097,8 +5061,6 @@ pub fn dump_argv(argv: []const []const u8) void { | ... | @@ -5097,8 +5061,6 @@ pub fn dump_argv(argv: []const []const u8) void { |
| 5097 | } | 5061 | } |
| 5098 | 5062 | ||
| 5099 | pub fn getZigBackend(comp: Compilation) std.builtin.CompilerBackend { | 5063 | pub fn getZigBackend(comp: Compilation) std.builtin.CompilerBackend { |
| 5100 | const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1; | ||
| 5101 | if (use_stage1) return .stage1; | ||
| 5102 | if (build_options.have_llvm and comp.bin_file.options.use_llvm) return .stage2_llvm; | 5064 | if (build_options.have_llvm and comp.bin_file.options.use_llvm) return .stage2_llvm; |
| 5103 | const target = comp.bin_file.options.target; | 5065 | const target = comp.bin_file.options.target; |
| 5104 | if (target.ofmt == .c) return .stage2_c; | 5066 | if (target.ofmt == .c) return .stage2_c; |
| ... | @@ -5394,7 +5356,6 @@ fn buildOutputFromZig( | ... | @@ -5394,7 +5356,6 @@ fn buildOutputFromZig( |
| 5394 | .link_mode = .Static, | 5356 | .link_mode = .Static, |
| 5395 | .function_sections = true, | 5357 | .function_sections = true, |
| 5396 | .no_builtin = true, | 5358 | .no_builtin = true, |
| 5397 | .use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1, | ||
| 5398 | .want_sanitize_c = false, | 5359 | .want_sanitize_c = false, |
| 5399 | .want_stack_check = false, | 5360 | .want_stack_check = false, |
| 5400 | .want_stack_protector = 0, | 5361 | .want_stack_protector = 0, |
src/Sema.zig-2| ... | @@ -2121,8 +2121,6 @@ fn failWithUseOfAsync(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError | ... | @@ -2121,8 +2121,6 @@ fn failWithUseOfAsync(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError |
| 2121 | const msg = msg: { | 2121 | const msg = msg: { |
| 2122 | const msg = try sema.errMsg(block, src, "async has not been implemented in the self-hosted compiler yet", .{}); | 2122 | const msg = try sema.errMsg(block, src, "async has not been implemented in the self-hosted compiler yet", .{}); |
| 2123 | errdefer msg.destroy(sema.gpa); | 2123 | errdefer msg.destroy(sema.gpa); |
| 2124 | |||
| 2125 | try sema.errNote(block, src, msg, "to use async enable the stage1 compiler with either '-fstage1' or by setting '.use_stage1 = true` in your 'build.zig' script", .{}); | ||
| 2126 | break :msg msg; | 2124 | break :msg msg; |
| 2127 | }; | 2125 | }; |
| 2128 | return sema.failWithOwnedErrorMsg(msg); | 2126 | return sema.failWithOwnedErrorMsg(msg); |
src/link.zig+2-21| ... | @@ -155,7 +155,6 @@ pub const Options = struct { | ... | @@ -155,7 +155,6 @@ pub const Options = struct { |
| 155 | build_id: bool, | 155 | build_id: bool, |
| 156 | disable_lld_caching: bool, | 156 | disable_lld_caching: bool, |
| 157 | is_test: bool, | 157 | is_test: bool, |
| 158 | use_stage1: bool, | ||
| 159 | hash_style: HashStyle, | 158 | hash_style: HashStyle, |
| 160 | major_subsystem_version: ?u32, | 159 | major_subsystem_version: ?u32, |
| 161 | minor_subsystem_version: ?u32, | 160 | minor_subsystem_version: ?u32, |
| ... | @@ -293,8 +292,7 @@ pub const File = struct { | ... | @@ -293,8 +292,7 @@ pub const File = struct { |
| 293 | return &(try MachO.openPath(allocator, options)).base; | 292 | return &(try MachO.openPath(allocator, options)).base; |
| 294 | } | 293 | } |
| 295 | 294 | ||
| 296 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | 295 | if (options.emit == null) { |
| 297 | if (use_stage1 or options.emit == null) { | ||
| 298 | return switch (options.target.ofmt) { | 296 | return switch (options.target.ofmt) { |
| 299 | .coff => &(try Coff.createEmpty(allocator, options)).base, | 297 | .coff => &(try Coff.createEmpty(allocator, options)).base, |
| 300 | .elf => &(try Elf.createEmpty(allocator, options)).base, | 298 | .elf => &(try Elf.createEmpty(allocator, options)).base, |
| ... | @@ -983,24 +981,7 @@ pub const File = struct { | ... | @@ -983,24 +981,7 @@ pub const File = struct { |
| 983 | 981 | ||
| 984 | // If there is no Zig code to compile, then we should skip flushing the output file | 982 | // If there is no Zig code to compile, then we should skip flushing the output file |
| 985 | // because it will not be part of the linker line anyway. | 983 | // because it will not be part of the linker line anyway. |
| 986 | const module_obj_path: ?[]const u8 = if (base.options.module) |module| blk: { | 984 | const module_obj_path: ?[]const u8 = if (base.options.module != null) blk: { |
| 987 | const use_stage1 = build_options.have_stage1 and base.options.use_stage1; | ||
| 988 | if (use_stage1) { | ||
| 989 | const obj_basename = try std.zig.binNameAlloc(arena, .{ | ||
| 990 | .root_name = base.options.root_name, | ||
| 991 | .target = base.options.target, | ||
| 992 | .output_mode = .Obj, | ||
| 993 | }); | ||
| 994 | switch (base.options.cache_mode) { | ||
| 995 | .incremental => break :blk try module.zig_cache_artifact_directory.join( | ||
| 996 | arena, | ||
| 997 | &[_][]const u8{obj_basename}, | ||
| 998 | ), | ||
| 999 | .whole => break :blk try fs.path.join(arena, &.{ | ||
| 1000 | fs.path.dirname(full_out_path_z).?, obj_basename, | ||
| 1001 | }), | ||
| 1002 | } | ||
| 1003 | } | ||
| 1004 | try base.flushModule(comp, prog_node); | 985 | try base.flushModule(comp, prog_node); |
| 1005 | 986 | ||
| 1006 | const dirname = fs.path.dirname(full_out_path_z) orelse "."; | 987 | const dirname = fs.path.dirname(full_out_path_z) orelse "."; |
src/link/Coff.zig+1-2| ... | @@ -248,8 +248,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff { | ... | @@ -248,8 +248,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff { |
| 248 | }; | 248 | }; |
| 249 | 249 | ||
| 250 | const use_llvm = build_options.have_llvm and options.use_llvm; | 250 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 251 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | 251 | if (use_llvm) { |
| 252 | if (use_llvm and !use_stage1) { | ||
| 253 | self.llvm_object = try LlvmObject.create(gpa, options); | 252 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 254 | } | 253 | } |
| 255 | return self; | 254 | return self; |
src/link/Coff/lld.zig+1-19| ... | @@ -30,25 +30,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod | ... | @@ -30,25 +30,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 30 | 30 | ||
| 31 | // If there is no Zig code to compile, then we should skip flushing the output file because it | 31 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 32 | // will not be part of the linker line anyway. | 32 | // will not be part of the linker line anyway. |
| 33 | const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: { | 33 | const module_obj_path: ?[]const u8 = if (self.base.options.module != null) blk: { |
| 34 | const use_stage1 = build_options.have_stage1 and self.base.options.use_stage1; | ||
| 35 | if (use_stage1) { | ||
| 36 | const obj_basename = try std.zig.binNameAlloc(arena, .{ | ||
| 37 | .root_name = self.base.options.root_name, | ||
| 38 | .target = self.base.options.target, | ||
| 39 | .output_mode = .Obj, | ||
| 40 | }); | ||
| 41 | switch (self.base.options.cache_mode) { | ||
| 42 | .incremental => break :blk try module.zig_cache_artifact_directory.join( | ||
| 43 | arena, | ||
| 44 | &[_][]const u8{obj_basename}, | ||
| 45 | ), | ||
| 46 | .whole => break :blk try fs.path.join(arena, &.{ | ||
| 47 | fs.path.dirname(full_out_path).?, obj_basename, | ||
| 48 | }), | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | try self.flushModule(comp, prog_node); | 34 | try self.flushModule(comp, prog_node); |
| 53 | 35 | ||
| 54 | if (fs.path.dirname(full_out_path)) |dirname| { | 36 | if (fs.path.dirname(full_out_path)) |dirname| { |
src/link/Elf.zig+2-21| ... | @@ -328,8 +328,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { | ... | @@ -328,8 +328,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { |
| 328 | .page_size = page_size, | 328 | .page_size = page_size, |
| 329 | }; | 329 | }; |
| 330 | const use_llvm = build_options.have_llvm and options.use_llvm; | 330 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 331 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | 331 | if (use_llvm) { |
| 332 | if (use_llvm and !use_stage1) { | ||
| 333 | self.llvm_object = try LlvmObject.create(gpa, options); | 332 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 334 | } | 333 | } |
| 335 | return self; | 334 | return self; |
| ... | @@ -1228,25 +1227,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v | ... | @@ -1228,25 +1227,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v |
| 1228 | 1227 | ||
| 1229 | // If there is no Zig code to compile, then we should skip flushing the output file because it | 1228 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 1230 | // will not be part of the linker line anyway. | 1229 | // will not be part of the linker line anyway. |
| 1231 | const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: { | 1230 | const module_obj_path: ?[]const u8 = if (self.base.options.module != null) blk: { |
| 1232 | // stage1 puts the object file in the cache directory. | ||
| 1233 | if (self.base.options.use_stage1) { | ||
| 1234 | const obj_basename = try std.zig.binNameAlloc(arena, .{ | ||
| 1235 | .root_name = self.base.options.root_name, | ||
| 1236 | .target = self.base.options.target, | ||
| 1237 | .output_mode = .Obj, | ||
| 1238 | }); | ||
| 1239 | switch (self.base.options.cache_mode) { | ||
| 1240 | .incremental => break :blk try module.zig_cache_artifact_directory.join( | ||
| 1241 | arena, | ||
| 1242 | &[_][]const u8{obj_basename}, | ||
| 1243 | ), | ||
| 1244 | .whole => break :blk try fs.path.join(arena, &.{ | ||
| 1245 | fs.path.dirname(full_out_path).?, obj_basename, | ||
| 1246 | }), | ||
| 1247 | } | ||
| 1248 | } | ||
| 1249 | |||
| 1250 | try self.flushModule(comp, prog_node); | 1231 | try self.flushModule(comp, prog_node); |
| 1251 | 1232 | ||
| 1252 | if (fs.path.dirname(full_out_path)) |dirname| { | 1233 | if (fs.path.dirname(full_out_path)) |dirname| { |
src/link/MachO.zig+3-5| ... | @@ -290,8 +290,7 @@ pub const Export = struct { | ... | @@ -290,8 +290,7 @@ pub const Export = struct { |
| 290 | pub fn openPath(allocator: Allocator, options: link.Options) !*MachO { | 290 | pub fn openPath(allocator: Allocator, options: link.Options) !*MachO { |
| 291 | assert(options.target.ofmt == .macho); | 291 | assert(options.target.ofmt == .macho); |
| 292 | 292 | ||
| 293 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | 293 | if (options.emit == null or options.module == null) { |
| 294 | if (use_stage1 or options.emit == null or options.module == null) { | ||
| 295 | return createEmpty(allocator, options); | 294 | return createEmpty(allocator, options); |
| 296 | } | 295 | } |
| 297 | 296 | ||
| ... | @@ -377,7 +376,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { | ... | @@ -377,7 +376,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { |
| 377 | const cpu_arch = options.target.cpu.arch; | 376 | const cpu_arch = options.target.cpu.arch; |
| 378 | const page_size: u16 = if (cpu_arch == .aarch64) 0x4000 else 0x1000; | 377 | const page_size: u16 = if (cpu_arch == .aarch64) 0x4000 else 0x1000; |
| 379 | const use_llvm = build_options.have_llvm and options.use_llvm; | 378 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 380 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | ||
| 381 | 379 | ||
| 382 | const self = try gpa.create(MachO); | 380 | const self = try gpa.create(MachO); |
| 383 | errdefer gpa.destroy(self); | 381 | errdefer gpa.destroy(self); |
| ... | @@ -390,13 +388,13 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { | ... | @@ -390,13 +388,13 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { |
| 390 | .file = null, | 388 | .file = null, |
| 391 | }, | 389 | }, |
| 392 | .page_size = page_size, | 390 | .page_size = page_size, |
| 393 | .mode = if (use_stage1 or use_llvm or options.module == null or options.cache_mode == .whole) | 391 | .mode = if (use_llvm or options.module == null or options.cache_mode == .whole) |
| 394 | .one_shot | 392 | .one_shot |
| 395 | else | 393 | else |
| 396 | .incremental, | 394 | .incremental, |
| 397 | }; | 395 | }; |
| 398 | 396 | ||
| 399 | if (use_llvm and !use_stage1) { | 397 | if (use_llvm) { |
| 400 | self.llvm_object = try LlvmObject.create(gpa, options); | 398 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 401 | } | 399 | } |
| 402 | 400 |
src/link/MachO/zld.zig+1-18| ... | @@ -3746,24 +3746,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr | ... | @@ -3746,24 +3746,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr |
| 3746 | 3746 | ||
| 3747 | // If there is no Zig code to compile, then we should skip flushing the output file because it | 3747 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 3748 | // will not be part of the linker line anyway. | 3748 | // will not be part of the linker line anyway. |
| 3749 | const module_obj_path: ?[]const u8 = if (options.module) |module| blk: { | 3749 | const module_obj_path: ?[]const u8 = if (options.module != null) blk: { |
| 3750 | if (options.use_stage1) { | ||
| 3751 | const obj_basename = try std.zig.binNameAlloc(arena, .{ | ||
| 3752 | .root_name = options.root_name, | ||
| 3753 | .target = target, | ||
| 3754 | .output_mode = .Obj, | ||
| 3755 | }); | ||
| 3756 | switch (options.cache_mode) { | ||
| 3757 | .incremental => break :blk try module.zig_cache_artifact_directory.join( | ||
| 3758 | arena, | ||
| 3759 | &[_][]const u8{obj_basename}, | ||
| 3760 | ), | ||
| 3761 | .whole => break :blk try fs.path.join(arena, &.{ | ||
| 3762 | fs.path.dirname(full_out_path).?, obj_basename, | ||
| 3763 | }), | ||
| 3764 | } | ||
| 3765 | } | ||
| 3766 | |||
| 3767 | try macho_file.flushModule(comp, prog_node); | 3750 | try macho_file.flushModule(comp, prog_node); |
| 3768 | 3751 | ||
| 3769 | if (fs.path.dirname(full_out_path)) |dirname| { | 3752 | if (fs.path.dirname(full_out_path)) |dirname| { |
src/link/Wasm.zig+14-40| ... | @@ -382,8 +382,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Wasm { | ... | @@ -382,8 +382,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Wasm { |
| 382 | }; | 382 | }; |
| 383 | 383 | ||
| 384 | const use_llvm = build_options.have_llvm and options.use_llvm; | 384 | const use_llvm = build_options.have_llvm and options.use_llvm; |
| 385 | const use_stage1 = build_options.have_stage1 and options.use_stage1; | 385 | if (use_llvm) { |
| 386 | if (use_llvm and !use_stage1) { | ||
| 387 | wasm.llvm_object = try LlvmObject.create(gpa, options); | 386 | wasm.llvm_object = try LlvmObject.create(gpa, options); |
| 388 | } | 387 | } |
| 389 | return wasm; | 388 | return wasm; |
| ... | @@ -2986,25 +2985,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! | ... | @@ -2986,25 +2985,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! |
| 2986 | 2985 | ||
| 2987 | // If there is no Zig code to compile, then we should skip flushing the output file because it | 2986 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 2988 | // will not be part of the linker line anyway. | 2987 | // will not be part of the linker line anyway. |
| 2989 | const module_obj_path: ?[]const u8 = if (wasm.base.options.module) |mod| blk: { | 2988 | const module_obj_path: ?[]const u8 = if (wasm.base.options.module != null) blk: { |
| 2990 | const use_stage1 = build_options.have_stage1 and wasm.base.options.use_stage1; | ||
| 2991 | if (use_stage1) { | ||
| 2992 | const obj_basename = try std.zig.binNameAlloc(arena, .{ | ||
| 2993 | .root_name = wasm.base.options.root_name, | ||
| 2994 | .target = wasm.base.options.target, | ||
| 2995 | .output_mode = .Obj, | ||
| 2996 | }); | ||
| 2997 | switch (wasm.base.options.cache_mode) { | ||
| 2998 | .incremental => break :blk try mod.zig_cache_artifact_directory.join( | ||
| 2999 | arena, | ||
| 3000 | &[_][]const u8{obj_basename}, | ||
| 3001 | ), | ||
| 3002 | .whole => break :blk try fs.path.join(arena, &.{ | ||
| 3003 | fs.path.dirname(full_out_path).?, obj_basename, | ||
| 3004 | }), | ||
| 3005 | } | ||
| 3006 | } | ||
| 3007 | |||
| 3008 | try wasm.flushModule(comp, prog_node); | 2989 | try wasm.flushModule(comp, prog_node); |
| 3009 | 2990 | ||
| 3010 | if (fs.path.dirname(full_out_path)) |dirname| { | 2991 | if (fs.path.dirname(full_out_path)) |dirname| { |
| ... | @@ -3198,26 +3179,19 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! | ... | @@ -3198,26 +3179,19 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! |
| 3198 | if (wasm.base.options.module) |mod| { | 3179 | if (wasm.base.options.module) |mod| { |
| 3199 | // when we use stage1, we use the exports that stage1 provided us. | 3180 | // when we use stage1, we use the exports that stage1 provided us. |
| 3200 | // For stage2, we can directly retrieve them from the module. | 3181 | // For stage2, we can directly retrieve them from the module. |
| 3201 | const use_stage1 = build_options.have_stage1 and wasm.base.options.use_stage1; | 3182 | const skip_export_non_fn = target.os.tag == .wasi and |
| 3202 | if (use_stage1) { | 3183 | wasm.base.options.wasi_exec_model == .command; |
| 3203 | for (comp.export_symbol_names.items) |symbol_name| { | 3184 | for (mod.decl_exports.values()) |exports| { |
| 3204 | try argv.append(try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name})); | 3185 | for (exports.items) |exprt| { |
| 3205 | } | 3186 | const exported_decl = mod.declPtr(exprt.exported_decl); |
| 3206 | } else { | 3187 | if (skip_export_non_fn and exported_decl.ty.zigTypeTag() != .Fn) { |
| 3207 | const skip_export_non_fn = target.os.tag == .wasi and | 3188 | // skip exporting symbols when we're building a WASI command |
| 3208 | wasm.base.options.wasi_exec_model == .command; | 3189 | // and the symbol is not a function |
| 3209 | for (mod.decl_exports.values()) |exports| { | 3190 | continue; |
| 3210 | for (exports.items) |exprt| { | ||
| 3211 | const exported_decl = mod.declPtr(exprt.exported_decl); | ||
| 3212 | if (skip_export_non_fn and exported_decl.ty.zigTypeTag() != .Fn) { | ||
| 3213 | // skip exporting symbols when we're building a WASI command | ||
| 3214 | // and the symbol is not a function | ||
| 3215 | continue; | ||
| 3216 | } | ||
| 3217 | const symbol_name = exported_decl.name; | ||
| 3218 | const arg = try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name}); | ||
| 3219 | try argv.append(arg); | ||
| 3220 | } | 3191 | } |
| 3192 | const symbol_name = exported_decl.name; | ||
| 3193 | const arg = try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name}); | ||
| 3194 | try argv.append(arg); | ||
| 3221 | } | 3195 | } |
| 3222 | } | 3196 | } |
| 3223 | } | 3197 | } |
src/main.zig+2-23| ... | @@ -394,8 +394,6 @@ const usage_build_generic = | ... | @@ -394,8 +394,6 @@ const usage_build_generic = |
| 394 | \\ -fno-LLVM Prevent using LLVM as the codegen backend | 394 | \\ -fno-LLVM Prevent using LLVM as the codegen backend |
| 395 | \\ -fClang Force using Clang as the C/C++ compilation backend | 395 | \\ -fClang Force using Clang as the C/C++ compilation backend |
| 396 | \\ -fno-Clang Prevent using Clang as the C/C++ compilation backend | 396 | \\ -fno-Clang Prevent using Clang as the C/C++ compilation backend |
| 397 | \\ -fstage1 Force using bootstrap compiler as the codegen backend | ||
| 398 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend | ||
| 399 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error | 397 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error |
| 400 | \\ -fno-reference-trace Disable reference trace | 398 | \\ -fno-reference-trace Disable reference trace |
| 401 | \\ -fsingle-threaded Code assumes there is only one thread | 399 | \\ -fsingle-threaded Code assumes there is only one thread |
| ... | @@ -719,7 +717,6 @@ fn buildOutputType( | ... | @@ -719,7 +717,6 @@ fn buildOutputType( |
| 719 | var use_llvm: ?bool = null; | 717 | var use_llvm: ?bool = null; |
| 720 | var use_lld: ?bool = null; | 718 | var use_lld: ?bool = null; |
| 721 | var use_clang: ?bool = null; | 719 | var use_clang: ?bool = null; |
| 722 | var use_stage1: ?bool = null; | ||
| 723 | var link_eh_frame_hdr = false; | 720 | var link_eh_frame_hdr = false; |
| 724 | var link_emit_relocs = false; | 721 | var link_emit_relocs = false; |
| 725 | var each_lib_rpath: ?bool = null; | 722 | var each_lib_rpath: ?bool = null; |
| ... | @@ -1158,10 +1155,6 @@ fn buildOutputType( | ... | @@ -1158,10 +1155,6 @@ fn buildOutputType( |
| 1158 | use_clang = true; | 1155 | use_clang = true; |
| 1159 | } else if (mem.eql(u8, arg, "-fno-Clang")) { | 1156 | } else if (mem.eql(u8, arg, "-fno-Clang")) { |
| 1160 | use_clang = false; | 1157 | use_clang = false; |
| 1161 | } else if (mem.eql(u8, arg, "-fstage1")) { | ||
| 1162 | use_stage1 = true; | ||
| 1163 | } else if (mem.eql(u8, arg, "-fno-stage1")) { | ||
| 1164 | use_stage1 = false; | ||
| 1165 | } else if (mem.eql(u8, arg, "-freference-trace")) { | 1158 | } else if (mem.eql(u8, arg, "-freference-trace")) { |
| 1166 | reference_trace = 256; | 1159 | reference_trace = 256; |
| 1167 | } else if (mem.startsWith(u8, arg, "-freference-trace=")) { | 1160 | } else if (mem.startsWith(u8, arg, "-freference-trace=")) { |
| ... | @@ -2909,7 +2902,6 @@ fn buildOutputType( | ... | @@ -2909,7 +2902,6 @@ fn buildOutputType( |
| 2909 | .use_llvm = use_llvm, | 2902 | .use_llvm = use_llvm, |
| 2910 | .use_lld = use_lld, | 2903 | .use_lld = use_lld, |
| 2911 | .use_clang = use_clang, | 2904 | .use_clang = use_clang, |
| 2912 | .use_stage1 = use_stage1, | ||
| 2913 | .hash_style = hash_style, | 2905 | .hash_style = hash_style, |
| 2914 | .rdynamic = rdynamic, | 2906 | .rdynamic = rdynamic, |
| 2915 | .linker_script = linker_script, | 2907 | .linker_script = linker_script, |
| ... | @@ -3024,8 +3016,7 @@ fn buildOutputType( | ... | @@ -3024,8 +3016,7 @@ fn buildOutputType( |
| 3024 | return std.io.getStdOut().writeAll(try comp.generateBuiltinZigSource(arena)); | 3016 | return std.io.getStdOut().writeAll(try comp.generateBuiltinZigSource(arena)); |
| 3025 | } | 3017 | } |
| 3026 | if (arg_mode == .translate_c) { | 3018 | if (arg_mode == .translate_c) { |
| 3027 | const stage1_mode = use_stage1 orelse false; | 3019 | return cmdTranslateC(comp, arena, have_enable_cache); |
| 3028 | return cmdTranslateC(comp, arena, have_enable_cache, stage1_mode); | ||
| 3029 | } | 3020 | } |
| 3030 | 3021 | ||
| 3031 | const hook: AfterUpdateHook = blk: { | 3022 | const hook: AfterUpdateHook = blk: { |
| ... | @@ -3444,7 +3435,7 @@ fn freePkgTree(gpa: Allocator, pkg: *Package, free_parent: bool) void { | ... | @@ -3444,7 +3435,7 @@ fn freePkgTree(gpa: Allocator, pkg: *Package, free_parent: bool) void { |
| 3444 | } | 3435 | } |
| 3445 | } | 3436 | } |
| 3446 | 3437 | ||
| 3447 | fn cmdTranslateC(comp: *Compilation, arena: Allocator, enable_cache: bool, stage1_mode: bool) !void { | 3438 | fn cmdTranslateC(comp: *Compilation, arena: Allocator, enable_cache: bool) !void { |
| 3448 | if (!build_options.have_llvm) | 3439 | if (!build_options.have_llvm) |
| 3449 | fatal("cannot translate-c: compiler built without LLVM extensions", .{}); | 3440 | fatal("cannot translate-c: compiler built without LLVM extensions", .{}); |
| 3450 | 3441 | ||
| ... | @@ -3457,7 +3448,6 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, enable_cache: bool, stage | ... | @@ -3457,7 +3448,6 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, enable_cache: bool, stage |
| 3457 | defer if (enable_cache) man.deinit(); | 3448 | defer if (enable_cache) man.deinit(); |
| 3458 | 3449 | ||
| 3459 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects | 3450 | man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects |
| 3460 | man.hash.add(stage1_mode); | ||
| 3461 | man.hashCSource(c_source_file) catch |err| { | 3451 | man.hashCSource(c_source_file) catch |err| { |
| 3462 | fatal("unable to process '{s}': {s}", .{ c_source_file.src_path, @errorName(err) }); | 3452 | fatal("unable to process '{s}': {s}", .{ c_source_file.src_path, @errorName(err) }); |
| 3463 | }; | 3453 | }; |
| ... | @@ -3509,7 +3499,6 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, enable_cache: bool, stage | ... | @@ -3509,7 +3499,6 @@ fn cmdTranslateC(comp: *Compilation, arena: Allocator, enable_cache: bool, stage |
| 3509 | new_argv.ptr + new_argv.len, | 3499 | new_argv.ptr + new_argv.len, |
| 3510 | &clang_errors, | 3500 | &clang_errors, |
| 3511 | c_headers_dir_path_z, | 3501 | c_headers_dir_path_z, |
| 3512 | stage1_mode, | ||
| 3513 | ) catch |err| switch (err) { | 3502 | ) catch |err| switch (err) { |
| 3514 | error.OutOfMemory => return error.OutOfMemory, | 3503 | error.OutOfMemory => return error.OutOfMemory, |
| 3515 | error.ASTUnitFailure => fatal("clang API returned errors but due to a clang bug, it is not exposing the errors for zig to see. For more details: https://github.com/ziglang/zig/issues/4455", .{}), | 3504 | error.ASTUnitFailure => fatal("clang API returned errors but due to a clang bug, it is not exposing the errors for zig to see. For more details: https://github.com/ziglang/zig/issues/4455", .{}), |
| ... | @@ -3755,8 +3744,6 @@ pub const usage_build = | ... | @@ -3755,8 +3744,6 @@ pub const usage_build = |
| 3755 | \\ Build a project from build.zig. | 3744 | \\ Build a project from build.zig. |
| 3756 | \\ | 3745 | \\ |
| 3757 | \\Options: | 3746 | \\Options: |
| 3758 | \\ -fstage1 Force using bootstrap compiler as the codegen backend | ||
| 3759 | \\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend | ||
| 3760 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error | 3747 | \\ -freference-trace[=num] How many lines of reference trace should be shown per compile error |
| 3761 | \\ -fno-reference-trace Disable reference trace | 3748 | \\ -fno-reference-trace Disable reference trace |
| 3762 | \\ --build-file [file] Override path to build.zig | 3749 | \\ --build-file [file] Override path to build.zig |
| ... | @@ -3770,7 +3757,6 @@ pub const usage_build = | ... | @@ -3770,7 +3757,6 @@ pub const usage_build = |
| 3770 | 3757 | ||
| 3771 | pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { | 3758 | pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 3772 | var prominent_compile_errors: bool = false; | 3759 | var prominent_compile_errors: bool = false; |
| 3773 | var use_stage1: ?bool = null; | ||
| 3774 | 3760 | ||
| 3775 | // We want to release all the locks before executing the child process, so we make a nice | 3761 | // We want to release all the locks before executing the child process, so we make a nice |
| 3776 | // big block here to ensure the cleanup gets run when we extract out our argv. | 3762 | // big block here to ensure the cleanup gets run when we extract out our argv. |
| ... | @@ -3827,12 +3813,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi | ... | @@ -3827,12 +3813,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3827 | continue; | 3813 | continue; |
| 3828 | } else if (mem.eql(u8, arg, "--prominent-compile-errors")) { | 3814 | } else if (mem.eql(u8, arg, "--prominent-compile-errors")) { |
| 3829 | prominent_compile_errors = true; | 3815 | prominent_compile_errors = true; |
| 3830 | } else if (mem.eql(u8, arg, "-fstage1")) { | ||
| 3831 | use_stage1 = true; | ||
| 3832 | try child_argv.append(arg); | ||
| 3833 | } else if (mem.eql(u8, arg, "-fno-stage1")) { | ||
| 3834 | use_stage1 = false; | ||
| 3835 | try child_argv.append(arg); | ||
| 3836 | } else if (mem.eql(u8, arg, "-freference-trace")) { | 3816 | } else if (mem.eql(u8, arg, "-freference-trace")) { |
| 3837 | try child_argv.append(arg); | 3817 | try child_argv.append(arg); |
| 3838 | reference_trace = 256; | 3818 | reference_trace = 256; |
| ... | @@ -3979,7 +3959,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi | ... | @@ -3979,7 +3959,6 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3979 | .optimize_mode = .Debug, | 3959 | .optimize_mode = .Debug, |
| 3980 | .self_exe_path = self_exe_path, | 3960 | .self_exe_path = self_exe_path, |
| 3981 | .thread_pool = &thread_pool, | 3961 | .thread_pool = &thread_pool, |
| 3982 | .use_stage1 = use_stage1, | ||
| 3983 | .cache_mode = .whole, | 3962 | .cache_mode = .whole, |
| 3984 | .reference_trace = reference_trace, | 3963 | .reference_trace = reference_trace, |
| 3985 | .debug_compile_errors = debug_compile_errors, | 3964 | .debug_compile_errors = debug_compile_errors, |
src/test.zig-1| ... | @@ -1548,7 +1548,6 @@ pub const TestContext = struct { | ... | @@ -1548,7 +1548,6 @@ pub const TestContext = struct { |
| 1548 | .dynamic_linker = target_info.dynamic_linker.get(), | 1548 | .dynamic_linker = target_info.dynamic_linker.get(), |
| 1549 | .link_libc = case.link_libc, | 1549 | .link_libc = case.link_libc, |
| 1550 | .use_llvm = use_llvm, | 1550 | .use_llvm = use_llvm, |
| 1551 | .use_stage1 = null, // We already handled stage1 tests | ||
| 1552 | .self_exe_path = zig_exe_path, | 1551 | .self_exe_path = zig_exe_path, |
| 1553 | // TODO instead of turning off color, pass in a std.Progress.Node | 1552 | // TODO instead of turning off color, pass in a std.Progress.Node |
| 1554 | .color = .off, | 1553 | .color = .off, |
src/translate_c.zig+3-24| ... | @@ -327,16 +327,6 @@ pub const Context = struct { | ... | @@ -327,16 +327,6 @@ pub const Context = struct { |
| 327 | 327 | ||
| 328 | pattern_list: PatternList, | 328 | pattern_list: PatternList, |
| 329 | 329 | ||
| 330 | /// This is used to emit different code depending on whether | ||
| 331 | /// the output zig source code is intended to be compiled with stage1 or stage2. | ||
| 332 | /// Ideally we will have stage1 and stage2 support the exact same Zig language, | ||
| 333 | /// but for now they diverge because I would rather focus on finishing and shipping | ||
| 334 | /// stage2 than implementing the features in stage1. | ||
| 335 | /// The list of differences are currently: | ||
| 336 | /// * function pointers in stage1 are e.g. `fn()void` | ||
| 337 | /// but in stage2 they are `*const fn()void`. | ||
| 338 | zig_is_stage1: bool, | ||
| 339 | |||
| 340 | fn getMangle(c: *Context) u32 { | 330 | fn getMangle(c: *Context) u32 { |
| 341 | c.mangle_count += 1; | 331 | c.mangle_count += 1; |
| 342 | return c.mangle_count; | 332 | return c.mangle_count; |
| ... | @@ -365,7 +355,6 @@ pub fn translate( | ... | @@ -365,7 +355,6 @@ pub fn translate( |
| 365 | args_end: [*]?[*]const u8, | 355 | args_end: [*]?[*]const u8, |
| 366 | errors: *[]ClangErrMsg, | 356 | errors: *[]ClangErrMsg, |
| 367 | resources_path: [*:0]const u8, | 357 | resources_path: [*:0]const u8, |
| 368 | zig_is_stage1: bool, | ||
| 369 | ) !std.zig.Ast { | 358 | ) !std.zig.Ast { |
| 370 | // TODO stage2 bug | 359 | // TODO stage2 bug |
| 371 | var tmp = errors; | 360 | var tmp = errors; |
| ... | @@ -395,7 +384,6 @@ pub fn translate( | ... | @@ -395,7 +384,6 @@ pub fn translate( |
| 395 | .global_scope = try arena.create(Scope.Root), | 384 | .global_scope = try arena.create(Scope.Root), |
| 396 | .clang_context = ast_unit.getASTContext(), | 385 | .clang_context = ast_unit.getASTContext(), |
| 397 | .pattern_list = try PatternList.init(gpa), | 386 | .pattern_list = try PatternList.init(gpa), |
| 398 | .zig_is_stage1 = zig_is_stage1, | ||
| 399 | }; | 387 | }; |
| 400 | context.global_scope.* = Scope.Root.init(&context); | 388 | context.global_scope.* = Scope.Root.init(&context); |
| 401 | defer { | 389 | defer { |
| ... | @@ -435,7 +423,7 @@ pub fn translate( | ... | @@ -435,7 +423,7 @@ pub fn translate( |
| 435 | } | 423 | } |
| 436 | } | 424 | } |
| 437 | 425 | ||
| 438 | return ast.render(gpa, zig_is_stage1, context.global_scope.nodes.items); | 426 | return ast.render(gpa, context.global_scope.nodes.items); |
| 439 | } | 427 | } |
| 440 | 428 | ||
| 441 | /// Determines whether macro is of the form: `#define FOO FOO` (Possibly with trailing tokens) | 429 | /// Determines whether macro is of the form: `#define FOO FOO` (Possibly with trailing tokens) |
| ... | @@ -4747,9 +4735,6 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan | ... | @@ -4747,9 +4735,6 @@ fn transType(c: *Context, scope: *Scope, ty: *const clang.Type, source_loc: clan |
| 4747 | .Pointer => { | 4735 | .Pointer => { |
| 4748 | const child_qt = ty.getPointeeType(); | 4736 | const child_qt = ty.getPointeeType(); |
| 4749 | const is_fn_proto = qualTypeChildIsFnProto(child_qt); | 4737 | const is_fn_proto = qualTypeChildIsFnProto(child_qt); |
| 4750 | if (c.zig_is_stage1 and is_fn_proto) { | ||
| 4751 | return Tag.optional_type.create(c.arena, try transQualType(c, scope, child_qt, source_loc)); | ||
| 4752 | } | ||
| 4753 | const is_const = is_fn_proto or child_qt.isConstQualified(); | 4738 | const is_const = is_fn_proto or child_qt.isConstQualified(); |
| 4754 | const is_volatile = child_qt.isVolatileQualified(); | 4739 | const is_volatile = child_qt.isVolatileQualified(); |
| 4755 | const elem_type = try transQualType(c, scope, child_qt, source_loc); | 4740 | const elem_type = try transQualType(c, scope, child_qt, source_loc); |
| ... | @@ -6681,16 +6666,10 @@ fn getFnProto(c: *Context, ref: Node) ?*ast.Payload.Func { | ... | @@ -6681,16 +6666,10 @@ fn getFnProto(c: *Context, ref: Node) ?*ast.Payload.Func { |
| 6681 | return null; | 6666 | return null; |
| 6682 | if (getContainerTypeOf(c, init)) |ty_node| { | 6667 | if (getContainerTypeOf(c, init)) |ty_node| { |
| 6683 | if (ty_node.castTag(.optional_type)) |prefix| { | 6668 | if (ty_node.castTag(.optional_type)) |prefix| { |
| 6684 | if (c.zig_is_stage1) { | 6669 | if (prefix.data.castTag(.single_pointer)) |sp| { |
| 6685 | if (prefix.data.castTag(.func)) |fn_proto| { | 6670 | if (sp.data.elem_type.castTag(.func)) |fn_proto| { |
| 6686 | return fn_proto; | 6671 | return fn_proto; |
| 6687 | } | 6672 | } |
| 6688 | } else { | ||
| 6689 | if (prefix.data.castTag(.single_pointer)) |sp| { | ||
| 6690 | if (sp.data.elem_type.castTag(.func)) |fn_proto| { | ||
| 6691 | return fn_proto; | ||
| 6692 | } | ||
| 6693 | } | ||
| 6694 | } | 6673 | } |
| 6695 | } | 6674 | } |
| 6696 | } | 6675 | } |
src/translate_c/ast.zig+17-31| ... | @@ -732,11 +732,10 @@ pub const Payload = struct { | ... | @@ -732,11 +732,10 @@ pub const Payload = struct { |
| 732 | 732 | ||
| 733 | /// Converts the nodes into a Zig Ast. | 733 | /// Converts the nodes into a Zig Ast. |
| 734 | /// Caller must free the source slice. | 734 | /// Caller must free the source slice. |
| 735 | pub fn render(gpa: Allocator, zig_is_stage1: bool, nodes: []const Node) !std.zig.Ast { | 735 | pub fn render(gpa: Allocator, nodes: []const Node) !std.zig.Ast { |
| 736 | var ctx = Context{ | 736 | var ctx = Context{ |
| 737 | .gpa = gpa, | 737 | .gpa = gpa, |
| 738 | .buf = std.ArrayList(u8).init(gpa), | 738 | .buf = std.ArrayList(u8).init(gpa), |
| 739 | .zig_is_stage1 = zig_is_stage1, | ||
| 740 | }; | 739 | }; |
| 741 | defer ctx.buf.deinit(); | 740 | defer ctx.buf.deinit(); |
| 742 | defer ctx.nodes.deinit(gpa); | 741 | defer ctx.nodes.deinit(gpa); |
| ... | @@ -805,11 +804,6 @@ const Context = struct { | ... | @@ -805,11 +804,6 @@ const Context = struct { |
| 805 | extra_data: std.ArrayListUnmanaged(std.zig.Ast.Node.Index) = .{}, | 804 | extra_data: std.ArrayListUnmanaged(std.zig.Ast.Node.Index) = .{}, |
| 806 | tokens: std.zig.Ast.TokenList = .{}, | 805 | tokens: std.zig.Ast.TokenList = .{}, |
| 807 | 806 | ||
| 808 | /// This is used to emit different code depending on whether | ||
| 809 | /// the output zig source code is intended to be compiled with stage1 or stage2. | ||
| 810 | /// Refer to the Context in translate_c.zig. | ||
| 811 | zig_is_stage1: bool, | ||
| 812 | |||
| 813 | fn addTokenFmt(c: *Context, tag: TokenTag, comptime format: []const u8, args: anytype) Allocator.Error!TokenIndex { | 807 | fn addTokenFmt(c: *Context, tag: TokenTag, comptime format: []const u8, args: anytype) Allocator.Error!TokenIndex { |
| 814 | const start_index = c.buf.items.len; | 808 | const start_index = c.buf.items.len; |
| 815 | try c.buf.writer().print(format ++ " ", args); | 809 | try c.buf.writer().print(format ++ " ", args); |
| ... | @@ -932,7 +926,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { | ... | @@ -932,7 +926,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { |
| 932 | .call => { | 926 | .call => { |
| 933 | const payload = node.castTag(.call).?.data; | 927 | const payload = node.castTag(.call).?.data; |
| 934 | // Cosmetic: avoids an unnecesary address_of on most function calls. | 928 | // Cosmetic: avoids an unnecesary address_of on most function calls. |
| 935 | const lhs = if (!c.zig_is_stage1 and payload.lhs.tag() == .fn_identifier) | 929 | const lhs = if (payload.lhs.tag() == .fn_identifier) |
| 936 | try c.addNode(.{ | 930 | try c.addNode(.{ |
| 937 | .tag = .identifier, | 931 | .tag = .identifier, |
| 938 | .main_token = try c.addIdentifier(payload.lhs.castTag(.fn_identifier).?.data), | 932 | .main_token = try c.addIdentifier(payload.lhs.castTag(.fn_identifier).?.data), |
| ... | @@ -1097,28 +1091,20 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { | ... | @@ -1097,28 +1091,20 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { |
| 1097 | // value (implicit in stage1, explicit in stage2), except in | 1091 | // value (implicit in stage1, explicit in stage2), except in |
| 1098 | // the context of an address_of, which is handled there. | 1092 | // the context of an address_of, which is handled there. |
| 1099 | const payload = node.castTag(.fn_identifier).?.data; | 1093 | const payload = node.castTag(.fn_identifier).?.data; |
| 1100 | if (c.zig_is_stage1) { | 1094 | const tok = try c.addToken(.ampersand, "&"); |
| 1101 | return try c.addNode(.{ | 1095 | const arg = try c.addNode(.{ |
| 1102 | .tag = .identifier, | 1096 | .tag = .identifier, |
| 1103 | .main_token = try c.addIdentifier(payload), | 1097 | .main_token = try c.addIdentifier(payload), |
| 1104 | .data = undefined, | 1098 | .data = undefined, |
| 1105 | }); | 1099 | }); |
| 1106 | } else { | 1100 | return c.addNode(.{ |
| 1107 | const tok = try c.addToken(.ampersand, "&"); | 1101 | .tag = .address_of, |
| 1108 | const arg = try c.addNode(.{ | 1102 | .main_token = tok, |
| 1109 | .tag = .identifier, | 1103 | .data = .{ |
| 1110 | .main_token = try c.addIdentifier(payload), | 1104 | .lhs = arg, |
| 1111 | .data = undefined, | 1105 | .rhs = undefined, |
| 1112 | }); | 1106 | }, |
| 1113 | return c.addNode(.{ | 1107 | }); |
| 1114 | .tag = .address_of, | ||
| 1115 | .main_token = tok, | ||
| 1116 | .data = .{ | ||
| 1117 | .lhs = arg, | ||
| 1118 | .rhs = undefined, | ||
| 1119 | }, | ||
| 1120 | }); | ||
| 1121 | } | ||
| 1122 | }, | 1108 | }, |
| 1123 | .float_literal => { | 1109 | .float_literal => { |
| 1124 | const payload = node.castTag(.float_literal).?.data; | 1110 | const payload = node.castTag(.float_literal).?.data; |
| ... | @@ -1448,7 +1434,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { | ... | @@ -1448,7 +1434,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { |
| 1448 | .optional_type => return renderPrefixOp(c, node, .optional_type, .question_mark, "?"), | 1434 | .optional_type => return renderPrefixOp(c, node, .optional_type, .question_mark, "?"), |
| 1449 | .address_of => { | 1435 | .address_of => { |
| 1450 | const payload = node.castTag(.address_of).?.data; | 1436 | const payload = node.castTag(.address_of).?.data; |
| 1451 | if (c.zig_is_stage1 and payload.tag() == .fn_identifier) | 1437 | if (payload.tag() == .fn_identifier) |
| 1452 | return try c.addNode(.{ | 1438 | return try c.addNode(.{ |
| 1453 | .tag = .identifier, | 1439 | .tag = .identifier, |
| 1454 | .main_token = try c.addIdentifier(payload.castTag(.fn_identifier).?.data), | 1440 | .main_token = try c.addIdentifier(payload.castTag(.fn_identifier).?.data), |
test/link/wasm/archive/build.zig-1| ... | @@ -13,7 +13,6 @@ pub fn build(b: *Builder) void { | ... | @@ -13,7 +13,6 @@ pub fn build(b: *Builder) void { |
| 13 | lib.setBuildMode(mode); | 13 | lib.setBuildMode(mode); |
| 14 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | 14 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); |
| 15 | lib.use_llvm = false; | 15 | lib.use_llvm = false; |
| 16 | lib.use_stage1 = false; | ||
| 17 | lib.use_lld = false; | 16 | lib.use_lld = false; |
| 18 | lib.strip = false; | 17 | lib.strip = false; |
| 19 | 18 |
test/link/wasm/bss/build.zig-1| ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { | ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { |
| 11 | lib.setBuildMode(mode); | 11 | lib.setBuildMode(mode); |
| 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); |
| 13 | lib.use_llvm = false; | 13 | lib.use_llvm = false; |
| 14 | lib.use_stage1 = false; | ||
| 15 | lib.use_lld = false; | 14 | lib.use_lld = false; |
| 16 | lib.strip = false; | 15 | lib.strip = false; |
| 17 | // to make sure the bss segment is emitted, we must import memory | 16 | // to make sure the bss segment is emitted, we must import memory |
test/link/wasm/producers/build.zig-1| ... | @@ -12,7 +12,6 @@ pub fn build(b: *Builder) void { | ... | @@ -12,7 +12,6 @@ pub fn build(b: *Builder) void { |
| 12 | lib.setBuildMode(mode); | 12 | lib.setBuildMode(mode); |
| 13 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | 13 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); |
| 14 | lib.use_llvm = false; | 14 | lib.use_llvm = false; |
| 15 | lib.use_stage1 = false; | ||
| 16 | lib.use_lld = false; | 15 | lib.use_lld = false; |
| 17 | lib.strip = false; | 16 | lib.strip = false; |
| 18 | lib.install(); | 17 | lib.install(); |
test/link/wasm/segments/build.zig-1| ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { | ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { |
| 11 | lib.setBuildMode(mode); | 11 | lib.setBuildMode(mode); |
| 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); |
| 13 | lib.use_llvm = false; | 13 | lib.use_llvm = false; |
| 14 | lib.use_stage1 = false; | ||
| 15 | lib.use_lld = false; | 14 | lib.use_lld = false; |
| 16 | lib.strip = false; | 15 | lib.strip = false; |
| 17 | lib.install(); | 16 | lib.install(); |
test/link/wasm/stack_pointer/build.zig-1| ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { | ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { |
| 11 | lib.setBuildMode(mode); | 11 | lib.setBuildMode(mode); |
| 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); |
| 13 | lib.use_llvm = false; | 13 | lib.use_llvm = false; |
| 14 | lib.use_stage1 = false; | ||
| 15 | lib.use_lld = false; | 14 | lib.use_lld = false; |
| 16 | lib.strip = false; | 15 | lib.strip = false; |
| 17 | lib.stack_size = std.wasm.page_size * 2; // set an explicit stack size | 16 | lib.stack_size = std.wasm.page_size * 2; // set an explicit stack size |
test/link/wasm/type/build.zig-1| ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { | ... | @@ -11,7 +11,6 @@ pub fn build(b: *Builder) void { |
| 11 | lib.setBuildMode(mode); | 11 | lib.setBuildMode(mode); |
| 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); |
| 13 | lib.use_llvm = false; | 13 | lib.use_llvm = false; |
| 14 | lib.use_stage1 = false; | ||
| 15 | lib.use_lld = false; | 14 | lib.use_lld = false; |
| 16 | lib.strip = false; | 15 | lib.strip = false; |
| 17 | lib.install(); | 16 | lib.install(); |
test/tests.zig+3-7| ... | @@ -720,20 +720,18 @@ pub fn addPkgTests( | ... | @@ -720,20 +720,18 @@ pub fn addPkgTests( |
| 720 | these_tests.addIncludePath("test"); | 720 | these_tests.addIncludePath("test"); |
| 721 | if (test_target.backend) |backend| switch (backend) { | 721 | if (test_target.backend) |backend| switch (backend) { |
| 722 | .stage1 => { | 722 | .stage1 => { |
| 723 | these_tests.use_stage1 = true; | 723 | @panic("stage1 testing requested"); |
| 724 | }, | 724 | }, |
| 725 | .stage2_llvm => { | 725 | .stage2_llvm => { |
| 726 | these_tests.use_stage1 = false; | ||
| 727 | these_tests.use_llvm = true; | 726 | these_tests.use_llvm = true; |
| 728 | }, | 727 | }, |
| 729 | .stage2_c => { | 728 | .stage2_c => { |
| 730 | these_tests.use_stage1 = false; | ||
| 731 | these_tests.use_llvm = false; | 729 | these_tests.use_llvm = false; |
| 732 | }, | 730 | }, |
| 733 | else => { | 731 | else => { |
| 734 | these_tests.use_stage1 = false; | ||
| 735 | these_tests.use_llvm = false; | 732 | these_tests.use_llvm = false; |
| 736 | // TODO: force self-hosted linkers to avoid LLD creeping in until the auto-select mechanism deems them worthy | 733 | // TODO: force self-hosted linkers to avoid LLD creeping in |
| 734 | // until the auto-select mechanism deems them worthy | ||
| 737 | these_tests.use_lld = false; | 735 | these_tests.use_lld = false; |
| 738 | }, | 736 | }, |
| 739 | }; | 737 | }; |
| ... | @@ -1355,8 +1353,6 @@ pub fn addCAbiTests(b: *build.Builder, skip_non_native: bool) *build.Step { | ... | @@ -1355,8 +1353,6 @@ pub fn addCAbiTests(b: *build.Builder, skip_non_native: bool) *build.Step { |
| 1355 | triple_prefix, | 1353 | triple_prefix, |
| 1356 | })); | 1354 | })); |
| 1357 | 1355 | ||
| 1358 | test_step.use_stage1 = false; | ||
| 1359 | |||
| 1360 | step.dependOn(&test_step.step); | 1356 | step.dependOn(&test_step.step); |
| 1361 | } | 1357 | } |
| 1362 | return step; | 1358 | return step; |