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,...@@ -112,7 +112,6 @@ unwind_tables: bool,
112test_evented_io: bool,112test_evented_io: bool,
113debug_compiler_runtime_libs: bool,113debug_compiler_runtime_libs: bool,
114debug_compile_errors: bool,114debug_compile_errors: bool,
115job_queued_compiler_rt_lib: bool = false,
116job_queued_compiler_rt_obj: bool = false,115job_queued_compiler_rt_obj: bool = false,
117alloc_failure_occurred: bool = false,116alloc_failure_occurred: bool = false,
118formatted_panics: bool = false,117formatted_panics: bool = false,
...@@ -158,9 +157,6 @@ libssp_static_lib: ?CRTFile = null,...@@ -158,9 +157,6 @@ libssp_static_lib: ?CRTFile = null,
158/// Populated when we build the libc static library. A Job to build this is placed in the queue157/// Populated when we build the libc static library. A Job to build this is placed in the queue
159/// and resolved before calling linker.flush().158/// and resolved before calling linker.flush().
160libc_static_lib: ?CRTFile = null,159libc_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,
164/// Populated when we build the compiler_rt_obj object. A Job to build this is indicated160/// Populated when we build the compiler_rt_obj object. A Job to build this is indicated
165/// by setting `job_queued_compiler_rt_obj` and resolved before calling linker.flush().161/// by setting `job_queued_compiler_rt_obj` and resolved before calling linker.flush().
166compiler_rt_obj: ?CRTFile = null,162compiler_rt_obj: ?CRTFile = null,
...@@ -1877,13 +1873,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1877,13 +1873,8 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1877 }1873 }
18781874
1879 if (comp.bin_file.options.include_compiler_rt and capable_of_building_compiler_rt) {1875 if (comp.bin_file.options.include_compiler_rt and capable_of_building_compiler_rt) {
1880 if (is_exe_or_dyn_lib) {1876 if (is_exe_or_dyn_lib or options.output_mode != .Obj) {
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) {
1884 log.debug("queuing a job to build compiler_rt_obj", .{});1877 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.
1887 comp.job_queued_compiler_rt_obj = true;1878 comp.job_queued_compiler_rt_obj = true;
1888 }1879 }
1889 }1880 }
...@@ -1938,9 +1929,6 @@ pub fn destroy(self: *Compilation) void {...@@ -1938,9 +1929,6 @@ pub fn destroy(self: *Compilation) void {
1938 if (self.libcxxabi_static_lib) |*crt_file| {1929 if (self.libcxxabi_static_lib) |*crt_file| {
1939 crt_file.deinit(gpa);1930 crt_file.deinit(gpa);
1940 }1931 }
1941 if (self.compiler_rt_lib) |*crt_file| {
1942 crt_file.deinit(gpa);
1943 }
1944 if (self.compiler_rt_obj) |*crt_file| {1932 if (self.compiler_rt_obj) |*crt_file| {
1945 crt_file.deinit(gpa);1933 crt_file.deinit(gpa);
1946 }1934 }
...@@ -3407,11 +3395,6 @@ pub fn performAllTheWork(...@@ -3407,11 +3395,6 @@ pub fn performAllTheWork(
3407 break;3395 break;
3408 }3396 }
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
3415 if (comp.job_queued_compiler_rt_obj) {3398 if (comp.job_queued_compiler_rt_obj) {
3416 comp.job_queued_compiler_rt_obj = false;3399 comp.job_queued_compiler_rt_obj = false;
3417 buildCompilerRtOneShot(comp, .Obj, &comp.compiler_rt_obj, main_progress_node);3400 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...@@ -491,8 +491,8 @@ pub fn linkWithLLD(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod
491 }491 }
492 // MSVC compiler_rt is missing some stuff, so we build it unconditionally but492 // MSVC compiler_rt is missing some stuff, so we build it unconditionally but
493 // and rely on weak linkage to allow MSVC compiler_rt functions to override ours.493 // and rely on weak linkage to allow MSVC compiler_rt functions to override ours.
494 if (comp.compiler_rt_lib) |lib| {494 if (comp.compiler_rt_obj) |obj| {
495 try argv.append(lib.full_object_path);495 try argv.append(obj.full_object_path);
496 }496 }
497 }497 }
498498
src/link/Elf.zig-2
...@@ -1257,7 +1257,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node...@@ -1257,7 +1257,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
1257 // to be after the shared libraries, so they are picked up from the shared1257 // to be after the shared libraries, so they are picked up from the shared
1258 // libraries, not libcompiler_rt.1258 // libraries, not libcompiler_rt.
1259 const compiler_rt_path: ?[]const u8 = blk: {1259 const compiler_rt_path: ?[]const u8 = blk: {
1260 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
1261 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;1260 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
1262 break :blk null;1261 break :blk null;
1263 };1262 };
...@@ -1957,7 +1956,6 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v...@@ -1957,7 +1956,6 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
1957 const stack_size = self.base.options.stack_size_override orelse 16777216;1956 const stack_size = self.base.options.stack_size_override orelse 16777216;
1958 const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os;1957 const allow_shlib_undefined = self.base.options.allow_shlib_undefined orelse !self.base.options.is_native_os;
1959 const compiler_rt_path: ?[]const u8 = blk: {1958 const compiler_rt_path: ?[]const u8 = blk: {
1960 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
1961 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;1959 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
1962 break :blk null;1960 break :blk null;
1963 };1961 };
src/link/MachO/zld.zig+4-4
...@@ -186,8 +186,8 @@ pub fn linkWithZld(...@@ -186,8 +186,8 @@ pub fn linkWithZld(
186 try positionals.append(.{ .path = p });186 try positionals.append(.{ .path = p });
187 }187 }
188188
189 if (comp.compiler_rt_lib) |lib| {189 if (comp.compiler_rt_obj) |obj| {
190 try positionals.append(.{ .path = lib.full_object_path });190 try positionals.append(.{ .path = obj.full_object_path });
191 }191 }
192192
193 // libc++ dep193 // libc++ dep
...@@ -301,8 +301,8 @@ pub fn linkWithZld(...@@ -301,8 +301,8 @@ pub fn linkWithZld(
301 try argv.append(p);301 try argv.append(p);
302 }302 }
303303
304 if (comp.compiler_rt_lib) |lib| {304 if (comp.compiler_rt_obj) |obj| {
305 try argv.append(lib.full_object_path);305 try argv.append(obj.full_object_path);
306 }306 }
307307
308 if (options.link_libcpp) {308 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...@@ -3257,11 +3257,7 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l
3257 sub_prog_node.activate();3257 sub_prog_node.activate();
3258 defer sub_prog_node.end();3258 defer sub_prog_node.end();
32593259
3260 const is_obj = options.output_mode == .Obj;3260 const compiler_rt_path: ?[]const u8 = if (comp.compiler_rt_obj) |o| o.full_object_path else null;
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;
3265 const id_symlink_basename = "zld.id";3261 const id_symlink_basename = "zld.id";
32663262
3267 var man: Cache.Manifest = undefined;3263 var man: Cache.Manifest = undefined;
...@@ -3376,8 +3372,8 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l...@@ -3376,8 +3372,8 @@ fn linkWithZld(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) l
3376 try positionals.append(c_object.status.success.object_path);3372 try positionals.append(c_object.status.success.object_path);
3377 }3373 }
33783374
3379 if (comp.compiler_rt_lib) |lib| {3375 if (comp.compiler_rt_obj) |obj| {
3380 try positionals.append(lib.full_object_path);3376 try positionals.append(obj.full_object_path);
3381 }3377 }
33823378
3383 try wasm.parseInputFiles(positionals.items);3379 try wasm.parseInputFiles(positionals.items);
...@@ -3463,8 +3459,8 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod...@@ -3463,8 +3459,8 @@ pub fn flushModule(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
3463 try positionals.append(c_object.status.success.object_path);3459 try positionals.append(c_object.status.success.object_path);
3464 }3460 }
34653461
3466 if (comp.compiler_rt_lib) |lib| {3462 if (comp.compiler_rt_obj) |obj| {
3467 try positionals.append(lib.full_object_path);3463 try positionals.append(obj.full_object_path);
3468 }3464 }
34693465
3470 try wasm.parseInputFiles(positionals.items);3466 try wasm.parseInputFiles(positionals.items);
...@@ -4325,11 +4321,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !...@@ -4325,11 +4321,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
4325 defer sub_prog_node.end();4321 defer sub_prog_node.end();
43264322
4327 const is_obj = wasm.base.options.output_mode == .Obj;4323 const is_obj = wasm.base.options.output_mode == .Obj;
43284324 const compiler_rt_path: ?[]const u8 = if (comp.compiler_rt_obj) |o| o.full_object_path else null;
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;
43334325
4334 const target = wasm.base.options.target;4326 const target = wasm.base.options.target;
43354327