From 4bffe645c6e621cdda858f9eeb4436980fece25c Mon Sep 17 00:00:00 2001 From: Luuk de Gram Date: Wed, 28 Dec 2022 14:59:53 +0100 Subject: [PATCH] std: remove hack in test step This hack was initially introduced as we would export all symbols unconditionally, including non-function definitions. This would cause an error from the Wasmtime runtime engine, which this flag would suppress. As we now properly export symbols, this flag is no longer needed and any user running into this error can manually include it. This commit also adds the `--import-symbols` ability to build.zig --- lib/std/build/LibExeObjStep.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/std/build/LibExeObjStep.zig b/lib/std/build/LibExeObjStep.zig index f992fa0c1eb6ec03c3aaa25671dc0bc57daad2bc..0b30d138e8c2a12da22227f1f67ca52ab9519839 100644 --- a/lib/std/build/LibExeObjStep.zig +++ b/lib/std/build/LibExeObjStep.zig @@ -74,6 +74,9 @@ disable_sanitize_c: bool, sanitize_thread: bool, rdynamic: bool, import_memory: bool = false, +/// For WebAssembly targets, this will allow for undefined symbols to +/// be imported from the host environment. +import_symbols: bool = false, import_table: bool = false, export_table: bool = false, initial_memory: ?u64 = null, @@ -1458,6 +1461,9 @@ fn make(step: *Step) !void { if (self.import_memory) { try zig_args.append("--import-memory"); } + if (self.import_symbols) { + try zig_args.append("--import-symbols"); + } if (self.import_table) { try zig_args.append("--import-table"); } @@ -1609,8 +1615,6 @@ fn make(step: *Step) !void { try zig_args.append(bin_name); try zig_args.append("--test-cmd"); try zig_args.append("--dir=."); - try zig_args.append("--test-cmd"); - try zig_args.append("--allow-unknown-exports"); // TODO: Remove when stage2 is default compiler try zig_args.append("--test-cmd-bin"); } else { try zig_args.append("--test-no-exec"); -- 2.54.0