| ... | @@ -3695,15 +3695,19 @@ fn performAllTheWorkInner( | ... | @@ -3695,15 +3695,19 @@ fn performAllTheWorkInner( |
| 3695 | // In case it failed last time, try again. `clearMiscFailures` was already | 3695 | // In case it failed last time, try again. `clearMiscFailures` was already |
| 3696 | // called at the start of `update`. | 3696 | // called at the start of `update`. |
| 3697 | if (comp.queued_jobs.compiler_rt_lib and comp.compiler_rt_lib == null) { | 3697 | if (comp.queued_jobs.compiler_rt_lib and comp.compiler_rt_lib == null) { |
| 3698 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Lib, &comp.compiler_rt_lib, main_progress_node }); | 3698 | // LLVM disables LTO for its compiler-rt and we've had various issues with LTO of our |
| | 3699 | // compiler-rt due to LLD bugs as well, e.g.: |
| | 3700 | // |
| | 3701 | // https://github.com/llvm/llvm-project/issues/43698#issuecomment-2542660611 |
| | 3702 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Lib, false, &comp.compiler_rt_lib, main_progress_node }); |
| 3699 | } | 3703 | } |
| 3700 | | 3704 | |
| 3701 | if (comp.queued_jobs.compiler_rt_obj and comp.compiler_rt_obj == null) { | 3705 | if (comp.queued_jobs.compiler_rt_obj and comp.compiler_rt_obj == null) { |
| 3702 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Obj, &comp.compiler_rt_obj, main_progress_node }); | 3706 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "compiler_rt.zig", .compiler_rt, .Obj, false, &comp.compiler_rt_obj, main_progress_node }); |
| 3703 | } | 3707 | } |
| 3704 | | 3708 | |
| 3705 | if (comp.queued_jobs.fuzzer_lib and comp.fuzzer_lib == null) { | 3709 | if (comp.queued_jobs.fuzzer_lib and comp.fuzzer_lib == null) { |
| 3706 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, &comp.fuzzer_lib, main_progress_node }); | 3710 | comp.link_task_wait_group.spawnManager(buildRt, .{ comp, "fuzzer.zig", .libfuzzer, .Lib, true, &comp.fuzzer_lib, main_progress_node }); |
| 3707 | } | 3711 | } |
| 3708 | | 3712 | |
| 3709 | if (comp.queued_jobs.glibc_shared_objects) { | 3713 | if (comp.queued_jobs.glibc_shared_objects) { |
| ... | @@ -4635,12 +4639,14 @@ fn buildRt( | ... | @@ -4635,12 +4639,14 @@ fn buildRt( |
| 4635 | root_source_name: []const u8, | 4639 | root_source_name: []const u8, |
| 4636 | misc_task: MiscTask, | 4640 | misc_task: MiscTask, |
| 4637 | output_mode: std.builtin.OutputMode, | 4641 | output_mode: std.builtin.OutputMode, |
| | 4642 | allow_lto: bool, |
| 4638 | out: *?CrtFile, | 4643 | out: *?CrtFile, |
| 4639 | prog_node: std.Progress.Node, | 4644 | prog_node: std.Progress.Node, |
| 4640 | ) void { | 4645 | ) void { |
| 4641 | comp.buildOutputFromZig( | 4646 | comp.buildOutputFromZig( |
| 4642 | root_source_name, | 4647 | root_source_name, |
| 4643 | output_mode, | 4648 | output_mode, |
| | 4649 | allow_lto, |
| 4644 | out, | 4650 | out, |
| 4645 | misc_task, | 4651 | misc_task, |
| 4646 | prog_node, | 4652 | prog_node, |
| ... | @@ -4748,6 +4754,7 @@ fn buildZigLibc(comp: *Compilation, prog_node: std.Progress.Node) void { | ... | @@ -4748,6 +4754,7 @@ fn buildZigLibc(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 4748 | comp.buildOutputFromZig( | 4754 | comp.buildOutputFromZig( |
| 4749 | "c.zig", | 4755 | "c.zig", |
| 4750 | .Lib, | 4756 | .Lib, |
| | 4757 | true, |
| 4751 | &comp.libc_static_lib, | 4758 | &comp.libc_static_lib, |
| 4752 | .zig_libc, | 4759 | .zig_libc, |
| 4753 | prog_node, | 4760 | prog_node, |
| ... | @@ -6453,6 +6460,7 @@ fn buildOutputFromZig( | ... | @@ -6453,6 +6460,7 @@ fn buildOutputFromZig( |
| 6453 | comp: *Compilation, | 6460 | comp: *Compilation, |
| 6454 | src_basename: []const u8, | 6461 | src_basename: []const u8, |
| 6455 | output_mode: std.builtin.OutputMode, | 6462 | output_mode: std.builtin.OutputMode, |
| | 6463 | allow_lto: bool, |
| 6456 | out: *?CrtFile, | 6464 | out: *?CrtFile, |
| 6457 | misc_task_tag: MiscTask, | 6465 | misc_task_tag: MiscTask, |
| 6458 | prog_node: std.Progress.Node, | 6466 | prog_node: std.Progress.Node, |
| ... | @@ -6481,6 +6489,7 @@ fn buildOutputFromZig( | ... | @@ -6481,6 +6489,7 @@ fn buildOutputFromZig( |
| 6481 | .root_strip = strip, | 6489 | .root_strip = strip, |
| 6482 | .link_libc = comp.config.link_libc, | 6490 | .link_libc = comp.config.link_libc, |
| 6483 | .any_unwind_tables = comp.root_mod.unwind_tables != .none, | 6491 | .any_unwind_tables = comp.root_mod.unwind_tables != .none, |
| | 6492 | .lto = if (allow_lto) comp.config.lto else .none, |
| 6484 | }); | 6493 | }); |
| 6485 | | 6494 | |
| 6486 | const root_mod = try Package.Module.create(arena, .{ | 6495 | const root_mod = try Package.Module.create(arena, .{ |
| ... | @@ -6581,6 +6590,8 @@ pub const CrtFileOptions = struct { | ... | @@ -6581,6 +6590,8 @@ pub const CrtFileOptions = struct { |
| 6581 | unwind_tables: ?std.builtin.UnwindTables = null, | 6590 | unwind_tables: ?std.builtin.UnwindTables = null, |
| 6582 | pic: ?bool = null, | 6591 | pic: ?bool = null, |
| 6583 | no_builtin: ?bool = null, | 6592 | no_builtin: ?bool = null, |
| | 6593 | |
| | 6594 | allow_lto: bool = true, |
| 6584 | }; | 6595 | }; |
| 6585 | | 6596 | |
| 6586 | pub fn build_crt_file( | 6597 | pub fn build_crt_file( |
| ... | @@ -6619,7 +6630,7 @@ pub fn build_crt_file( | ... | @@ -6619,7 +6630,7 @@ pub fn build_crt_file( |
| 6619 | .link_libc = false, | 6630 | .link_libc = false, |
| 6620 | .any_unwind_tables = options.unwind_tables != .none, | 6631 | .any_unwind_tables = options.unwind_tables != .none, |
| 6621 | .lto = switch (output_mode) { | 6632 | .lto = switch (output_mode) { |
| 6622 | .Lib => comp.config.lto, | 6633 | .Lib => if (options.allow_lto) comp.config.lto else .none, |
| 6623 | .Obj, .Exe => .none, | 6634 | .Obj, .Exe => .none, |
| 6624 | }, | 6635 | }, |
| 6625 | }); | 6636 | }); |