authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-09 16:58:23-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-10 11:17:29-07:00
log6e0904504155d3cba80955c108116170fd739aec
tree478d4c606d36f4b77405fe10ddf678de1f784862
parent2ca7cc46c41dc5fe91fe385df4f3330634bd88f3

compiler_rt: no need to put it in a static library

It's simpler to link against compiler_rt.o directly.

5 files changed, 13 insertions(+), 40 deletions(-)

src/Compilation.zig+1-18
......@@ -112,7 +112,6 @@ unwind_tables: bool,
112112test_evented_io: bool,
113113debug_compiler_runtime_libs: bool,
114114debug_compile_errors: bool,
115job_queued_compiler_rt_lib: bool = false,
116115job_queued_compiler_rt_obj: bool = false,
117116alloc_failure_occurred: bool = false,
118117formatted_panics: bool = false,
......@@ -158,9 +157,6 @@ libssp_static_lib: ?CRTFile = null,
158157/// Populated when we build the libc static library. A Job to build this is placed in the queue
159158/// and resolved before calling linker.flush().
160159libc_static_lib: ?CRTFile = null,
161/// Populated when we build the libcompiler_rt static library. A Job to build this is indicated
162/// by setting `job_queued_compiler_rt_lib` and resolved before calling linker.flush().
163compiler_rt_lib: ?CRTFile = null,
164160/// Populated when we build the compiler_rt_obj object. A Job to build this is indicated
165161/// by setting `job_queued_compiler_rt_obj` and resolved before calling linker.flush().
166162compiler_rt_obj: ?CRTFile = null,
......@@ -1877,13 +1873,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
18771873 }
18781874
18791875 if (comp.bin_file.options.include_compiler_rt and capable_of_building_compiler_rt) {
1880 if (is_exe_or_dyn_lib) {
1881 log.debug("queuing a job to build compiler_rt_lib", .{});
1882 comp.job_queued_compiler_rt_lib = true;
1883 } else if (options.output_mode != .Obj) {
1876 if (is_exe_or_dyn_lib or options.output_mode != .Obj) {
18841877 log.debug("queuing a job to build compiler_rt_obj", .{});
1885 // In this case we are making a static library, so we ask
1886 // for a compiler-rt object to put in it.
18871878 comp.job_queued_compiler_rt_obj = true;
18881879 }
18891880 }
......@@ -1938,9 +1929,6 @@ pub fn destroy(self: *Compilation) void {
19381929 if (self.libcxxabi_static_lib) |*crt_file| {
19391930 crt_file.deinit(gpa);
19401931 }
1941 if (self.compiler_rt_lib) |*crt_file| {
1942 crt_file.deinit(gpa);
1943 }
19441932 if (self.compiler_rt_obj) |*crt_file| {
19451933 crt_file.deinit(gpa);
19461934 }
......@@ -3407,11 +3395,6 @@ pub fn performAllTheWork(
34073395 break;
34083396 }
34093397
3410 if (comp.job_queued_compiler_rt_lib) {
3411 comp.job_queued_compiler_rt_lib = false;
3412 buildCompilerRtOneShot(comp, .Lib, &comp.compiler_rt_lib, main_progress_node);
3413 }
3414
34153398 if (comp.job_queued_compiler_rt_obj) {
34163399 comp.job_queued_compiler_rt_obj = false;
34173400 buildCompilerRtOneShot(comp, .Obj, &comp.compiler_rt_obj, main_progress_node);
src/link/Coff/lld.zig+2-2
......@@ -491,8 +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);
494 if (comp.compiler_rt_obj) |obj| {
495 try argv.append(obj.full_object_path);
496496 }
497497 }
498498
src/link/Elf.zig-2
......@@ -1257,7 +1257,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
12571257 // to be after the shared libraries, so they are picked up from the shared
12581258 // libraries, not libcompiler_rt.
12591259 const compiler_rt_path: ?[]const u8 = blk: {
1260 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
12611260 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
12621261 break :blk null;
12631262 };
......@@ -1957,7 +1956,6 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
19571956 const stack_size = self.base.options.stack_size_override orelse 16777216;
19581957 const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os;
19591958 const compiler_rt_path: ?[]const u8 = blk: {
1960 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
19611959 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
19621960 break :blk null;
19631961 };
src/link/MachO/zld.zig+4-4
......@@ -186,8 +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 });
189 if (comp.compiler_rt_obj) |obj| {
190 try positionals.append(.{ .path = obj.full_object_path });
191191 }
192192
193193 // libc++ dep
......@@ -301,8 +301,8 @@ pub fn linkWithZld(
301301 try argv.append(p);
302302 }
303303
304 if (comp.compiler_rt_lib) |lib| {
305 try argv.append(lib.full_object_path);
304 if (comp.compiler_rt_obj) |obj| {
305 try argv.append(obj.full_object_path);
306306 }
307307
308308 if (options.link_libcpp) {
src/link/Wasm.zig+6-14
......@@ -3257,11 +3257,7 @@ 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 = if (comp.compiler_rt_obj) |o| o.full_object_path else null;
32653261 const id_symlink_basename = "zld.id";
32663262
32673263 var man: Cache.Manifest = undefined;
......@@ -3376,8 +3372,8 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l
33763372 try positionals.append(c_object.status.success.object_path);
33773373 }
33783374
3379 if (comp.compiler_rt_lib) |lib| {
3380 try positionals.append(lib.full_object_path);
3375 if (comp.compiler_rt_obj) |obj| {
3376 try positionals.append(obj.full_object_path);
33813377 }
33823378
33833379 try wasm.parseInputFiles(positionals.items);
......@@ -3463,8 +3459,8 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
34633459 try positionals.append(c_object.status.success.object_path);
34643460 }
34653461
3466 if (comp.compiler_rt_lib) |lib| {
3467 try positionals.append(lib.full_object_path);
3462 if (comp.compiler_rt_obj) |obj| {
3463 try positionals.append(obj.full_object_path);
34683464 }
34693465
34703466 try wasm.parseInputFiles(positionals.items);
......@@ -4325,11 +4321,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
43254321 defer sub_prog_node.end();
43264322
43274323 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;
4324 const compiler_rt_path: ?[]const u8 = if (comp.compiler_rt_obj) |o| o.full_object_path else null;
43334325
43344326 const target = wasm.base.options.target;
43354327