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.
This commit is contained in:
Andrew Kelley
2019-05-16 13:56:56 -04:00
parent 07d0aee11a
commit 81e960eb74
5 changed files with 26 additions and 22 deletions

View File

@@ -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";