aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-08-07 23:10:57 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-08-19 16:45:15 -0700
commit507aae4a1a3db498ece2a3a89d74e9e24d952923 (patch)
treedb52f3b00d0def30488e7ce81adc8685c4945874 /src/Compilation.zig
parent73bbd1069a993a0e663033ea3b8cd4ed1a123566 (diff)
downloadzig-507aae4a1a3db498ece2a3a89d74e9e24d952923.tar.gz
zig-507aae4a1a3db498ece2a3a89d74e9e24d952923.zip
make self-hosted the default compiler
stage1 is available behind the -fstage1 flag. closes #89
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 6d778b955a..84dd273947 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1040,22 +1040,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
const comp = try arena.create(Compilation);
const root_name = try arena.dupeZ(u8, options.root_name);
- const use_stage1 = options.use_stage1 orelse blk: {
- // Even though we may have no Zig code to compile (depending on `options.main_pkg`),
- // we may need to use stage1 for building compiler-rt and other dependencies.
-
- if (options.use_llvm) |use_llvm| {
- if (!use_llvm) {
- break :blk false;
- }
- }
-
- // If LLVM does not support the target, then we can't use it.
- if (!target_util.hasLlvmSupport(options.target, options.target.ofmt))
- break :blk false;
-
- break :blk build_options.is_stage1;
- };
+ const use_stage1 = options.use_stage1 orelse false;
const cache_mode = if (use_stage1 and !options.disable_lld_caching)
CacheMode.whole
@@ -2211,7 +2196,7 @@ pub fn update(comp: *Compilation) !void {
comp.c_object_work_queue.writeItemAssumeCapacity(key);
}
- const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
+ const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1;
if (comp.bin_file.options.module) |module| {
module.compile_log_text.shrinkAndFree(module.gpa, 0);
module.generation += 1;
@@ -2387,7 +2372,7 @@ fn flush(comp: *Compilation, prog_node: *std.Progress.Node) !void {
};
comp.link_error_flags = comp.bin_file.errorFlags();
- const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
+ const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1;
if (!use_stage1) {
if (comp.bin_file.options.module) |module| {
try link.File.C.flushEmitH(module);
@@ -2845,7 +2830,7 @@ pub fn performAllTheWork(
comp.work_queue_wait_group.reset();
defer comp.work_queue_wait_group.wait();
- const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
+ const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1;
{
const astgen_frame = tracy.namedFrame("astgen");
@@ -3430,7 +3415,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
var man = comp.obtainCObjectCacheManifest();
defer man.deinit();
- const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
+ const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1;
man.hash.add(@as(u16, 0xb945)); // Random number to distinguish translate-c from compiling C objects
man.hash.add(use_stage1);
@@ -4745,7 +4730,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
const target = comp.getTarget();
const generic_arch_name = target.cpu.arch.genericName();
- const use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1;
+ const use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1;
const zig_backend: std.builtin.CompilerBackend = blk: {
if (use_stage1) break :blk .stage1;
@@ -5032,7 +5017,7 @@ fn buildOutputFromZig(
.link_mode = .Static,
.function_sections = true,
.no_builtin = true,
- .use_stage1 = build_options.is_stage1 and comp.bin_file.options.use_stage1,
+ .use_stage1 = build_options.have_stage1 and comp.bin_file.options.use_stage1,
.want_sanitize_c = false,
.want_stack_check = false,
.want_stack_protector = 0,