Commit bc6904eccc

Josh Wolfe <thejoshwolfe@gmail.com>
2020-10-09 03:40:56
include compiler_rt and c for wasm static libraries
1 parent 1951ecb
Changed files (2)
src/link/Wasm.zig
@@ -374,7 +374,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
         try argv.append(p);
     }
 
-    if (self.base.options.output_mode == .Exe and !self.base.options.is_compiler_rt_or_libc) {
+    if (self.base.options.output_mode != .Obj and !self.base.options.is_compiler_rt_or_libc) {
         if (!self.base.options.link_libc) {
             try argv.append(comp.libc_static_lib.?.full_object_path);
         }
src/Compilation.zig
@@ -922,7 +922,10 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
             try comp.work_queue.writeItem(.libcxx);
             try comp.work_queue.writeItem(.libcxxabi);
         }
-        if (is_exe_or_dyn_lib and build_options.is_stage1) {
+
+        const needs_compiler_rt_and_c = is_exe_or_dyn_lib or
+            (comp.getTarget().isWasm() and comp.bin_file.options.output_mode != .Obj);
+        if (needs_compiler_rt_and_c and build_options.is_stage1) {
             try comp.work_queue.writeItem(.{ .libcompiler_rt = {} });
             if (!comp.bin_file.options.link_libc) {
                 try comp.work_queue.writeItem(.{ .zig_libc = {} });