aboutsummaryrefslogtreecommitdiff
path: root/src/link/Goff.zig
blob: 9a39e4b9f8dfe94c581e5c080ce219a6178b4e90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! Stub linker support for GOFF based on LLVM.

const Goff = @This();

const std = @import("std");
const builtin = @import("builtin");

const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const log = std.log.scoped(.link);
const Path = std.Build.Cache.Path;

const Zcu = @import("../Zcu.zig");
const InternPool = @import("../InternPool.zig");
const Compilation = @import("../Compilation.zig");
const codegen = @import("../codegen.zig");
const link = @import("../link.zig");
const trace = @import("../tracy.zig").trace;
const build_options = @import("build_options");

base: link.File,

pub fn createEmpty(
    arena: Allocator,
    comp: *Compilation,
    emit: Path,
    options: link.File.OpenOptions,
) !*Goff {
    const target = &comp.root_mod.resolved_target.result;
    const use_lld = build_options.have_llvm and comp.config.use_lld;
    const use_llvm = comp.config.use_llvm;

    assert(use_llvm); // Caught by Compilation.Config.resolve.
    assert(!use_lld); // Caught by Compilation.Config.resolve.
    assert(target.os.tag == .zos); // Caught by Compilation.Config.resolve.

    const goff = try arena.create(Goff);
    goff.* = .{
        .base = .{
            .tag = .goff,
            .comp = comp,
            .emit = emit,
            .zcu_object_basename = emit.sub_path,
            .gc_sections = options.gc_sections orelse false,
            .print_gc_sections = options.print_gc_sections,
            .stack_size = options.stack_size orelse 0,
            .allow_shlib_undefined = options.allow_shlib_undefined orelse false,
            .file = null,
            .build_id = options.build_id,
        },
    };

    return goff;
}

pub fn open(
    arena: Allocator,
    comp: *Compilation,
    emit: Path,
    options: link.File.OpenOptions,
) !*Goff {
    const target = &comp.root_mod.resolved_target.result;
    assert(target.ofmt == .goff);
    return createEmpty(arena, comp, emit, options);
}

pub fn deinit(self: *Goff) void {
    _ = self;
}

pub fn updateFunc(
    self: *Goff,
    pt: Zcu.PerThread,
    func_index: InternPool.Index,
    mir: *const codegen.AnyMir,
) link.File.UpdateNavError!void {
    _ = self;
    _ = pt;
    _ = func_index;
    _ = mir;
    unreachable; // we always use llvm
}

pub fn updateNav(self: *Goff, pt: Zcu.PerThread, nav: InternPool.Nav.Index) link.File.UpdateNavError!void {
    _ = self;
    _ = pt;
    _ = nav;
    unreachable; // we always use llvm
}

pub fn updateExports(
    self: *Goff,
    pt: Zcu.PerThread,
    exported: Zcu.Exported,
    export_indices: []const Zcu.Export.Index,
) !void {
    _ = self;
    _ = pt;
    _ = exported;
    _ = export_indices;
    unreachable; // we always use llvm
}

pub fn flush(self: *Goff, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.Progress.Node) link.File.FlushError!void {
    if (build_options.skip_non_native and builtin.object_format != .goff)
        @panic("Attempted to compile for object format that was disabled by build configuration");

    _ = self;
    _ = arena;
    _ = tid;
    _ = prog_node;
}