mirror of
https://github.com/ziglang/zig.git
synced 2025-12-26 08:03:08 +00:00
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.
This commit is contained in:
parent
205af5b148
commit
8c9919ec7b
@ -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),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,6 +282,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
|
||||
break :blk full_obj_path;
|
||||
} else null;
|
||||
|
||||
const compiler_rt_path: ?[]const u8 = if (self.base.options.include_compiler_rt)
|
||||
comp.compiler_rt_static_lib.?.full_object_path
|
||||
else
|
||||
null;
|
||||
|
||||
const target = self.base.options.target;
|
||||
|
||||
const id_symlink_basename = "lld.id";
|
||||
@ -302,6 +307,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
|
||||
_ = try man.addFile(entry.key.status.success.object_path, null);
|
||||
}
|
||||
try man.addOptionalFile(module_obj_path);
|
||||
try man.addOptionalFile(compiler_rt_path);
|
||||
man.hash.addOptional(self.base.options.stack_size_override);
|
||||
man.hash.addListOfBytes(self.base.options.extra_lld_args);
|
||||
|
||||
@ -381,11 +387,15 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
|
||||
try argv.append(p);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
try argv.append(comp.compiler_rt_static_lib.?.full_object_path);
|
||||
if (self.base.options.output_mode != .Obj and
|
||||
!self.base.options.is_compiler_rt_or_libc and
|
||||
!self.base.options.link_libc)
|
||||
{
|
||||
try argv.append(comp.libc_static_lib.?.full_object_path);
|
||||
}
|
||||
|
||||
if (compiler_rt_path) |p| {
|
||||
try argv.append(p);
|
||||
}
|
||||
|
||||
if (self.base.options.verbose_link) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user