| author | |
| committer | |
| log | c7c1d65372019199824d5f2284a63031383f0512 |
| tree | 70b83be3ca5e2f08da71a59731cc55f3d0a9baf2 |
| parent | 3ee12f3a2aeab1aff5852466cf0c654222e034cc |
4 files changed, 5 insertions(+), 72 deletions(-)
lib/std/zig.zig-4| ... | ... | @@ -996,14 +996,11 @@ pub const EmitArtifact = enum { |
| 996 | 996 | docs, |
| 997 | 997 | pdb, |
| 998 | 998 | h, |
| 999 | compiler_rt_dyn_lib, | |
| 1000 | 999 | |
| 1001 | 1000 | /// If using `Server` to communicate with the compiler, it will place requested artifacts in |
| 1002 | 1001 | /// paths under the output directory, where those paths are named according to this function. |
| 1003 | 1002 | /// Returned string is allocated with `gpa` and owned by the caller. |
| 1004 | 1003 | pub fn cacheName(ea: EmitArtifact, gpa: Allocator, opts: BinNameOptions) Allocator.Error![]const u8 { |
| 1005 | // hack for stage2_x86_64 + coff. See Coff.flush. | |
| 1006 | if (ea == .compiler_rt_dyn_lib) return "compiler_rt.dll"; | |
| 1007 | 1004 | const suffix: []const u8 = switch (ea) { |
| 1008 | 1005 | .bin => return binNameAlloc(gpa, opts), |
| 1009 | 1006 | .@"asm" => ".s", |
| ... | ... | @@ -1013,7 +1010,6 @@ pub const EmitArtifact = enum { |
| 1013 | 1010 | .docs => "-docs", |
| 1014 | 1011 | .pdb => ".pdb", |
| 1015 | 1012 | .h => ".h", |
| 1016 | .compiler_rt_dyn_lib => unreachable, | |
| 1017 | 1013 | }; |
| 1018 | 1014 | return std.fmt.allocPrint(gpa, "{s}{s}", .{ opts.root_name, suffix }); |
| 1019 | 1015 | } |
src/Compilation.zig+2-37| ... | ... | @@ -223,8 +223,6 @@ compiler_rt_lib: ?CrtFile = null, |
| 223 | 223 | /// Populated when we build the compiler_rt_obj object. A Job to build this is indicated |
| 224 | 224 | /// by setting `queued_jobs.compiler_rt_obj` and resolved before calling linker.flush(). |
| 225 | 225 | compiler_rt_obj: ?CrtFile = null, |
| 226 | /// hack for stage2_x86_64 + coff | |
| 227 | compiler_rt_dyn_lib: ?CrtFile = null, | |
| 228 | 226 | /// Populated when we build the libfuzzer static library. A Job to build this |
| 229 | 227 | /// is indicated by setting `queued_jobs.fuzzer_lib` and resolved before |
| 230 | 228 | /// calling linker.flush(). |
| ... | ... | @@ -287,8 +285,6 @@ emit_llvm_bc: ?[]const u8, |
| 287 | 285 | emit_docs: ?[]const u8, |
| 288 | 286 | |
| 289 | 287 | const QueuedJobs = struct { |
| 290 | /// hack for stage2_x86_64 + coff | |
| 291 | compiler_rt_dyn_lib: bool = false, | |
| 292 | 288 | compiler_rt_lib: bool = false, |
| 293 | 289 | compiler_rt_obj: bool = false, |
| 294 | 290 | ubsan_rt_lib: bool = false, |
| ... | ... | @@ -1781,7 +1777,7 @@ fn addModuleTableToCacheHash( |
| 1781 | 1777 | } |
| 1782 | 1778 | } |
| 1783 | 1779 | |
| 1784 | const RtStrat = enum { none, lib, obj, zcu, dyn_lib }; | |
| 1780 | const RtStrat = enum { none, lib, obj, zcu }; | |
| 1785 | 1781 | |
| 1786 | 1782 | pub const CreateDiagnostic = union(enum) { |
| 1787 | 1783 | export_table_import_table_conflict, |
| ... | ... | @@ -1902,12 +1898,6 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 1902 | 1898 | }; |
| 1903 | 1899 | if (have_zcu and (!need_llvm or use_llvm)) { |
| 1904 | 1900 | if (output_mode == .Obj) break :s .zcu; |
| 1905 | switch (target_util.zigBackend(target, use_llvm)) { | |
| 1906 | else => {}, | |
| 1907 | .stage2_aarch64, .stage2_x86_64 => if (target.ofmt == .coff) { | |
| 1908 | break :s if (is_exe_or_dyn_lib and build_options.have_llvm) .dyn_lib else .zcu; | |
| 1909 | }, | |
| 1910 | } | |
| 1911 | 1901 | } |
| 1912 | 1902 | if (need_llvm and !build_options.have_llvm) break :s .none; // impossible to build without llvm |
| 1913 | 1903 | if (is_exe_or_dyn_lib) break :s .lib; |
| ... | ... | @@ -2628,11 +2618,6 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2628 | 2618 | log.debug("queuing a job to build compiler_rt_obj", .{}); |
| 2629 | 2619 | comp.queued_jobs.compiler_rt_obj = true; |
| 2630 | 2620 | }, |
| 2631 | .dyn_lib => { | |
| 2632 | // hack for stage2_x86_64 + coff | |
| 2633 | log.debug("queuing a job to build compiler_rt_dyn_lib", .{}); | |
| 2634 | comp.queued_jobs.compiler_rt_dyn_lib = true; | |
| 2635 | }, | |
| 2636 | 2621 | } |
| 2637 | 2622 | |
| 2638 | 2623 | switch (comp.ubsan_rt_strat) { |
| ... | ... | @@ -2645,7 +2630,6 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2645 | 2630 | log.debug("queuing a job to build ubsan_rt_obj", .{}); |
| 2646 | 2631 | comp.queued_jobs.ubsan_rt_obj = true; |
| 2647 | 2632 | }, |
| 2648 | .dyn_lib => unreachable, // hack for compiler_rt only | |
| 2649 | 2633 | } |
| 2650 | 2634 | |
| 2651 | 2635 | switch (comp.zigc_strat) { |
| ... | ... | @@ -2654,7 +2638,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2654 | 2638 | log.debug("queuing a job to build libzigc", .{}); |
| 2655 | 2639 | comp.queued_jobs.zigc_lib = true; |
| 2656 | 2640 | }, |
| 2657 | .obj, .dyn_lib => unreachable, // only available as a static library or inside an existing ZCU | |
| 2641 | .obj => unreachable, // only available as a static library or inside an existing ZCU | |
| 2658 | 2642 | } |
| 2659 | 2643 | |
| 2660 | 2644 | if (is_exe_or_dyn_lib and comp.config.any_fuzz) { |
| ... | ... | @@ -2713,7 +2697,6 @@ pub fn destroy(comp: *Compilation) void { |
| 2713 | 2697 | if (comp.zigc_static_lib) |*crt_file| crt_file.deinit(gpa, io); |
| 2714 | 2698 | if (comp.compiler_rt_lib) |*crt_file| crt_file.deinit(gpa, io); |
| 2715 | 2699 | if (comp.compiler_rt_obj) |*crt_file| crt_file.deinit(gpa, io); |
| 2716 | if (comp.compiler_rt_dyn_lib) |*crt_file| crt_file.deinit(gpa, io); | |
| 2717 | 2700 | if (comp.fuzzer_lib) |*crt_file| crt_file.deinit(gpa, io); |
| 2718 | 2701 | |
| 2719 | 2702 | if (comp.glibc_so_files) |*glibc_file| { |
| ... | ... | @@ -4566,24 +4549,6 @@ fn dispatchPrelinkWork(comp: *Compilation, main_progress_node: std.Progress.Node |
| 4566 | 4549 | }); |
| 4567 | 4550 | } |
| 4568 | 4551 | |
| 4569 | // hack for stage2_x86_64 + coff | |
| 4570 | if (comp.queued_jobs.compiler_rt_dyn_lib and comp.compiler_rt_dyn_lib == null) { | |
| 4571 | prelink_group.async(io, buildRt, .{ | |
| 4572 | comp, | |
| 4573 | "compiler_rt.zig", | |
| 4574 | "compiler_rt", | |
| 4575 | .Lib, | |
| 4576 | .dynamic, | |
| 4577 | .compiler_rt, | |
| 4578 | main_progress_node, | |
| 4579 | RtOptions{ | |
| 4580 | .checks_valgrind = true, | |
| 4581 | .allow_lto = false, | |
| 4582 | }, | |
| 4583 | &comp.compiler_rt_dyn_lib, | |
| 4584 | }); | |
| 4585 | } | |
| 4586 | ||
| 4587 | 4552 | if (comp.queued_jobs.fuzzer_lib and comp.fuzzer_lib == null) { |
| 4588 | 4553 | prelink_group.async(io, buildRt, .{ |
| 4589 | 4554 | comp, |
src/codegen/x86_64/Emit.zig-8| ... | ... | @@ -154,19 +154,11 @@ pub fn emitMir(emit: *Emit) Error!void { |
| 154 | 154 | @enumFromInt(try elf_file.getGlobalSymbol(extern_func.toSlice(&emit.lower.mir).?, null)) |
| 155 | 155 | else if (emit.bin_file.cast(.elf2)) |elf| try elf.externSymbol(.{ |
| 156 | 156 | .name = extern_func.toSlice(&emit.lower.mir).?, |
| 157 | .lib_name = switch (comp.compiler_rt_strat) { | |
| 158 | .none, .lib, .obj, .zcu => null, | |
| 159 | .dyn_lib => "compiler_rt", | |
| 160 | }, | |
| 161 | 157 | .type = .FUNC, |
| 162 | 158 | }) else if (emit.bin_file.cast(.macho)) |macho_file| |
| 163 | 159 | @enumFromInt(try macho_file.getGlobalSymbol(extern_func.toSlice(&emit.lower.mir).?, null)) |
| 164 | 160 | else if (emit.bin_file.cast(.coff2)) |coff| @enumFromInt(@intFromEnum(try coff.globalSymbol(.{ |
| 165 | 161 | .name = extern_func.toSlice(&emit.lower.mir).?, |
| 166 | .lib_name = switch (comp.compiler_rt_strat) { | |
| 167 | .none, .lib, .obj, .zcu => null, | |
| 168 | .dyn_lib => "compiler_rt", | |
| 169 | }, | |
| 170 | 162 | }))) else return emit.fail("external symbol unimplemented for {s}", .{@tagName(emit.bin_file.tag)}), |
| 171 | 163 | .is_extern = true, |
| 172 | 164 | } }, |
src/link/Coff.zig+3-23| ... | ... | @@ -3283,7 +3283,7 @@ fn loadObject( |
| 3283 | 3283 | header.machine, |
| 3284 | 3284 | }); |
| 3285 | 3285 | if (header.number_of_sections == 0) return; |
| 3286 | if (@sizeOf(std.coff.Header) + header.number_of_sections * @sizeOf(std.coff.SectionHeader) > fl.size) | |
| 3286 | if (@sizeOf(std.coff.Header) + @as(usize, header.number_of_sections) * @sizeOf(std.coff.SectionHeader) > fl.size) | |
| 3287 | 3287 | return diags.failParse(path, "invalid section table", .{}); |
| 3288 | 3288 | const unexpected_header_flags: []const std.meta.FieldEnum(std.coff.Header.Flags) = &.{ |
| 3289 | 3289 | .RELOCS_STRIPPED, |
| ... | ... | @@ -4507,26 +4507,6 @@ pub fn flush( |
| 4507 | 4507 | coff.flushImplib(implib_file) catch |err| |
| 4508 | 4508 | return comp.link_diags.fail("flushing implib '{s}' failed: {t}", .{ implib_file, err }); |
| 4509 | 4509 | |
| 4510 | // hack for stage2_x86_64 + coff | |
| 4511 | if (comp.compiler_rt_dyn_lib) |crt_file| { | |
| 4512 | const io = comp.io; | |
| 4513 | const gpa = comp.gpa; | |
| 4514 | ||
| 4515 | const compiler_rt_sub_path = try std.fs.path.join(gpa, &.{ | |
| 4516 | std.fs.path.dirname(coff.base.emit.sub_path) orelse "", | |
| 4517 | std.fs.path.basename(crt_file.full_object_path.sub_path), | |
| 4518 | }); | |
| 4519 | defer gpa.free(compiler_rt_sub_path); | |
| 4520 | std.Io.Dir.copyFile( | |
| 4521 | crt_file.full_object_path.root_dir.handle, | |
| 4522 | crt_file.full_object_path.sub_path, | |
| 4523 | coff.base.emit.root_dir.handle, | |
| 4524 | compiler_rt_sub_path, | |
| 4525 | io, | |
| 4526 | .{}, | |
| 4527 | ) catch |err| return comp.link_diags.fail("copy '{s}' failed: {t}", .{ compiler_rt_sub_path, err }); | |
| 4528 | } | |
| 4529 | ||
| 4530 | 4510 | coff.mf.flush() catch |err| switch (err) { |
| 4531 | 4511 | error.Canceled => |e| return e, |
| 4532 | 4512 | else => |e| return comp.link_diags.fail("flush write failed: {t}", .{e}), |
| ... | ... | @@ -4558,14 +4538,14 @@ pub fn idle(coff: *Coff, tid: Zcu.PerThread.Id) !bool { |
| 4558 | 4538 | } |
| 4559 | 4539 | if (coff.pending_input) |pending_iami| { |
| 4560 | 4540 | // TODO: Prog node? |
| 4541 | coff.pending_input = null; | |
| 4561 | 4542 | coff.flushInputMember(pending_iami) catch |err| switch (err) { |
| 4562 | 4543 | error.OutOfMemory => return error.OutOfMemory, |
| 4563 | 4544 | else => |e| return comp.link_diags.fail( |
| 4564 | "linker failed to archive member: {t}", | |
| 4545 | "linker failed to load archive member: {t}", | |
| 4565 | 4546 | .{e}, |
| 4566 | 4547 | ), |
| 4567 | 4548 | }; |
| 4568 | coff.pending_input = null; | |
| 4569 | 4549 | break :task; |
| 4570 | 4550 | } |
| 4571 | 4551 | if (coff.global_pending_index < coff.globals.count()) { |