aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
diff options
context:
space:
mode:
authorFrank Denis <github@pureftpd.org>2022-12-25 22:04:01 +0100
committerFrank Denis <github@pureftpd.org>2022-12-25 22:32:21 +0100
commit7802c26449657b205dcaa47bb6575bb26171c024 (patch)
tree1f4ca594d37bf4d9c51d85ed63164b86c5771029 /src/link.zig
parent0c30e006c90db4e6ca77d9054d391340282b96f6 (diff)
downloadzig-7802c26449657b205dcaa47bb6575bb26171c024.tar.gz
zig-7802c26449657b205dcaa47bb6575bb26171c024.zip
WebAssembly: do not link with --allow-undefined unconditionally
In #1622, when targeting WebAsembly, the --allow-undefined flag became unconditionally added to the linker. This is not always desirable. First, this is error prone. Code with references to unkown symbols will link just fine, but then fail at run-time. This behavior is inconsistent with all other targets. For freestanding wasm applications, and applications that only use WASI, undefined references are better reported at compile-time. This behavior is also inconsistent with clang itself. Autoconf and cmake scripts checking for function presence think that all tested functions exist, but then resulting application cannot run. For example, this is one of the reasons compilation of Ruby 3.2.0 to WASI fails with zig cc, while it works out of the box with clang. But all applications checking for symbol existence before compilation are affected. This reverts the behavior to the one Zig had before #1622, and introduces an `import_symbols` flag to ignore undefined symbols, assuming that the webassembly runtime will define them.
Diffstat (limited to 'src/link.zig')
-rw-r--r--src/link.zig1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/link.zig b/src/link.zig
index 450763ac18..1dadacc2fe 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -128,6 +128,7 @@ pub const Options = struct {
compress_debug_sections: CompressDebugSections,
bind_global_refs_locally: bool,
import_memory: bool,
+ import_symbols: bool,
import_table: bool,
export_table: bool,
initial_memory: ?u64,