diff --git a/src/Compilation.zig b/src/Compilation.zig index 9a9ac5592a12c9cba22a073ad4d7872ce16d74cf..6e3a955632ab9d48a4e50231c3b82fe316253a6e 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -852,6 +852,10 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { // WASI-only. Resolve the optional exec-model option, defaults to command. const wasi_exec_model = if (options.target.os.tag != .wasi) undefined else options.wasi_exec_model orelse .command; + if (options.linker_export_table and options.linker_import_table) { + return error.ExportTableAndImportTableConflict; + } + const comp: *Compilation = comp: { // For allocations that have the same lifetime as Compilation. This arena is used only during this // initialization and then is freed in deinit(). diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index c305959e569f0038358587c7b0fad23e84b4a6a2..35a1ac672afbe309c41dfd1afb5760f441a4f31b 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -1123,14 +1123,12 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { } if (self.base.options.import_table) { - if (self.base.options.export_table) { - log.err("--import-table and --export-table may not be used together", .{}); - return error.InvalidArgs; - } + assert(self.base.options.export_table); try argv.append("--import-table"); } if (self.base.options.export_table) { + assert(!self.base.options.import_table); try argv.append("--export-table"); } diff --git a/src/main.zig b/src/main.zig index effcef40d918180c515852799a90a31095876573..3f2dbd0cc79797bfb0b393a4b7a7cbf64aa3e4ea 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2543,6 +2543,9 @@ fn buildOutputType( } process.exit(1); }, + error.ExportTableAndImportTableConflict => { + fatal("--import-table and --export-table may not be used together", .{}); + }, else => fatal("unable to create compilation: {s}", .{@errorName(err)}), }; var comp_destroyed = false;