| author | |
| committer | |
| log | 4e3fcbea84de17afdf391293dc143a1fcc7b2ef7 |
| tree | 5afa0213d212bbfd13ce8d4ec786bab8ebbca3a2 |
| parent | 0ee6a79da5a134a57d178edbe1acdd289470c909 |
This is an extension of the existing hack used for the x86_64 backend combined with the Coff linker3 files changed, 38 insertions(+), 0 deletions(-)
lib/std/Build/Step/Compile.zig+16| ... | @@ -219,6 +219,8 @@ generated_docs: ?*GeneratedFile, | ... | @@ -219,6 +219,8 @@ generated_docs: ?*GeneratedFile, |
| 219 | generated_asm: ?*GeneratedFile, | 219 | generated_asm: ?*GeneratedFile, |
| 220 | generated_bin: ?*GeneratedFile, | 220 | generated_bin: ?*GeneratedFile, |
| 221 | generated_pdb: ?*GeneratedFile, | 221 | generated_pdb: ?*GeneratedFile, |
| 222 | // hack for stage2_x86_64 + coff | ||
| 223 | generated_compiler_rt_dyn_lib: ?*GeneratedFile, | ||
| 222 | generated_implib: ?*GeneratedFile, | 224 | generated_implib: ?*GeneratedFile, |
| 223 | generated_llvm_bc: ?*GeneratedFile, | 225 | generated_llvm_bc: ?*GeneratedFile, |
| 224 | generated_llvm_ir: ?*GeneratedFile, | 226 | generated_llvm_ir: ?*GeneratedFile, |
| ... | @@ -441,6 +443,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { | ... | @@ -441,6 +443,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 441 | .generated_asm = null, | 443 | .generated_asm = null, |
| 442 | .generated_bin = null, | 444 | .generated_bin = null, |
| 443 | .generated_pdb = null, | 445 | .generated_pdb = null, |
| 446 | .generated_compiler_rt_dyn_lib = null, | ||
| 444 | .generated_implib = null, | 447 | .generated_implib = null, |
| 445 | .generated_llvm_bc = null, | 448 | .generated_llvm_bc = null, |
| 446 | .generated_llvm_ir = null, | 449 | .generated_llvm_ir = null, |
| ... | @@ -691,6 +694,11 @@ pub fn producesPdbFile(compile: *Compile) bool { | ... | @@ -691,6 +694,11 @@ pub fn producesPdbFile(compile: *Compile) bool { |
| 691 | return compile.isDynamicLibrary() or compile.kind == .exe or compile.kind == .@"test"; | 694 | return compile.isDynamicLibrary() or compile.kind == .exe or compile.kind == .@"test"; |
| 692 | } | 695 | } |
| 693 | 696 | ||
| 697 | pub fn producesCompilerRtDynLib(compile: *Compile) bool { | ||
| 698 | if (compile.rootModuleTarget().ofmt != .coff) return false; | ||
| 699 | return compile.use_llvm == false; | ||
| 700 | } | ||
| 701 | |||
| 694 | pub fn producesImplib(compile: *Compile) bool { | 702 | pub fn producesImplib(compile: *Compile) bool { |
| 695 | return compile.isDll(); | 703 | return compile.isDll(); |
| 696 | } | 704 | } |
| ... | @@ -869,6 +877,12 @@ pub fn getEmittedPdb(compile: *Compile) LazyPath { | ... | @@ -869,6 +877,12 @@ pub fn getEmittedPdb(compile: *Compile) LazyPath { |
| 869 | return compile.getEmittedFileGeneric(&compile.generated_pdb); | 877 | return compile.getEmittedFileGeneric(&compile.generated_pdb); |
| 870 | } | 878 | } |
| 871 | 879 | ||
| 880 | /// Returns the generated compiler_rt dynamic library. | ||
| 881 | /// This is a hack for stage2_x86_64 + coff. | ||
| 882 | pub fn getEmittedCompilerRtDynLib(compile: *Compile) ?LazyPath { | ||
| 883 | return compile.getEmittedFileGeneric(&compile.generated_compiler_rt_dyn_lib); | ||
| 884 | } | ||
| 885 | |||
| 872 | /// Returns the path to the generated documentation directory. | 886 | /// Returns the path to the generated documentation directory. |
| 873 | pub fn getEmittedDocs(compile: *Compile) LazyPath { | 887 | pub fn getEmittedDocs(compile: *Compile) LazyPath { |
| 874 | return compile.getEmittedFileGeneric(&compile.generated_docs); | 888 | return compile.getEmittedFileGeneric(&compile.generated_docs); |
| ... | @@ -1794,6 +1808,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -1794,6 +1808,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 1794 | // zig fmt: off | 1808 | // zig fmt: off |
| 1795 | if (compile.generated_bin) |lp| lp.path = compile.outputPath(output_dir, .bin); | 1809 | if (compile.generated_bin) |lp| lp.path = compile.outputPath(output_dir, .bin); |
| 1796 | if (compile.generated_pdb) |lp| lp.path = compile.outputPath(output_dir, .pdb); | 1810 | if (compile.generated_pdb) |lp| lp.path = compile.outputPath(output_dir, .pdb); |
| 1811 | // hack for stage2_x86_64 + coff | ||
| 1812 | if (compile.generated_compiler_rt_dyn_lib) |lp| lp.path = compile.outputPath(output_dir, .compiler_rt_dyn_lib); | ||
| 1797 | if (compile.generated_implib) |lp| lp.path = compile.outputPath(output_dir, .implib); | 1813 | if (compile.generated_implib) |lp| lp.path = compile.outputPath(output_dir, .implib); |
| 1798 | if (compile.generated_h) |lp| lp.path = compile.outputPath(output_dir, .h); | 1814 | if (compile.generated_h) |lp| lp.path = compile.outputPath(output_dir, .h); |
| 1799 | if (compile.generated_docs) |lp| lp.path = compile.outputPath(output_dir, .docs); | 1815 | if (compile.generated_docs) |lp| lp.path = compile.outputPath(output_dir, .docs); |
lib/std/Build/Step/InstallArtifact.zig+18| ... | @@ -17,6 +17,10 @@ emitted_implib: ?LazyPath, | ... | @@ -17,6 +17,10 @@ emitted_implib: ?LazyPath, |
| 17 | pdb_dir: ?InstallDir, | 17 | pdb_dir: ?InstallDir, |
| 18 | emitted_pdb: ?LazyPath, | 18 | emitted_pdb: ?LazyPath, |
| 19 | 19 | ||
| 20 | // hack for stage2_x86_64 + coff | ||
| 21 | compiler_rt_dyn_lib_dir: ?InstallDir, | ||
| 22 | emitted_compiler_rt_dyn_lib: ?LazyPath, | ||
| 23 | |||
| 20 | h_dir: ?InstallDir, | 24 | h_dir: ?InstallDir, |
| 21 | emitted_h: ?LazyPath, | 25 | emitted_h: ?LazyPath, |
| 22 | 26 | ||
| ... | @@ -35,6 +39,7 @@ pub const Options = struct { | ... | @@ -35,6 +39,7 @@ pub const Options = struct { |
| 35 | /// Which installation directory to put the main output file into. | 39 | /// Which installation directory to put the main output file into. |
| 36 | dest_dir: Dir = .default, | 40 | dest_dir: Dir = .default, |
| 37 | pdb_dir: Dir = .default, | 41 | pdb_dir: Dir = .default, |
| 42 | compiler_rt_dyn_lib_dir: Dir = .default, | ||
| 38 | h_dir: Dir = .default, | 43 | h_dir: Dir = .default, |
| 39 | implib_dir: Dir = .default, | 44 | implib_dir: Dir = .default, |
| 40 | 45 | ||
| ... | @@ -75,6 +80,11 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins | ... | @@ -75,6 +80,11 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 75 | .default => if (artifact.producesPdbFile()) dest_dir else null, | 80 | .default => if (artifact.producesPdbFile()) dest_dir else null, |
| 76 | .override => |o| o, | 81 | .override => |o| o, |
| 77 | }, | 82 | }, |
| 83 | .compiler_rt_dyn_lib_dir = switch (options.compiler_rt_dyn_lib_dir) { | ||
| 84 | .disabled => null, | ||
| 85 | .default => if (artifact.producesCompilerRtDynLib()) dest_dir else null, | ||
| 86 | .override => |o| o, | ||
| 87 | }, | ||
| 78 | .h_dir = switch (options.h_dir) { | 88 | .h_dir = switch (options.h_dir) { |
| 79 | .disabled => null, | 89 | .disabled => null, |
| 80 | .default => if (artifact.kind == .lib) .header else null, | 90 | .default => if (artifact.kind == .lib) .header else null, |
| ... | @@ -98,6 +108,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins | ... | @@ -98,6 +108,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 98 | 108 | ||
| 99 | .emitted_bin = null, | 109 | .emitted_bin = null, |
| 100 | .emitted_pdb = null, | 110 | .emitted_pdb = null, |
| 111 | .emitted_compiler_rt_dyn_lib = null, | ||
| 101 | .emitted_h = null, | 112 | .emitted_h = null, |
| 102 | .emitted_implib = null, | 113 | .emitted_implib = null, |
| 103 | 114 | ||
| ... | @@ -107,6 +118,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins | ... | @@ -107,6 +118,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 107 | install_artifact.step.dependOn(&artifact.step); | 118 | install_artifact.step.dependOn(&artifact.step); |
| 108 | 119 | ||
| 109 | if (install_artifact.dest_dir != null) install_artifact.emitted_bin = artifact.getEmittedBin(); | 120 | if (install_artifact.dest_dir != null) install_artifact.emitted_bin = artifact.getEmittedBin(); |
| 121 | if (install_artifact.compiler_rt_dyn_lib_dir != null) install_artifact.emitted_compiler_rt_dyn_lib = artifact.getEmittedCompilerRtDynLib(); | ||
| 110 | if (install_artifact.pdb_dir != null) install_artifact.emitted_pdb = artifact.getEmittedPdb(); | 122 | if (install_artifact.pdb_dir != null) install_artifact.emitted_pdb = artifact.getEmittedPdb(); |
| 111 | // https://github.com/ziglang/zig/issues/9698 | 123 | // https://github.com/ziglang/zig/issues/9698 |
| 112 | //if (install_artifact.h_dir != null) install_artifact.emitted_h = artifact.getEmittedH(); | 124 | //if (install_artifact.h_dir != null) install_artifact.emitted_h = artifact.getEmittedH(); |
| ... | @@ -135,6 +147,12 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -135,6 +147,12 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 135 | install_artifact.artifact.installed_path = full_dest_path; | 147 | install_artifact.artifact.installed_path = full_dest_path; |
| 136 | } | 148 | } |
| 137 | 149 | ||
| 150 | if (install_artifact.compiler_rt_dyn_lib_dir) |compiler_rt_dir| { | ||
| 151 | const full_compiler_rt_path = b.getInstallPath(compiler_rt_dir, install_artifact.emitted_compiler_rt_dyn_lib.?.basename(b, step)); | ||
| 152 | const p = try step.installFile(install_artifact.emitted_compiler_rt_dyn_lib.?, full_compiler_rt_path); | ||
| 153 | all_cached = all_cached and p == .fresh; | ||
| 154 | } | ||
| 155 | |||
| 138 | if (install_artifact.implib_dir) |implib_dir| { | 156 | if (install_artifact.implib_dir) |implib_dir| { |
| 139 | const full_implib_path = b.getInstallPath(implib_dir, install_artifact.emitted_implib.?.basename(b, step)); | 157 | const full_implib_path = b.getInstallPath(implib_dir, install_artifact.emitted_implib.?.basename(b, step)); |
| 140 | const p = try step.installFile(install_artifact.emitted_implib.?, full_implib_path); | 158 | const p = try step.installFile(install_artifact.emitted_implib.?, full_implib_path); |
lib/std/zig.zig+4| ... | @@ -985,11 +985,14 @@ pub const EmitArtifact = enum { | ... | @@ -985,11 +985,14 @@ pub const EmitArtifact = enum { |
| 985 | docs, | 985 | docs, |
| 986 | pdb, | 986 | pdb, |
| 987 | h, | 987 | h, |
| 988 | compiler_rt_dyn_lib, | ||
| 988 | 989 | ||
| 989 | /// If using `Server` to communicate with the compiler, it will place requested artifacts in | 990 | /// If using `Server` to communicate with the compiler, it will place requested artifacts in |
| 990 | /// paths under the output directory, where those paths are named according to this function. | 991 | /// paths under the output directory, where those paths are named according to this function. |
| 991 | /// Returned string is allocated with `gpa` and owned by the caller. | 992 | /// Returned string is allocated with `gpa` and owned by the caller. |
| 992 | pub fn cacheName(ea: EmitArtifact, gpa: Allocator, opts: BinNameOptions) Allocator.Error![]const u8 { | 993 | pub fn cacheName(ea: EmitArtifact, gpa: Allocator, opts: BinNameOptions) Allocator.Error![]const u8 { |
| 994 | // hack for stage2_x86_64 + coff | ||
| 995 | if (ea == .compiler_rt_dyn_lib) return "compiler_rt.dll"; | ||
| 993 | const suffix: []const u8 = switch (ea) { | 996 | const suffix: []const u8 = switch (ea) { |
| 994 | .bin => return binNameAlloc(gpa, opts), | 997 | .bin => return binNameAlloc(gpa, opts), |
| 995 | .@"asm" => ".s", | 998 | .@"asm" => ".s", |
| ... | @@ -999,6 +1002,7 @@ pub const EmitArtifact = enum { | ... | @@ -999,6 +1002,7 @@ pub const EmitArtifact = enum { |
| 999 | .docs => "-docs", | 1002 | .docs => "-docs", |
| 1000 | .pdb => ".pdb", | 1003 | .pdb => ".pdb", |
| 1001 | .h => ".h", | 1004 | .h => ".h", |
| 1005 | .compiler_rt_dyn_lib => unreachable, | ||
| 1002 | }; | 1006 | }; |
| 1003 | return std.fmt.allocPrint(gpa, "{s}{s}", .{ opts.root_name, suffix }); | 1007 | return std.fmt.allocPrint(gpa, "{s}{s}", .{ opts.root_name, suffix }); |
| 1004 | } | 1008 | } |