From 81e960eb748fdb37d1d61da262ec343e2fdb2511 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 16 May 2019 13:56:56 -0400 Subject: improvements to build-lib use case of WebAssembly * build-exe does include the startup code that supplies _start for the wasm32-freestanding target. Previously this did not occur because of logic excluding "freestanding". * build-lib for wasm32-freestanding target gets linked by LLD. To avoid infinite recursion, compiler_rt and zig libc are built as objects rather than libraries. - no "lib" prefix and ".wasm" extension instead of ".a". Rather than build-lib foo.zig producing "libfoo.a", now it produces "foo.wasm". * go back to using `.o` extension for webassembly objects * zig libc only provides _start symbol for wasm when linking libc. --- src/target.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/target.cpp') diff --git a/src/target.cpp b/src/target.cpp index 7a3459af1a..630096204b 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -947,8 +947,6 @@ bool target_allows_addr_zero(const ZigTarget *target) { const char *target_o_file_ext(const ZigTarget *target) { if (target->abi == ZigLLVM_MSVC || target->os == OsWindows || target->os == OsUefi) { return ".obj"; - } else if (target_is_wasm(target)) { - return ".wasm"; } else { return ".o"; } @@ -975,7 +973,7 @@ const char *target_exe_file_ext(const ZigTarget *target) { } const char *target_lib_file_prefix(const ZigTarget *target) { - if (target->os == OsWindows || target->os == OsUefi) { + if (target->os == OsWindows || target->os == OsUefi || target_is_wasm(target)) { return ""; } else { return "lib"; @@ -985,6 +983,9 @@ const char *target_lib_file_prefix(const ZigTarget *target) { const char *target_lib_file_ext(const ZigTarget *target, bool is_static, size_t version_major, size_t version_minor, size_t version_patch) { + if (target_is_wasm(target)) { + return ".wasm"; + } if (target->os == OsWindows || target->os == OsUefi) { if (is_static) { return ".lib"; -- cgit v1.2.3