authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-21 18:20:33-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-21 18:21:42-07:00
log2cbeb85a96af25f2718a604aa2bec4f76dd85018
treeefc5b9f311f53440d656b006d7c5ecec3a0443f6
parent2e887452d5cd8e912f6bdb36bd0da6faee383465

stage2: error check for mixing --import-table and --export-table

is moved from the linker to the frontend. This is a follow-up from 4cb2f11693b1bf13770b8ad6a8b8a1e37101a516.

3 files changed, 9 insertions(+), 4 deletions(-)

src/Compilation.zig+4
......@@ -852,6 +852,10 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
852852 // WASI-only. Resolve the optional exec-model option, defaults to command.
853853 const wasi_exec_model = if (options.target.os.tag != .wasi) undefined else options.wasi_exec_model orelse .command;
854854
855 if (options.linker_export_table and options.linker_import_table) {
856 return error.ExportTableAndImportTableConflict;
857 }
858
855859 const comp: *Compilation = comp: {
856860 // For allocations that have the same lifetime as Compilation. This arena is used only during this
857861 // initialization and then is freed in deinit().
src/link/Wasm.zig+2-4
......@@ -1123,14 +1123,12 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
11231123 }
11241124
11251125 if (self.base.options.import_table) {
1126 if (self.base.options.export_table) {
1127 log.err("--import-table and --export-table may not be used together", .{});
1128 return error.InvalidArgs;
1129 }
1126 assert(self.base.options.export_table);
11301127 try argv.append("--import-table");
11311128 }
11321129
11331130 if (self.base.options.export_table) {
1131 assert(!self.base.options.import_table);
11341132 try argv.append("--export-table");
11351133 }
11361134
src/main.zig+3
......@@ -2543,6 +2543,9 @@ fn buildOutputType(
25432543 }
25442544 process.exit(1);
25452545 },
2546 error.ExportTableAndImportTableConflict => {
2547 fatal("--import-table and --export-table may not be used together", .{});
2548 },
25462549 else => fatal("unable to create compilation: {s}", .{@errorName(err)}),
25472550 };
25482551 var comp_destroyed = false;