| 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 | 219 | generated_asm: ?*GeneratedFile, |
| 220 | 220 | generated_bin: ?*GeneratedFile, |
| 221 | 221 | generated_pdb: ?*GeneratedFile, |
| 222 | // hack for stage2_x86_64 + coff | |
| 223 | generated_compiler_rt_dyn_lib: ?*GeneratedFile, | |
| 222 | 224 | generated_implib: ?*GeneratedFile, |
| 223 | 225 | generated_llvm_bc: ?*GeneratedFile, |
| 224 | 226 | generated_llvm_ir: ?*GeneratedFile, |
| ... | ... | @@ -441,6 +443,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 441 | 443 | .generated_asm = null, |
| 442 | 444 | .generated_bin = null, |
| 443 | 445 | .generated_pdb = null, |
| 446 | .generated_compiler_rt_dyn_lib = null, | |
| 444 | 447 | .generated_implib = null, |
| 445 | 448 | .generated_llvm_bc = null, |
| 446 | 449 | .generated_llvm_ir = null, |
| ... | ... | @@ -691,6 +694,11 @@ pub fn producesPdbFile(compile: *Compile) bool { |
| 691 | 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 | 702 | pub fn producesImplib(compile: *Compile) bool { |
| 695 | 703 | return compile.isDll(); |
| 696 | 704 | } |
| ... | ... | @@ -869,6 +877,12 @@ pub fn getEmittedPdb(compile: *Compile) LazyPath { |
| 869 | 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 | 886 | /// Returns the path to the generated documentation directory. |
| 873 | 887 | pub fn getEmittedDocs(compile: *Compile) LazyPath { |
| 874 | 888 | return compile.getEmittedFileGeneric(&compile.generated_docs); |
| ... | ... | @@ -1794,6 +1808,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 1794 | 1808 | // zig fmt: off |
| 1795 | 1809 | if (compile.generated_bin) |lp| lp.path = compile.outputPath(output_dir, .bin); |
| 1796 | 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 | 1813 | if (compile.generated_implib) |lp| lp.path = compile.outputPath(output_dir, .implib); |
| 1798 | 1814 | if (compile.generated_h) |lp| lp.path = compile.outputPath(output_dir, .h); |
| 1799 | 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 | 17 | pdb_dir: ?InstallDir, |
| 18 | 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 | 24 | h_dir: ?InstallDir, |
| 21 | 25 | emitted_h: ?LazyPath, |
| 22 | 26 | |
| ... | ... | @@ -35,6 +39,7 @@ pub const Options = struct { |
| 35 | 39 | /// Which installation directory to put the main output file into. |
| 36 | 40 | dest_dir: Dir = .default, |
| 37 | 41 | pdb_dir: Dir = .default, |
| 42 | compiler_rt_dyn_lib_dir: Dir = .default, | |
| 38 | 43 | h_dir: Dir = .default, |
| 39 | 44 | implib_dir: Dir = .default, |
| 40 | 45 | |
| ... | ... | @@ -75,6 +80,11 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 75 | 80 | .default => if (artifact.producesPdbFile()) dest_dir else null, |
| 76 | 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 | 88 | .h_dir = switch (options.h_dir) { |
| 79 | 89 | .disabled => null, |
| 80 | 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 | 108 | |
| 99 | 109 | .emitted_bin = null, |
| 100 | 110 | .emitted_pdb = null, |
| 111 | .emitted_compiler_rt_dyn_lib = null, | |
| 101 | 112 | .emitted_h = null, |
| 102 | 113 | .emitted_implib = null, |
| 103 | 114 | |
| ... | ... | @@ -107,6 +118,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 107 | 118 | install_artifact.step.dependOn(&artifact.step); |
| 108 | 119 | |
| 109 | 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 | 122 | if (install_artifact.pdb_dir != null) install_artifact.emitted_pdb = artifact.getEmittedPdb(); |
| 111 | 123 | // https://github.com/ziglang/zig/issues/9698 |
| 112 | 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 | 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 | 156 | if (install_artifact.implib_dir) |implib_dir| { |
| 139 | 157 | const full_implib_path = b.getInstallPath(implib_dir, install_artifact.emitted_implib.?.basename(b, step)); |
| 140 | 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 | 985 | docs, |
| 986 | 986 | pdb, |
| 987 | 987 | h, |
| 988 | compiler_rt_dyn_lib, | |
| 988 | 989 | |
| 989 | 990 | /// If using `Server` to communicate with the compiler, it will place requested artifacts in |
| 990 | 991 | /// paths under the output directory, where those paths are named according to this function. |
| 991 | 992 | /// Returned string is allocated with `gpa` and owned by the caller. |
| 992 | 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 | 996 | const suffix: []const u8 = switch (ea) { |
| 994 | 997 | .bin => return binNameAlloc(gpa, opts), |
| 995 | 998 | .@"asm" => ".s", |
| ... | ... | @@ -999,6 +1002,7 @@ pub const EmitArtifact = enum { |
| 999 | 1002 | .docs => "-docs", |
| 1000 | 1003 | .pdb => ".pdb", |
| 1001 | 1004 | .h => ".h", |
| 1005 | .compiler_rt_dyn_lib => unreachable, | |
| 1002 | 1006 | }; |
| 1003 | 1007 | return std.fmt.allocPrint(gpa, "{s}{s}", .{ opts.root_name, suffix }); |
| 1004 | 1008 | } |