| ... | ... | @@ -224,6 +224,8 @@ compiler_rt_lib: ?CrtFile = null, |
| 224 | 224 | /// Populated when we build the compiler_rt_obj object. A Job to build this is indicated |
| 225 | 225 | /// by setting `queued_jobs.compiler_rt_obj` and resolved before calling linker.flush(). |
| 226 | 226 | compiler_rt_obj: ?CrtFile = null, |
| 227 | /// hack for stage2_x86_64 + coff |
| 228 | compiler_rt_dyn_lib: ?CrtFile = null, |
| 227 | 229 | /// Populated when we build the libfuzzer static library. A Job to build this |
| 228 | 230 | /// is indicated by setting `queued_jobs.fuzzer_lib` and resolved before |
| 229 | 231 | /// calling linker.flush(). |
| ... | ... | @@ -291,6 +293,8 @@ emit_llvm_bc: ?[]const u8, |
| 291 | 293 | emit_docs: ?[]const u8, |
| 292 | 294 | |
| 293 | 295 | const QueuedJobs = struct { |
| 296 | /// hack for stage2_x86_64 + coff |
| 297 | compiler_rt_dyn_lib: bool = false, |
| 294 | 298 | compiler_rt_lib: bool = false, |
| 295 | 299 | compiler_rt_obj: bool = false, |
| 296 | 300 | ubsan_rt_lib: bool = false, |
| ... | ... | @@ -1753,7 +1757,7 @@ fn addModuleTableToCacheHash( |
| 1753 | 1757 | } |
| 1754 | 1758 | } |
| 1755 | 1759 | |
| 1756 | | const RtStrat = enum { none, lib, obj, zcu }; |
| 1760 | const RtStrat = enum { none, lib, obj, zcu, dyn_lib }; |
| 1757 | 1761 | |
| 1758 | 1762 | pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compilation { |
| 1759 | 1763 | const output_mode = options.config.output_mode; |
| ... | ... | @@ -1816,7 +1820,11 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1816 | 1820 | if (options.skip_linker_dependencies) break :s .none; |
| 1817 | 1821 | const want = options.want_compiler_rt orelse is_exe_or_dyn_lib; |
| 1818 | 1822 | if (!want) break :s .none; |
| 1819 | | if (have_zcu and output_mode == .Obj) break :s .zcu; |
| 1823 | if (have_zcu) { |
| 1824 | if (output_mode == .Obj) break :s .zcu; |
| 1825 | if (target.ofmt == .coff and target_util.zigBackend(target, use_llvm) == .stage2_x86_64) |
| 1826 | break :s if (is_exe_or_dyn_lib) .dyn_lib else .zcu; |
| 1827 | } |
| 1820 | 1828 | if (is_exe_or_dyn_lib) break :s .lib; |
| 1821 | 1829 | break :s .obj; |
| 1822 | 1830 | }; |
| ... | ... | @@ -2441,6 +2449,11 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 2441 | 2449 | // for a compiler-rt object to put in it. |
| 2442 | 2450 | comp.queued_jobs.compiler_rt_obj = true; |
| 2443 | 2451 | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2452 | } else if (comp.compiler_rt_strat == .dyn_lib) { |
| 2453 | // hack for stage2_x86_64 + coff |
| 2454 | log.debug("queuing a job to build compiler_rt_dyn_lib", .{}); |
| 2455 | comp.queued_jobs.compiler_rt_dyn_lib = true; |
| 2456 | comp.link_task_queue.pending_prelink_tasks += 1; |
| 2444 | 2457 | } |
| 2445 | 2458 | |
| 2446 | 2459 | if (comp.ubsan_rt_strat == .lib) { |
| ... | ... | @@ -4254,6 +4267,7 @@ fn performAllTheWork( |
| 4254 | 4267 | "compiler_rt.zig", |
| 4255 | 4268 | "compiler_rt", |
| 4256 | 4269 | .Lib, |
| 4270 | .static, |
| 4257 | 4271 | .compiler_rt, |
| 4258 | 4272 | main_progress_node, |
| 4259 | 4273 | RtOptions{ |
| ... | ... | @@ -4270,6 +4284,7 @@ fn performAllTheWork( |
| 4270 | 4284 | "compiler_rt.zig", |
| 4271 | 4285 | "compiler_rt", |
| 4272 | 4286 | .Obj, |
| 4287 | .static, |
| 4273 | 4288 | .compiler_rt, |
| 4274 | 4289 | main_progress_node, |
| 4275 | 4290 | RtOptions{ |
| ... | ... | @@ -4280,12 +4295,31 @@ fn performAllTheWork( |
| 4280 | 4295 | }); |
| 4281 | 4296 | } |
| 4282 | 4297 | |
| 4298 | // hack for stage2_x86_64 + coff |
| 4299 | if (comp.queued_jobs.compiler_rt_dyn_lib and comp.compiler_rt_dyn_lib == null) { |
| 4300 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4301 | comp, |
| 4302 | "compiler_rt.zig", |
| 4303 | "compiler_rt", |
| 4304 | .Lib, |
| 4305 | .dynamic, |
| 4306 | .compiler_rt, |
| 4307 | main_progress_node, |
| 4308 | RtOptions{ |
| 4309 | .checks_valgrind = true, |
| 4310 | .allow_lto = false, |
| 4311 | }, |
| 4312 | &comp.compiler_rt_dyn_lib, |
| 4313 | }); |
| 4314 | } |
| 4315 | |
| 4283 | 4316 | if (comp.queued_jobs.fuzzer_lib and comp.fuzzer_lib == null) { |
| 4284 | 4317 | comp.link_task_wait_group.spawnManager(buildRt, .{ |
| 4285 | 4318 | comp, |
| 4286 | 4319 | "fuzzer.zig", |
| 4287 | 4320 | "fuzzer", |
| 4288 | 4321 | .Lib, |
| 4322 | .static, |
| 4289 | 4323 | .libfuzzer, |
| 4290 | 4324 | main_progress_node, |
| 4291 | 4325 | RtOptions{}, |
| ... | ... | @@ -4299,6 +4333,7 @@ fn performAllTheWork( |
| 4299 | 4333 | "ubsan_rt.zig", |
| 4300 | 4334 | "ubsan_rt", |
| 4301 | 4335 | .Lib, |
| 4336 | .static, |
| 4302 | 4337 | .libubsan, |
| 4303 | 4338 | main_progress_node, |
| 4304 | 4339 | RtOptions{ |
| ... | ... | @@ -4314,6 +4349,7 @@ fn performAllTheWork( |
| 4314 | 4349 | "ubsan_rt.zig", |
| 4315 | 4350 | "ubsan_rt", |
| 4316 | 4351 | .Obj, |
| 4352 | .static, |
| 4317 | 4353 | .libubsan, |
| 4318 | 4354 | main_progress_node, |
| 4319 | 4355 | RtOptions{ |
| ... | ... | @@ -5390,6 +5426,7 @@ fn buildRt( |
| 5390 | 5426 | root_source_name: []const u8, |
| 5391 | 5427 | root_name: []const u8, |
| 5392 | 5428 | output_mode: std.builtin.OutputMode, |
| 5429 | link_mode: std.builtin.LinkMode, |
| 5393 | 5430 | misc_task: MiscTask, |
| 5394 | 5431 | prog_node: std.Progress.Node, |
| 5395 | 5432 | options: RtOptions, |
| ... | ... | @@ -5399,6 +5436,7 @@ fn buildRt( |
| 5399 | 5436 | root_source_name, |
| 5400 | 5437 | root_name, |
| 5401 | 5438 | output_mode, |
| 5439 | link_mode, |
| 5402 | 5440 | misc_task, |
| 5403 | 5441 | prog_node, |
| 5404 | 5442 | options, |
| ... | ... | @@ -5554,6 +5592,7 @@ fn buildLibZigC(comp: *Compilation, prog_node: std.Progress.Node) void { |
| 5554 | 5592 | "c.zig", |
| 5555 | 5593 | "zigc", |
| 5556 | 5594 | .Lib, |
| 5595 | .static, |
| 5557 | 5596 | .libzigc, |
| 5558 | 5597 | prog_node, |
| 5559 | 5598 | .{}, |
| ... | ... | @@ -7231,6 +7270,7 @@ fn buildOutputFromZig( |
| 7231 | 7270 | src_basename: []const u8, |
| 7232 | 7271 | root_name: []const u8, |
| 7233 | 7272 | output_mode: std.builtin.OutputMode, |
| 7273 | link_mode: std.builtin.LinkMode, |
| 7234 | 7274 | misc_task_tag: MiscTask, |
| 7235 | 7275 | prog_node: std.Progress.Node, |
| 7236 | 7276 | options: RtOptions, |
| ... | ... | @@ -7251,7 +7291,7 @@ fn buildOutputFromZig( |
| 7251 | 7291 | |
| 7252 | 7292 | const config = try Config.resolve(.{ |
| 7253 | 7293 | .output_mode = output_mode, |
| 7254 | | .link_mode = .static, |
| 7294 | .link_mode = link_mode, |
| 7255 | 7295 | .resolved_target = comp.root_mod.resolved_target, |
| 7256 | 7296 | .is_test = false, |
| 7257 | 7297 | .have_zcu = true, |