| author | |
| committer | |
| log | 3c907e51d1d3e075589cc3d7279b935ab33e5e82 |
| tree | 50bbe8a5ab1bdcaaa1da7be90f2ce5cd5e61ce11 |
| parent | 791e38da8c416b62e4e30f4c9cb44fd6f26442a5 |
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.2 files changed, 22 insertions(+), 8 deletions(-)
src/Compilation.zig+7-3| ... | @@ -961,16 +961,20 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -961,16 +961,20 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 961 | // Once it is capable this condition should be removed. | 961 | // Once it is capable this condition should be removed. |
| 962 | if (build_options.is_stage1) { | 962 | if (build_options.is_stage1) { |
| 963 | if (comp.bin_file.options.include_compiler_rt) { | 963 | if (comp.bin_file.options.include_compiler_rt) { |
| 964 | if (is_exe_or_dyn_lib) { | 964 | if (is_exe_or_dyn_lib or comp.getTarget().isWasm()) { |
| 965 | try comp.work_queue.writeItem(.{ .compiler_rt_lib = {} }); | 965 | try comp.work_queue.writeItem(.{ .compiler_rt_lib = {} }); |
| 966 | } else { | 966 | } else { |
| 967 | try comp.work_queue.writeItem(.{ .compiler_rt_obj = {} }); | 967 | try comp.work_queue.writeItem(.{ .compiler_rt_obj = {} }); |
| 968 | if (comp.bin_file.options.object_format != .elf) { | 968 | if (comp.bin_file.options.object_format != .elf and |
| 969 | comp.bin_file.options.output_mode == .Obj) | ||
| 970 | { | ||
| 969 | // For ELF we can rely on using -r to link multiple objects together into one, | 971 | // For ELF we can rely on using -r to link multiple objects together into one, |
| 970 | // but to truly support `build-obj -fcompiler-rt` will require virtually | 972 | // but to truly support `build-obj -fcompiler-rt` will require virtually |
| 971 | // injecting `_ = @import("compiler_rt.zig")` into the root source file of | 973 | // injecting `_ = @import("compiler_rt.zig")` into the root source file of |
| 972 | // the compilation. | 974 | // the compilation. |
| 973 | fatal("Embedding compiler-rt into non-ELF objects is not yet implemented.", .{}); | 975 | fatal("Embedding compiler-rt into {s} objects is not yet implemented.", .{ |
| 976 | @tagName(comp.bin_file.options.object_format), | ||
| 977 | }); | ||
| 974 | } | 978 | } |
| 975 | } | 979 | } |
| 976 | } | 980 | } |
src/link/Wasm.zig+15-5| ... | @@ -282,6 +282,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { | ... | @@ -282,6 +282,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 282 | break :blk full_obj_path; | 282 | break :blk full_obj_path; |
| 283 | } else null; | 283 | } else null; |
| 284 | 284 | ||
| 285 | const compiler_rt_path: ?[]const u8 = if (self.base.options.include_compiler_rt) | ||
| 286 | comp.compiler_rt_static_lib.?.full_object_path | ||
| 287 | else | ||
| 288 | null; | ||
| 289 | |||
| 285 | const target = self.base.options.target; | 290 | const target = self.base.options.target; |
| 286 | 291 | ||
| 287 | const id_symlink_basename = "lld.id"; | 292 | const id_symlink_basename = "lld.id"; |
| ... | @@ -302,6 +307,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { | ... | @@ -302,6 +307,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 302 | _ = try man.addFile(entry.key.status.success.object_path, null); | 307 | _ = try man.addFile(entry.key.status.success.object_path, null); |
| 303 | } | 308 | } |
| 304 | try man.addOptionalFile(module_obj_path); | 309 | try man.addOptionalFile(module_obj_path); |
| 310 | try man.addOptionalFile(compiler_rt_path); | ||
| 305 | man.hash.addOptional(self.base.options.stack_size_override); | 311 | man.hash.addOptional(self.base.options.stack_size_override); |
| 306 | man.hash.addListOfBytes(self.base.options.extra_lld_args); | 312 | man.hash.addListOfBytes(self.base.options.extra_lld_args); |
| 307 | 313 | ||
| ... | @@ -378,11 +384,15 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { | ... | @@ -378,11 +384,15 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 378 | try argv.append(p); | 384 | try argv.append(p); |
| 379 | } | 385 | } |
| 380 | 386 | ||
| 381 | if (self.base.options.output_mode != .Obj and !self.base.options.is_compiler_rt_or_libc) { | 387 | if (self.base.options.output_mode != .Obj and |
| 382 | if (!self.base.options.link_libc) { | 388 | !self.base.options.is_compiler_rt_or_libc and |
| 383 | try argv.append(comp.libc_static_lib.?.full_object_path); | 389 | !self.base.options.link_libc) |
| 384 | } | 390 | { |
| 385 | try argv.append(comp.compiler_rt_static_lib.?.full_object_path); | 391 | try argv.append(comp.libc_static_lib.?.full_object_path); |
| 392 | } | ||
| 393 | |||
| 394 | if (compiler_rt_path) |p| { | ||
| 395 | try argv.append(p); | ||
| 386 | } | 396 | } |
| 387 | 397 | ||
| 388 | if (self.base.options.verbose_link) { | 398 | if (self.base.options.verbose_link) { |