Merge pull request #17465

Compilation: default to self-hosted backends when not using libllvm
This commit is contained in:
Andrew Kelley 2023-10-11 00:53:07 -07:00 committed by GitHub
commit 5722261e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 26 deletions

View File

@ -845,6 +845,12 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
if (options.main_mod == null)
break :blk false;
// If we cannot use LLVM libraries, then our own backends will be a
// better default since the LLVM backend can only produce bitcode
// and not an object file or executable.
if (!use_lib_llvm)
break :blk false;
// If LLVM does not support the target, then we can't use it.
if (!target_util.hasLlvmSupport(options.target, options.target.ofmt))
break :blk false;

View File

@ -491,9 +491,8 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
}
// MSVC compiler_rt is missing some stuff, so we build it unconditionally but
// and rely on weak linkage to allow MSVC compiler_rt functions to override ours.
if (comp.compiler_rt_lib) |lib| {
try argv.append(lib.full_object_path);
}
if (comp.compiler_rt_obj) |obj| try argv.append(obj.full_object_path);
if (comp.compiler_rt_lib) |lib| try argv.append(lib.full_object_path);
}
try argv.ensureUnusedCapacity(self.base.options.system_libs.count());

View File

@ -186,9 +186,8 @@ pub fn linkWithZld(
try positionals.append(.{ .path = p });
}
if (comp.compiler_rt_lib) |lib| {
try positionals.append(.{ .path = lib.full_object_path });
}
if (comp.compiler_rt_lib) |lib| try positionals.append(.{ .path = lib.full_object_path });
if (comp.compiler_rt_obj) |obj| try positionals.append(.{ .path = obj.full_object_path });
// libc++ dep
if (options.link_libcpp) {
@ -301,9 +300,8 @@ pub fn linkWithZld(
try argv.append(p);
}
if (comp.compiler_rt_lib) |lib| {
try argv.append(lib.full_object_path);
}
if (comp.compiler_rt_lib) |lib| try argv.append(lib.full_object_path);
if (comp.compiler_rt_obj) |obj| try argv.append(obj.full_object_path);
if (options.link_libcpp) {
try argv.append(comp.libcxxabi_static_lib.?.full_object_path);

View File

@ -3257,11 +3257,12 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l
sub_prog_node.activate();
defer sub_prog_node.end();
const is_obj = options.output_mode == .Obj;
const compiler_rt_path: ?[]const u8 = if (options.include_compiler_rt and !is_obj)
comp.compiler_rt_lib.?.full_object_path
else
null;
const compiler_rt_path: ?[]const u8 = blk: {
if (comp.compiler_rt_obj) |obj| break :blk obj.full_object_path;
if (comp.compiler_rt_lib) |lib| break :blk lib.full_object_path;
break :blk null;
};
const id_symlink_basename = "zld.id";
var man: Cache.Manifest = undefined;
@ -3376,9 +3377,8 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l
try positionals.append(c_object.status.success.object_path);
}
if (comp.compiler_rt_lib) |lib| {
try positionals.append(lib.full_object_path);
}
if (comp.compiler_rt_lib) |lib| try positionals.append(lib.full_object_path);
if (comp.compiler_rt_obj) |obj| try positionals.append(obj.full_object_path);
try wasm.parseInputFiles(positionals.items);
@ -3463,9 +3463,8 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
try positionals.append(c_object.status.success.object_path);
}
if (comp.compiler_rt_lib) |lib| {
try positionals.append(lib.full_object_path);
}
if (comp.compiler_rt_lib) |lib| try positionals.append(lib.full_object_path);
if (comp.compiler_rt_obj) |obj| try positionals.append(obj.full_object_path);
try wasm.parseInputFiles(positionals.items);
@ -4325,11 +4324,11 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
defer sub_prog_node.end();
const is_obj = wasm.base.options.output_mode == .Obj;
const compiler_rt_path: ?[]const u8 = if (wasm.base.options.include_compiler_rt and !is_obj)
comp.compiler_rt_lib.?.full_object_path
else
null;
const compiler_rt_path: ?[]const u8 = blk: {
if (comp.compiler_rt_lib) |lib| break :blk lib.full_object_path;
if (comp.compiler_rt_obj) |obj| break :blk obj.full_object_path;
break :blk null;
};
const target = wasm.base.options.target;

View File

@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
const check = lib.checkObject();
check.checkInSymtab();
check.checkNotPresent("external");
check.checkNotPresent("external _abc");
test_step.dependOn(&check.step);
}