aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-10-31 20:29:55 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-12-06 12:15:04 -0700
commit28514476ef8c824c3d189d98f23d0f8d23e496ea (patch)
tree537631080e7c99fb582738d3be96ac48c5941bb7 /src/link
parentbf316e550671cc71eb498b3cf799493627bb0fdc (diff)
downloadzig-28514476ef8c824c3d189d98f23d0f8d23e496ea.tar.gz
zig-28514476ef8c824c3d189d98f23d0f8d23e496ea.zip
remove `-fstage1` option
After this commit, the self-hosted compiler does not offer the option to use stage1 as a backend anymore.
Diffstat (limited to 'src/link')
-rw-r--r--src/link/Coff.zig3
-rw-r--r--src/link/Coff/lld.zig20
-rw-r--r--src/link/Elf.zig23
-rw-r--r--src/link/MachO.zig8
-rw-r--r--src/link/MachO/zld.zig19
-rw-r--r--src/link/Wasm.zig54
6 files changed, 22 insertions, 105 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index 3f89de9608..aa94704c54 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -248,8 +248,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Coff {
};
const use_llvm = build_options.have_llvm and options.use_llvm;
- const use_stage1 = build_options.have_stage1 and options.use_stage1;
- if (use_llvm and !use_stage1) {
+ if (use_llvm) {
self.llvm_object = try LlvmObject.create(gpa, options);
}
return self;
diff --git a/src/link/Coff/lld.zig b/src/link/Coff/lld.zig
index 7c53ef30bd..c1edb55b80 100644
--- a/src/link/Coff/lld.zig
+++ b/src/link/Coff/lld.zig
@@ -30,25 +30,7 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
// If there is no Zig code to compile, then we should skip flushing the output file because it
// will not be part of the linker line anyway.
- const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: {
- const use_stage1 = build_options.have_stage1 and self.base.options.use_stage1;
- if (use_stage1) {
- const obj_basename = try std.zig.binNameAlloc(arena, .{
- .root_name = self.base.options.root_name,
- .target = self.base.options.target,
- .output_mode = .Obj,
- });
- switch (self.base.options.cache_mode) {
- .incremental => break :blk try module.zig_cache_artifact_directory.join(
- arena,
- &[_][]const u8{obj_basename},
- ),
- .whole => break :blk try fs.path.join(arena, &.{
- fs.path.dirname(full_out_path).?, obj_basename,
- }),
- }
- }
-
+ const module_obj_path: ?[]const u8 = if (self.base.options.module != null) blk: {
try self.flushModule(comp, prog_node);
if (fs.path.dirname(full_out_path)) |dirname| {
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index f98e33e58b..b7968b3f1c 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -328,8 +328,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf {
.page_size = page_size,
};
const use_llvm = build_options.have_llvm and options.use_llvm;
- const use_stage1 = build_options.have_stage1 and options.use_stage1;
- if (use_llvm and !use_stage1) {
+ if (use_llvm) {
self.llvm_object = try LlvmObject.create(gpa, options);
}
return self;
@@ -1228,25 +1227,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
// If there is no Zig code to compile, then we should skip flushing the output file because it
// will not be part of the linker line anyway.
- const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: {
- // stage1 puts the object file in the cache directory.
- if (self.base.options.use_stage1) {
- const obj_basename = try std.zig.binNameAlloc(arena, .{
- .root_name = self.base.options.root_name,
- .target = self.base.options.target,
- .output_mode = .Obj,
- });
- switch (self.base.options.cache_mode) {
- .incremental => break :blk try module.zig_cache_artifact_directory.join(
- arena,
- &[_][]const u8{obj_basename},
- ),
- .whole => break :blk try fs.path.join(arena, &.{
- fs.path.dirname(full_out_path).?, obj_basename,
- }),
- }
- }
-
+ const module_obj_path: ?[]const u8 = if (self.base.options.module != null) blk: {
try self.flushModule(comp, prog_node);
if (fs.path.dirname(full_out_path)) |dirname| {
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index fb651edbe3..8c9e5329f2 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -290,8 +290,7 @@ pub const Export = struct {
pub fn openPath(allocator: Allocator, options: link.Options) !*MachO {
assert(options.target.ofmt == .macho);
- const use_stage1 = build_options.have_stage1 and options.use_stage1;
- if (use_stage1 or options.emit == null or options.module == null) {
+ if (options.emit == null or options.module == null) {
return createEmpty(allocator, options);
}
@@ -377,7 +376,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO {
const cpu_arch = options.target.cpu.arch;
const page_size: u16 = if (cpu_arch == .aarch64) 0x4000 else 0x1000;
const use_llvm = build_options.have_llvm and options.use_llvm;
- const use_stage1 = build_options.have_stage1 and options.use_stage1;
const self = try gpa.create(MachO);
errdefer gpa.destroy(self);
@@ -390,13 +388,13 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO {
.file = null,
},
.page_size = page_size,
- .mode = if (use_stage1 or use_llvm or options.module == null or options.cache_mode == .whole)
+ .mode = if (use_llvm or options.module == null or options.cache_mode == .whole)
.one_shot
else
.incremental,
};
- if (use_llvm and !use_stage1) {
+ if (use_llvm) {
self.llvm_object = try LlvmObject.create(gpa, options);
}
diff --git a/src/link/MachO/zld.zig b/src/link/MachO/zld.zig
index 5baaf71f18..9baecd326a 100644
--- a/src/link/MachO/zld.zig
+++ b/src/link/MachO/zld.zig
@@ -3746,24 +3746,7 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr
// If there is no Zig code to compile, then we should skip flushing the output file because it
// will not be part of the linker line anyway.
- const module_obj_path: ?[]const u8 = if (options.module) |module| blk: {
- if (options.use_stage1) {
- const obj_basename = try std.zig.binNameAlloc(arena, .{
- .root_name = options.root_name,
- .target = target,
- .output_mode = .Obj,
- });
- switch (options.cache_mode) {
- .incremental => break :blk try module.zig_cache_artifact_directory.join(
- arena,
- &[_][]const u8{obj_basename},
- ),
- .whole => break :blk try fs.path.join(arena, &.{
- fs.path.dirname(full_out_path).?, obj_basename,
- }),
- }
- }
-
+ const module_obj_path: ?[]const u8 = if (options.module != null) blk: {
try macho_file.flushModule(comp, prog_node);
if (fs.path.dirname(full_out_path)) |dirname| {
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index adcb539bd6..4a9db75c98 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -382,8 +382,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Wasm {
};
const use_llvm = build_options.have_llvm and options.use_llvm;
- const use_stage1 = build_options.have_stage1 and options.use_stage1;
- if (use_llvm and !use_stage1) {
+ if (use_llvm) {
wasm.llvm_object = try LlvmObject.create(gpa, options);
}
return wasm;
@@ -2986,25 +2985,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
// If there is no Zig code to compile, then we should skip flushing the output file because it
// will not be part of the linker line anyway.
- const module_obj_path: ?[]const u8 = if (wasm.base.options.module) |mod| blk: {
- const use_stage1 = build_options.have_stage1 and wasm.base.options.use_stage1;
- if (use_stage1) {
- const obj_basename = try std.zig.binNameAlloc(arena, .{
- .root_name = wasm.base.options.root_name,
- .target = wasm.base.options.target,
- .output_mode = .Obj,
- });
- switch (wasm.base.options.cache_mode) {
- .incremental => break :blk try mod.zig_cache_artifact_directory.join(
- arena,
- &[_][]const u8{obj_basename},
- ),
- .whole => break :blk try fs.path.join(arena, &.{
- fs.path.dirname(full_out_path).?, obj_basename,
- }),
- }
- }
-
+ const module_obj_path: ?[]const u8 = if (wasm.base.options.module != null) blk: {
try wasm.flushModule(comp, prog_node);
if (fs.path.dirname(full_out_path)) |dirname| {
@@ -3198,26 +3179,19 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
if (wasm.base.options.module) |mod| {
// when we use stage1, we use the exports that stage1 provided us.
// For stage2, we can directly retrieve them from the module.
- const use_stage1 = build_options.have_stage1 and wasm.base.options.use_stage1;
- if (use_stage1) {
- for (comp.export_symbol_names.items) |symbol_name| {
- try argv.append(try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name}));
- }
- } else {
- const skip_export_non_fn = target.os.tag == .wasi and
- wasm.base.options.wasi_exec_model == .command;
- for (mod.decl_exports.values()) |exports| {
- for (exports.items) |exprt| {
- const exported_decl = mod.declPtr(exprt.exported_decl);
- if (skip_export_non_fn and exported_decl.ty.zigTypeTag() != .Fn) {
- // skip exporting symbols when we're building a WASI command
- // and the symbol is not a function
- continue;
- }
- const symbol_name = exported_decl.name;
- const arg = try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name});
- try argv.append(arg);
+ const skip_export_non_fn = target.os.tag == .wasi and
+ wasm.base.options.wasi_exec_model == .command;
+ for (mod.decl_exports.values()) |exports| {
+ for (exports.items) |exprt| {
+ const exported_decl = mod.declPtr(exprt.exported_decl);
+ if (skip_export_non_fn and exported_decl.ty.zigTypeTag() != .Fn) {
+ // skip exporting symbols when we're building a WASI command
+ // and the symbol is not a function
+ continue;
}
+ const symbol_name = exported_decl.name;
+ const arg = try std.fmt.allocPrint(arena, "--export={s}", .{symbol_name});
+ try argv.append(arg);
}
}
}