From 3a5d0f7700dc28b523e17ba461874b807786b939 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 20 May 2021 10:27:35 +0200 Subject: wasm: link dynamically by default when targeting wasm This matches the behaviour of other languages and leaves us the ability to create actual static Wasm archives with ``` zig build-lib -static some.zig ``` which can then be combined with other Wasm object files and linked into either a Wasm lib or executable using `wasm-ld`. Update langref to reflect the fact we now ship WASI libc. --- src/main.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index b388329508..86d017b3b7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1548,6 +1548,12 @@ fn buildOutputType( link_libcpp = true; } + if (cross_target.getCpuArch().isWasm() and output_mode == .Lib and link_mode == null) { + // If link_mode is unspecified, always link as dynamic library when targeting Wasm, + // so that wasm-ld is invoked rather than standard archiver. + link_mode = .Dynamic; + } + // Now that we have target info, we can find out if any of the system libraries // are part of libc or libc++. We remove them from the list and communicate their // existence via flags instead. -- cgit v1.2.3