aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-12-14 16:41:20 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-01 17:51:19 -0700
commitf54471b54c471bb6f8e51a1383be09d01c24d0c3 (patch)
tree63b869ef277027fc0f21e4789b953d9d2e421e68 /src/link.zig
parent769dea6e37ffef32f0972a0b958ff2ea38db6854 (diff)
downloadzig-f54471b54c471bb6f8e51a1383be09d01c24d0c3.tar.gz
zig-f54471b54c471bb6f8e51a1383be09d01c24d0c3.zip
compiler: miscellaneous branch progress
implement builtin.zig file population for all modules rather than assuming there is only one global builtin.zig module. move some fields from link.File to Compilation move some fields from Module to Compilation compute debug_format in global Compilation config resolution wire up C compilation to the concept of owner modules make whole cache mode call link.File.createEmpty() instead of link.File.open()
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/link.zig b/src/link.zig
index 2a61e46969..91def2a134 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -68,9 +68,6 @@ pub const File = struct {
force_undefined_symbols: std.StringArrayHashMapUnmanaged(void),
allow_shlib_undefined: bool,
stack_size: u64,
- debug_format: DebugFormat,
- function_sections: bool,
- data_sections: bool,
/// Prevents other processes from clobbering files in the output directory
/// of this linking operation.
@@ -78,16 +75,7 @@ pub const File = struct {
child_pid: ?std.ChildProcess.Id = null,
- pub const DebugFormat = union(enum) {
- strip,
- dwarf: std.dwarf.Format,
- code_view,
- };
-
pub const OpenOptions = struct {
- comp: *Compilation,
- emit: Compilation.Emit,
-
symbol_count_hint: u64 = 32,
program_code_size_hint: u64 = 256 * 1024,
@@ -95,8 +83,6 @@ pub const File = struct {
entry_addr: ?u64,
stack_size: ?u64,
image_base: ?u64,
- function_sections: bool,
- data_sections: bool,
eh_frame_hdr: bool,
emit_relocs: bool,
rdynamic: bool,
@@ -150,8 +136,6 @@ pub const File = struct {
compatibility_version: ?std.SemanticVersion,
- debug_format: ?DebugFormat,
-
// TODO: remove this. libraries are resolved by the frontend.
lib_dirs: []const []const u8,
rpath_list: []const []const u8,
@@ -190,10 +174,29 @@ pub const File = struct {
/// rewriting it. A malicious file is detected as incremental link failure
/// and does not cause Illegal Behavior. This operation is not atomic.
/// `arena` is used for allocations with the same lifetime as the created File.
- pub fn open(arena: Allocator, options: OpenOptions) !*File {
- switch (Tag.fromObjectFormat(options.comp.root_mod.resolved_target.result.ofmt)) {
+ pub fn open(
+ arena: Allocator,
+ comp: *Compilation,
+ emit: Compilation.Emit,
+ options: OpenOptions,
+ ) !*File {
+ switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) {
+ inline else => |tag| {
+ const ptr = try tag.Type().open(arena, comp, emit, options);
+ return &ptr.base;
+ },
+ }
+ }
+
+ pub fn createEmpty(
+ arena: Allocator,
+ comp: *Compilation,
+ emit: Compilation.Emit,
+ options: OpenOptions,
+ ) !*File {
+ switch (Tag.fromObjectFormat(comp.root_mod.resolved_target.result.ofmt)) {
inline else => |tag| {
- const ptr = try tag.Type().open(arena, options);
+ const ptr = try tag.Type().createEmpty(arena, comp, emit, options);
return &ptr.base;
},
}