From 8c9919ec7b409d11ca73ca5764f44282dec0fe25 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 30 Nov 2020 17:46:10 -0700 Subject: fix regression on wasm targets The previous commit broke wasm targets because the linking step would look for the compiler-rt lib in the wrong place. Fixed in this commit. --- src/Compilation.zig | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index b7660718de..df48e5a391 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -981,16 +981,20 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { // Once it is capable this condition should be removed. if (build_options.is_stage1) { if (comp.bin_file.options.include_compiler_rt) { - if (is_exe_or_dyn_lib) { + if (is_exe_or_dyn_lib or comp.getTarget().isWasm()) { try comp.work_queue.writeItem(.{ .compiler_rt_lib = {} }); } else { try comp.work_queue.writeItem(.{ .compiler_rt_obj = {} }); - if (comp.bin_file.options.object_format != .elf) { + if (comp.bin_file.options.object_format != .elf and + comp.bin_file.options.output_mode == .Obj) + { // For ELF we can rely on using -r to link multiple objects together into one, // but to truly support `build-obj -fcompiler-rt` will require virtually // injecting `_ = @import("compiler_rt.zig")` into the root source file of // the compilation. - fatal("Embedding compiler-rt into non-ELF objects is not yet implemented.", .{}); + fatal("Embedding compiler-rt into {s} objects is not yet implemented.", .{ + @tagName(comp.bin_file.options.object_format), + }); } } } -- cgit v1.2.3