diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-10-24 16:48:15 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-10-24 23:30:57 -0700 |
| commit | b3cd38ea4a7520fabbb05d3d2e74351c7c8effdb (patch) | |
| tree | 51a821b640352c1967490e96165e2d5abbd94c2b /src/link/Wasm.zig | |
| parent | 4f04759c874d5fd41c7cadeb974b4459559bc2a7 (diff) | |
| download | zig-b3cd38ea4a7520fabbb05d3d2e74351c7c8effdb.tar.gz zig-b3cd38ea4a7520fabbb05d3d2e74351c7c8effdb.zip | |
link: add an explicit error set for flush() and flushModule()
This makes it easier to understand how control flow should happen in
various cases; already just by doing this it is revealed that
UndefinedSymbol and UndefinedSymbolReference should be merged, and that
MissingMainEntrypoint should be removed in favor of the ErrorFlags
mechanism thath we already have for missing the main entrypoint.
The main motivation for this change, however, is preventing a compile
error when there is conditional compilation inside linker
implementations, causing the flush() error set to depend on compilation
options. With this change, the error set is fixed, and, notably, the
`-Donly-c` flag no longer has compilation errors due to this error set.
Diffstat (limited to 'src/link/Wasm.zig')
| -rw-r--r-- | src/link/Wasm.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 2327837b31..4c3de84e01 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -501,7 +501,7 @@ fn resolveSymbolsInObject(wasm: *Wasm, object_index: u16) !void { if (symbol.isUndefined()) { log.err("Local symbols are not allowed to reference imports", .{}); log.err(" symbol '{s}' defined in '{s}'", .{ sym_name, object.name }); - return error.undefinedLocal; + return error.UndefinedLocal; } try wasm.resolved_symbols.putNoClobber(wasm.base.allocator, location, {}); continue; @@ -2091,7 +2091,7 @@ fn resetState(wasm: *Wasm) void { wasm.debug_pubtypes_index = null; } -pub fn flush(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !void { +pub fn flush(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) link.File.FlushError!void { if (wasm.base.options.emit == null) { if (build_options.have_llvm) { if (wasm.llvm_object) |llvm_object| { @@ -2107,7 +2107,7 @@ pub fn flush(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !vo } } -pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !void { +pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) link.File.FlushError!void { const tracy = trace(@src()); defer tracy.end(); @@ -3195,7 +3195,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! const term = child.spawnAndWait() catch |err| { log.err("unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) }); - return error.UnableToSpawnwasm; + return error.UnableToSpawnWasm; }; switch (term) { .Exited => |code| { @@ -3216,7 +3216,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) ! const term = child.wait() catch |err| { log.err("unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) }); - return error.UnableToSpawnwasm; + return error.UnableToSpawnWasm; }; switch (term) { |
