authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-11 00:53:07-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-10-11 00:53:07-07:00
log5722261e6474e8bac5b8cb341b6344100b8514f2
tree8fc8006e8f3cedeac4a45c88305bc0eb0b0e3fb0
parent42998e637b29df66992d10be270fb97e47758fba
parentda7e4fb31a05f2063eb829c4c383a44b38ed21e1
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #17465

Compilation: default to self-hosted backends when not using libllvm

5 files changed, 28 insertions(+), 26 deletions(-)

src/Compilation.zig+6
......@@ -845,6 +845,12 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
845845 if (options.main_mod == null)
846846 break :blk false;
847847
848 // If we cannot use LLVM libraries, then our own backends will be a
849 // better default since the LLVM backend can only produce bitcode
850 // and not an object file or executable.
851 if (!use_lib_llvm)
852 break :blk false;
853
848854 // If LLVM does not support the target, then we can't use it.
849855 if (!target_util.hasLlvmSupport(options.target, options.target.ofmt))
850856 break :blk false;
src/link/Coff/lld.zig+2-3
......@@ -491,9 +491,8 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
491491 }
492492 // MSVC compiler_rt is missing some stuff, so we build it unconditionally but
493493 // and rely on weak linkage to allow MSVC compiler_rt functions to override ours.
494 if (comp.compiler_rt_lib) |lib| {
495 try argv.append(lib.full_object_path);
496 }
494 if (comp.compiler_rt_obj) |obj| try argv.append(obj.full_object_path);
495 if (comp.compiler_rt_lib) |lib| try argv.append(lib.full_object_path);
497496 }
498497
499498 try argv.ensureUnusedCapacity(self.base.options.system_libs.count());
src/link/MachO/zld.zig+4-6
......@@ -186,9 +186,8 @@ pub fn linkWithZld(
186186 try positionals.append(.{ .path = p });
187187 }
188188
189 if (comp.compiler_rt_lib) |lib| {
190 try positionals.append(.{ .path = lib.full_object_path });
191 }
189 if (comp.compiler_rt_lib) |lib| try positionals.append(.{ .path = lib.full_object_path });
190 if (comp.compiler_rt_obj) |obj| try positionals.append(.{ .path = obj.full_object_path });
192191
193192 // libc++ dep
194193 if (options.link_libcpp) {
......@@ -301,9 +300,8 @@ pub fn linkWithZld(
301300 try argv.append(p);
302301 }
303302
304 if (comp.compiler_rt_lib) |lib| {
305 try argv.append(lib.full_object_path);
306 }
303 if (comp.compiler_rt_lib) |lib| try argv.append(lib.full_object_path);
304 if (comp.compiler_rt_obj) |obj| try argv.append(obj.full_object_path);
307305
308306 if (options.link_libcpp) {
309307 try argv.append(comp.libcxxabi_static_lib.?.full_object_path);
src/link/Wasm.zig+15-16
......@@ -3257,11 +3257,12 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l
32573257 sub_prog_node.activate();
32583258 defer sub_prog_node.end();
32593259
3260 const is_obj = options.output_mode == .Obj;
3261 const compiler_rt_path: ?[]const u8 = if (options.include_compiler_rt and !is_obj)
3262 comp.compiler_rt_lib.?.full_object_path
3263 else
3264 null;
3260 const compiler_rt_path: ?[]const u8 = blk: {
3261 if (comp.compiler_rt_obj) |obj| break :blk obj.full_object_path;
3262 if (comp.compiler_rt_lib) |lib| break :blk lib.full_object_path;
3263 break :blk null;
3264 };
3265
32653266 const id_symlink_basename = "zld.id";
32663267
32673268 var man: Cache.Manifest = undefined;
......@@ -3376,9 +3377,8 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l
33763377 try positionals.append(c_object.status.success.object_path);
33773378 }
33783379
3379 if (comp.compiler_rt_lib) |lib| {
3380 try positionals.append(lib.full_object_path);
3381 }
3380 if (comp.compiler_rt_lib) |lib| try positionals.append(lib.full_object_path);
3381 if (comp.compiler_rt_obj) |obj| try positionals.append(obj.full_object_path);
33823382
33833383 try wasm.parseInputFiles(positionals.items);
33843384
......@@ -3463,9 +3463,8 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
34633463 try positionals.append(c_object.status.success.object_path);
34643464 }
34653465
3466 if (comp.compiler_rt_lib) |lib| {
3467 try positionals.append(lib.full_object_path);
3468 }
3466 if (comp.compiler_rt_lib) |lib| try positionals.append(lib.full_object_path);
3467 if (comp.compiler_rt_obj) |obj| try positionals.append(obj.full_object_path);
34693468
34703469 try wasm.parseInputFiles(positionals.items);
34713470
......@@ -4325,11 +4324,11 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
43254324 defer sub_prog_node.end();
43264325
43274326 const is_obj = wasm.base.options.output_mode == .Obj;
4328
4329 const compiler_rt_path: ?[]const u8 = if (wasm.base.options.include_compiler_rt and !is_obj)
4330 comp.compiler_rt_lib.?.full_object_path
4331 else
4332 null;
4327 const compiler_rt_path: ?[]const u8 = blk: {
4328 if (comp.compiler_rt_lib) |lib| break :blk lib.full_object_path;
4329 if (comp.compiler_rt_obj) |obj| break :blk obj.full_object_path;
4330 break :blk null;
4331 };
43334332
43344333 const target = wasm.base.options.target;
43354334
test/link/macho/bugs/16308/build.zig+1-1
......@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) void {
1717
1818 const check = lib.checkObject();
1919 check.checkInSymtab();
20 check.checkNotPresent("external");
20 check.checkNotPresent("external _abc");
2121
2222 test_step.dependOn(&check.step);
2323}