| author | |
| committer | |
| log | 34c21affa2429cf07042eb2f225ee59194998802 |
| tree | b75283e0215fa3e5de31c1995e71a56f35942c28 |
| parent | 1f0b77b3b88112ef458f62c23df72003c843e7cc |
The code now compiles and fails with Plan9ObjectFormatUnimplemented10 files changed, 114 insertions(+), 3 deletions(-)
CMakeLists.txt+2| ... | @@ -573,6 +573,8 @@ set(ZIG_STAGE2_SOURCES | ... | @@ -573,6 +573,8 @@ set(ZIG_STAGE2_SOURCES |
| 573 | "${CMAKE_SOURCE_DIR}/src/link/C.zig" | 573 | "${CMAKE_SOURCE_DIR}/src/link/C.zig" |
| 574 | "${CMAKE_SOURCE_DIR}/src/link/Coff.zig" | 574 | "${CMAKE_SOURCE_DIR}/src/link/Coff.zig" |
| 575 | "${CMAKE_SOURCE_DIR}/src/link/Elf.zig" | 575 | "${CMAKE_SOURCE_DIR}/src/link/Elf.zig" |
| 576 | "${CMAKE_SOURCE_DIR}/src/link/Plan9.zig" | ||
| 577 | "${CMAKE_SOURCE_DIR}/src/link/plan9/a.out.zig" | ||
| 576 | "${CMAKE_SOURCE_DIR}/src/link/MachO.zig" | 578 | "${CMAKE_SOURCE_DIR}/src/link/MachO.zig" |
| 577 | "${CMAKE_SOURCE_DIR}/src/link/MachO/Archive.zig" | 579 | "${CMAKE_SOURCE_DIR}/src/link/MachO/Archive.zig" |
| 578 | "${CMAKE_SOURCE_DIR}/src/link/MachO/CodeSignature.zig" | 580 | "${CMAKE_SOURCE_DIR}/src/link/MachO/CodeSignature.zig" |
lib/std/target.zig+9| ... | @@ -60,6 +60,7 @@ pub const Target = struct { | ... | @@ -60,6 +60,7 @@ pub const Target = struct { |
| 60 | opencl, | 60 | opencl, |
| 61 | glsl450, | 61 | glsl450, |
| 62 | vulkan, | 62 | vulkan, |
| 63 | plan9, | ||
| 63 | other, | 64 | other, |
| 64 | 65 | ||
| 65 | pub fn isDarwin(tag: Tag) bool { | 66 | pub fn isDarwin(tag: Tag) bool { |
| ... | @@ -262,6 +263,7 @@ pub const Target = struct { | ... | @@ -262,6 +263,7 @@ pub const Target = struct { |
| 262 | .opencl, // TODO: OpenCL versions | 263 | .opencl, // TODO: OpenCL versions |
| 263 | .glsl450, // TODO: GLSL versions | 264 | .glsl450, // TODO: GLSL versions |
| 264 | .vulkan, | 265 | .vulkan, |
| 266 | .plan9, | ||
| 265 | .other, | 267 | .other, |
| 266 | => return .{ .none = {} }, | 268 | => return .{ .none = {} }, |
| 267 | 269 | ||
| ... | @@ -420,6 +422,7 @@ pub const Target = struct { | ... | @@ -420,6 +422,7 @@ pub const Target = struct { |
| 420 | .opencl, | 422 | .opencl, |
| 421 | .glsl450, | 423 | .glsl450, |
| 422 | .vulkan, | 424 | .vulkan, |
| 425 | .plan9, | ||
| 423 | .other, | 426 | .other, |
| 424 | => false, | 427 | => false, |
| 425 | }; | 428 | }; |
| ... | @@ -515,6 +518,7 @@ pub const Target = struct { | ... | @@ -515,6 +518,7 @@ pub const Target = struct { |
| 515 | .opencl, // TODO: SPIR-V ABIs with Linkage capability | 518 | .opencl, // TODO: SPIR-V ABIs with Linkage capability |
| 516 | .glsl450, | 519 | .glsl450, |
| 517 | .vulkan, | 520 | .vulkan, |
| 521 | .plan9, // TODO specify abi | ||
| 518 | => return .none, | 522 | => return .none, |
| 519 | } | 523 | } |
| 520 | } | 524 | } |
| ... | @@ -554,6 +558,7 @@ pub const Target = struct { | ... | @@ -554,6 +558,7 @@ pub const Target = struct { |
| 554 | spirv, | 558 | spirv, |
| 555 | hex, | 559 | hex, |
| 556 | raw, | 560 | raw, |
| 561 | plan9, | ||
| 557 | }; | 562 | }; |
| 558 | 563 | ||
| 559 | pub const SubSystem = enum { | 564 | pub const SubSystem = enum { |
| ... | @@ -1359,6 +1364,8 @@ pub const Target = struct { | ... | @@ -1359,6 +1364,8 @@ pub const Target = struct { |
| 1359 | if (cpu_arch.isSPIRV()) { | 1364 | if (cpu_arch.isSPIRV()) { |
| 1360 | return .spirv; | 1365 | return .spirv; |
| 1361 | } | 1366 | } |
| 1367 | if (os_tag == .plan9) | ||
| 1368 | return .plan9; | ||
| 1362 | return .elf; | 1369 | return .elf; |
| 1363 | } | 1370 | } |
| 1364 | 1371 | ||
| ... | @@ -1432,6 +1439,7 @@ pub const Target = struct { | ... | @@ -1432,6 +1439,7 @@ pub const Target = struct { |
| 1432 | .opencl, | 1439 | .opencl, |
| 1433 | .glsl450, | 1440 | .glsl450, |
| 1434 | .vulkan, | 1441 | .vulkan, |
| 1442 | .plan9, | ||
| 1435 | .other, | 1443 | .other, |
| 1436 | => return false, | 1444 | => return false, |
| 1437 | else => return true, | 1445 | else => return true, |
| ... | @@ -1616,6 +1624,7 @@ pub const Target = struct { | ... | @@ -1616,6 +1624,7 @@ pub const Target = struct { |
| 1616 | .glsl450, | 1624 | .glsl450, |
| 1617 | .vulkan, | 1625 | .vulkan, |
| 1618 | .other, | 1626 | .other, |
| 1627 | .plan9, | ||
| 1619 | => return result, | 1628 | => return result, |
| 1620 | 1629 | ||
| 1621 | // TODO revisit when multi-arch for Haiku is available | 1630 | // TODO revisit when multi-arch for Haiku is available |
lib/std/zig.zig+2| ... | @@ -181,6 +181,8 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro | ... | @@ -181,6 +181,8 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro |
| 181 | .spirv => return std.fmt.allocPrint(allocator, "{s}.spv", .{root_name}), | 181 | .spirv => return std.fmt.allocPrint(allocator, "{s}.spv", .{root_name}), |
| 182 | .hex => return std.fmt.allocPrint(allocator, "{s}.ihex", .{root_name}), | 182 | .hex => return std.fmt.allocPrint(allocator, "{s}.ihex", .{root_name}), |
| 183 | .raw => return std.fmt.allocPrint(allocator, "{s}.bin", .{root_name}), | 183 | .raw => return std.fmt.allocPrint(allocator, "{s}.bin", .{root_name}), |
| 184 | // TODO change this to the arbitrary character for plan9 output, eg '6' for amd64 | ||
| 185 | .plan9 => return std.fmt.allocPrint(allocator, "{s}.out.p9", .{root_name}), | ||
| 184 | } | 186 | } |
| 185 | } | 187 | } |
| 186 | 188 |
lib/std/zig/cross_target.zig+2| ... | @@ -133,6 +133,7 @@ pub const CrossTarget = struct { | ... | @@ -133,6 +133,7 @@ pub const CrossTarget = struct { |
| 133 | .opencl, | 133 | .opencl, |
| 134 | .glsl450, | 134 | .glsl450, |
| 135 | .vulkan, | 135 | .vulkan, |
| 136 | .plan9, | ||
| 136 | .other, | 137 | .other, |
| 137 | => { | 138 | => { |
| 138 | self.os_version_min = .{ .none = {} }; | 139 | self.os_version_min = .{ .none = {} }; |
| ... | @@ -746,6 +747,7 @@ pub const CrossTarget = struct { | ... | @@ -746,6 +747,7 @@ pub const CrossTarget = struct { |
| 746 | .opencl, | 747 | .opencl, |
| 747 | .glsl450, | 748 | .glsl450, |
| 748 | .vulkan, | 749 | .vulkan, |
| 750 | .plan9, | ||
| 749 | .other, | 751 | .other, |
| 750 | => return error.InvalidOperatingSystemVersion, | 752 | => return error.InvalidOperatingSystemVersion, |
| 751 | 753 |
src/Module.zig+8| ... | @@ -3437,6 +3437,9 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo | ... | @@ -3437,6 +3437,9 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo |
| 3437 | // in `Decl` to notice that the line number did not change. | 3437 | // in `Decl` to notice that the line number did not change. |
| 3438 | mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl }); | 3438 | mod.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl }); |
| 3439 | }, | 3439 | }, |
| 3440 | .plan9 => { | ||
| 3441 | // TODO implement for plan9 | ||
| 3442 | }, | ||
| 3440 | .c, .wasm, .spirv => {}, | 3443 | .c, .wasm, .spirv => {}, |
| 3441 | } | 3444 | } |
| 3442 | } | 3445 | } |
| ... | @@ -3514,6 +3517,7 @@ pub fn clearDecl( | ... | @@ -3514,6 +3517,7 @@ pub fn clearDecl( |
| 3514 | .coff => .{ .coff = link.File.Coff.TextBlock.empty }, | 3517 | .coff => .{ .coff = link.File.Coff.TextBlock.empty }, |
| 3515 | .elf => .{ .elf = link.File.Elf.TextBlock.empty }, | 3518 | .elf => .{ .elf = link.File.Elf.TextBlock.empty }, |
| 3516 | .macho => .{ .macho = link.File.MachO.TextBlock.empty }, | 3519 | .macho => .{ .macho = link.File.MachO.TextBlock.empty }, |
| 3520 | .plan9 => @panic("plan9 link"), | ||
| 3517 | .c => .{ .c = link.File.C.DeclBlock.empty }, | 3521 | .c => .{ .c = link.File.C.DeclBlock.empty }, |
| 3518 | .wasm => .{ .wasm = link.File.Wasm.DeclBlock.empty }, | 3522 | .wasm => .{ .wasm = link.File.Wasm.DeclBlock.empty }, |
| 3519 | .spirv => .{ .spirv = {} }, | 3523 | .spirv => .{ .spirv = {} }, |
| ... | @@ -3522,6 +3526,7 @@ pub fn clearDecl( | ... | @@ -3522,6 +3526,7 @@ pub fn clearDecl( |
| 3522 | .coff => .{ .coff = {} }, | 3526 | .coff => .{ .coff = {} }, |
| 3523 | .elf => .{ .elf = link.File.Elf.SrcFn.empty }, | 3527 | .elf => .{ .elf = link.File.Elf.SrcFn.empty }, |
| 3524 | .macho => .{ .macho = link.File.MachO.SrcFn.empty }, | 3528 | .macho => .{ .macho = link.File.MachO.SrcFn.empty }, |
| 3529 | .plan9 => @panic("plan9 fn_link"), | ||
| 3525 | .c => .{ .c = link.File.C.FnBlock.empty }, | 3530 | .c => .{ .c = link.File.C.FnBlock.empty }, |
| 3526 | .wasm => .{ .wasm = link.File.Wasm.FnData.empty }, | 3531 | .wasm => .{ .wasm = link.File.Wasm.FnData.empty }, |
| 3527 | .spirv => .{ .spirv = .{} }, | 3532 | .spirv => .{ .spirv = .{} }, |
| ... | @@ -3689,6 +3694,7 @@ fn allocateNewDecl(mod: *Module, namespace: *Scope.Namespace, src_node: ast.Node | ... | @@ -3689,6 +3694,7 @@ fn allocateNewDecl(mod: *Module, namespace: *Scope.Namespace, src_node: ast.Node |
| 3689 | .coff => .{ .coff = link.File.Coff.TextBlock.empty }, | 3694 | .coff => .{ .coff = link.File.Coff.TextBlock.empty }, |
| 3690 | .elf => .{ .elf = link.File.Elf.TextBlock.empty }, | 3695 | .elf => .{ .elf = link.File.Elf.TextBlock.empty }, |
| 3691 | .macho => .{ .macho = link.File.MachO.TextBlock.empty }, | 3696 | .macho => .{ .macho = link.File.MachO.TextBlock.empty }, |
| 3697 | .plan9 => @panic("PLan9 export"), | ||
| 3692 | .c => .{ .c = link.File.C.DeclBlock.empty }, | 3698 | .c => .{ .c = link.File.C.DeclBlock.empty }, |
| 3693 | .wasm => .{ .wasm = link.File.Wasm.DeclBlock.empty }, | 3699 | .wasm => .{ .wasm = link.File.Wasm.DeclBlock.empty }, |
| 3694 | .spirv => .{ .spirv = {} }, | 3700 | .spirv => .{ .spirv = {} }, |
| ... | @@ -3697,6 +3703,7 @@ fn allocateNewDecl(mod: *Module, namespace: *Scope.Namespace, src_node: ast.Node | ... | @@ -3697,6 +3703,7 @@ fn allocateNewDecl(mod: *Module, namespace: *Scope.Namespace, src_node: ast.Node |
| 3697 | .coff => .{ .coff = {} }, | 3703 | .coff => .{ .coff = {} }, |
| 3698 | .elf => .{ .elf = link.File.Elf.SrcFn.empty }, | 3704 | .elf => .{ .elf = link.File.Elf.SrcFn.empty }, |
| 3699 | .macho => .{ .macho = link.File.MachO.SrcFn.empty }, | 3705 | .macho => .{ .macho = link.File.MachO.SrcFn.empty }, |
| 3706 | .plan9 => .{ .plan9 = link.File.Plan9.SrcFn.empty }, | ||
| 3700 | .c => .{ .c = link.File.C.FnBlock.empty }, | 3707 | .c => .{ .c = link.File.C.FnBlock.empty }, |
| 3701 | .wasm => .{ .wasm = link.File.Wasm.FnData.empty }, | 3708 | .wasm => .{ .wasm = link.File.Wasm.FnData.empty }, |
| 3702 | .spirv => .{ .spirv = .{} }, | 3709 | .spirv => .{ .spirv = .{} }, |
| ... | @@ -3766,6 +3773,7 @@ pub fn analyzeExport( | ... | @@ -3766,6 +3773,7 @@ pub fn analyzeExport( |
| 3766 | .coff => .{ .coff = {} }, | 3773 | .coff => .{ .coff = {} }, |
| 3767 | .elf => .{ .elf = link.File.Elf.Export{} }, | 3774 | .elf => .{ .elf = link.File.Elf.Export{} }, |
| 3768 | .macho => .{ .macho = link.File.MachO.Export{} }, | 3775 | .macho => .{ .macho = link.File.MachO.Export{} }, |
| 3776 | .plan9 => @panic("plan9 link"), | ||
| 3769 | .c => .{ .c = {} }, | 3777 | .c => .{ .c = {} }, |
| 3770 | .wasm => .{ .wasm = {} }, | 3778 | .wasm => .{ .wasm = {} }, |
| 3771 | .spirv => .{ .spirv = {} }, | 3779 | .spirv => .{ .spirv = {} }, |
src/codegen/llvm.zig+1| ... | @@ -117,6 +117,7 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { | ... | @@ -117,6 +117,7 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { |
| 117 | .opencl => return error.LLVMBackendDoesNotSupportOpenCL, | 117 | .opencl => return error.LLVMBackendDoesNotSupportOpenCL, |
| 118 | .glsl450 => return error.LLVMBackendDoesNotSupportGLSL450, | 118 | .glsl450 => return error.LLVMBackendDoesNotSupportGLSL450, |
| 119 | .vulkan => return error.LLVMBackendDoesNotSupportVulkan, | 119 | .vulkan => return error.LLVMBackendDoesNotSupportVulkan, |
| 120 | .plan9 => return error.LLVMBackendDoesNotSupportPlan9, | ||
| 120 | .other => "unknown", | 121 | .other => "unknown", |
| 121 | }; | 122 | }; |
| 122 | 123 |
src/link.zig+23-2| ... | @@ -150,6 +150,7 @@ pub const File = struct { | ... | @@ -150,6 +150,7 @@ pub const File = struct { |
| 150 | elf: Elf.SrcFn, | 150 | elf: Elf.SrcFn, |
| 151 | coff: Coff.SrcFn, | 151 | coff: Coff.SrcFn, |
| 152 | macho: MachO.SrcFn, | 152 | macho: MachO.SrcFn, |
| 153 | plan9: Plan9.SrcFn, | ||
| 153 | c: C.FnBlock, | 154 | c: C.FnBlock, |
| 154 | wasm: Wasm.FnData, | 155 | wasm: Wasm.FnData, |
| 155 | spirv: SpirV.FnData, | 156 | spirv: SpirV.FnData, |
| ... | @@ -159,6 +160,7 @@ pub const File = struct { | ... | @@ -159,6 +160,7 @@ pub const File = struct { |
| 159 | elf: Elf.Export, | 160 | elf: Elf.Export, |
| 160 | coff: void, | 161 | coff: void, |
| 161 | macho: MachO.Export, | 162 | macho: MachO.Export, |
| 163 | plan9: Plan9.Export, | ||
| 162 | c: void, | 164 | c: void, |
| 163 | wasm: void, | 165 | wasm: void, |
| 164 | spirv: void, | 166 | spirv: void, |
| ... | @@ -189,6 +191,7 @@ pub const File = struct { | ... | @@ -189,6 +191,7 @@ pub const File = struct { |
| 189 | .elf => &(try Elf.createEmpty(allocator, options)).base, | 191 | .elf => &(try Elf.createEmpty(allocator, options)).base, |
| 190 | .macho => &(try MachO.createEmpty(allocator, options)).base, | 192 | .macho => &(try MachO.createEmpty(allocator, options)).base, |
| 191 | .wasm => &(try Wasm.createEmpty(allocator, options)).base, | 193 | .wasm => &(try Wasm.createEmpty(allocator, options)).base, |
| 194 | .plan9 => return &(try Plan9.createEmpty(allocator, options)).base, | ||
| 192 | .c => unreachable, // Reported error earlier. | 195 | .c => unreachable, // Reported error earlier. |
| 193 | .spirv => &(try SpirV.createEmpty(allocator, options)).base, | 196 | .spirv => &(try SpirV.createEmpty(allocator, options)).base, |
| 194 | .hex => return error.HexObjectFormatUnimplemented, | 197 | .hex => return error.HexObjectFormatUnimplemented, |
| ... | @@ -209,6 +212,7 @@ pub const File = struct { | ... | @@ -209,6 +212,7 @@ pub const File = struct { |
| 209 | .spirv => &(try SpirV.createEmpty(allocator, options)).base, | 212 | .spirv => &(try SpirV.createEmpty(allocator, options)).base, |
| 210 | .hex => return error.HexObjectFormatUnimplemented, | 213 | .hex => return error.HexObjectFormatUnimplemented, |
| 211 | .raw => return error.RawObjectFormatUnimplemented, | 214 | .raw => return error.RawObjectFormatUnimplemented, |
| 215 | .plan9 => return error.Plan9ObjectFormatUnimplemented, | ||
| 212 | }; | 216 | }; |
| 213 | } | 217 | } |
| 214 | // Open a temporary object file, not the final output file because we want to link with LLD. | 218 | // Open a temporary object file, not the final output file because we want to link with LLD. |
| ... | @@ -225,6 +229,7 @@ pub const File = struct { | ... | @@ -225,6 +229,7 @@ pub const File = struct { |
| 225 | .spirv => &(try SpirV.openPath(allocator, sub_path, options)).base, | 229 | .spirv => &(try SpirV.openPath(allocator, sub_path, options)).base, |
| 226 | .hex => return error.HexObjectFormatUnimplemented, | 230 | .hex => return error.HexObjectFormatUnimplemented, |
| 227 | .raw => return error.RawObjectFormatUnimplemented, | 231 | .raw => return error.RawObjectFormatUnimplemented, |
| 232 | .plan9 => return error.Plan9ObjectFormatUnimplemented, | ||
| 228 | }; | 233 | }; |
| 229 | 234 | ||
| 230 | if (use_lld) { | 235 | if (use_lld) { |
| ... | @@ -243,7 +248,7 @@ pub const File = struct { | ... | @@ -243,7 +248,7 @@ pub const File = struct { |
| 243 | 248 | ||
| 244 | pub fn makeWritable(base: *File) !void { | 249 | pub fn makeWritable(base: *File) !void { |
| 245 | switch (base.tag) { | 250 | switch (base.tag) { |
| 246 | .coff, .elf, .macho => { | 251 | .coff, .elf, .macho, .plan9 => { |
| 247 | if (base.file != null) return; | 252 | if (base.file != null) return; |
| 248 | const emit = base.options.emit orelse return; | 253 | const emit = base.options.emit orelse return; |
| 249 | base.file = try emit.directory.handle.createFile(emit.sub_path, .{ | 254 | base.file = try emit.directory.handle.createFile(emit.sub_path, .{ |
| ... | @@ -288,7 +293,7 @@ pub const File = struct { | ... | @@ -288,7 +293,7 @@ pub const File = struct { |
| 288 | f.close(); | 293 | f.close(); |
| 289 | base.file = null; | 294 | base.file = null; |
| 290 | }, | 295 | }, |
| 291 | .coff, .elf => if (base.file) |f| { | 296 | .coff, .elf, .plan9 => if (base.file) |f| { |
| 292 | if (base.intermediary_basename != null) { | 297 | if (base.intermediary_basename != null) { |
| 293 | // The file we have open is not the final file that we want to | 298 | // The file we have open is not the final file that we want to |
| 294 | // make executable, so we don't have to close it. | 299 | // make executable, so we don't have to close it. |
| ... | @@ -313,6 +318,7 @@ pub const File = struct { | ... | @@ -313,6 +318,7 @@ pub const File = struct { |
| 313 | .c => return @fieldParentPtr(C, "base", base).updateDecl(module, decl), | 318 | .c => return @fieldParentPtr(C, "base", base).updateDecl(module, decl), |
| 314 | .wasm => return @fieldParentPtr(Wasm, "base", base).updateDecl(module, decl), | 319 | .wasm => return @fieldParentPtr(Wasm, "base", base).updateDecl(module, decl), |
| 315 | .spirv => return @fieldParentPtr(SpirV, "base", base).updateDecl(module, decl), | 320 | .spirv => return @fieldParentPtr(SpirV, "base", base).updateDecl(module, decl), |
| 321 | .plan9 => return @fieldParentPtr(Plan9, "base", base).updateDecl(module, decl), | ||
| 316 | } | 322 | } |
| 317 | } | 323 | } |
| 318 | 324 | ||
| ... | @@ -326,6 +332,7 @@ pub const File = struct { | ... | @@ -326,6 +332,7 @@ pub const File = struct { |
| 326 | .elf => return @fieldParentPtr(Elf, "base", base).updateDeclLineNumber(module, decl), | 332 | .elf => return @fieldParentPtr(Elf, "base", base).updateDeclLineNumber(module, decl), |
| 327 | .macho => return @fieldParentPtr(MachO, "base", base).updateDeclLineNumber(module, decl), | 333 | .macho => return @fieldParentPtr(MachO, "base", base).updateDeclLineNumber(module, decl), |
| 328 | .c => return @fieldParentPtr(C, "base", base).updateDeclLineNumber(module, decl), | 334 | .c => return @fieldParentPtr(C, "base", base).updateDeclLineNumber(module, decl), |
| 335 | .plan9 => @panic("PLAN 9 DEBUG INFO"), | ||
| 329 | .wasm, .spirv => {}, | 336 | .wasm, .spirv => {}, |
| 330 | } | 337 | } |
| 331 | } | 338 | } |
| ... | @@ -340,6 +347,7 @@ pub const File = struct { | ... | @@ -340,6 +347,7 @@ pub const File = struct { |
| 340 | .macho => return @fieldParentPtr(MachO, "base", base).allocateDeclIndexes(decl), | 347 | .macho => return @fieldParentPtr(MachO, "base", base).allocateDeclIndexes(decl), |
| 341 | .c => return @fieldParentPtr(C, "base", base).allocateDeclIndexes(decl), | 348 | .c => return @fieldParentPtr(C, "base", base).allocateDeclIndexes(decl), |
| 342 | .wasm => return @fieldParentPtr(Wasm, "base", base).allocateDeclIndexes(decl), | 349 | .wasm => return @fieldParentPtr(Wasm, "base", base).allocateDeclIndexes(decl), |
| 350 | .plan9 => return @fieldParentPtr(Plan9, "base", base).allocateDeclIndexes(decl), | ||
| 343 | .spirv => {}, | 351 | .spirv => {}, |
| 344 | } | 352 | } |
| 345 | } | 353 | } |
| ... | @@ -393,6 +401,11 @@ pub const File = struct { | ... | @@ -393,6 +401,11 @@ pub const File = struct { |
| 393 | parent.deinit(); | 401 | parent.deinit(); |
| 394 | base.allocator.destroy(parent); | 402 | base.allocator.destroy(parent); |
| 395 | }, | 403 | }, |
| 404 | .plan9 => { | ||
| 405 | const parent = @fieldParentPtr(Plan9, "base", base); | ||
| 406 | parent.deinit(); | ||
| 407 | base.allocator.destroy(parent); | ||
| 408 | }, | ||
| 396 | } | 409 | } |
| 397 | } | 410 | } |
| 398 | 411 | ||
| ... | @@ -425,6 +438,7 @@ pub const File = struct { | ... | @@ -425,6 +438,7 @@ pub const File = struct { |
| 425 | .c => return @fieldParentPtr(C, "base", base).flush(comp), | 438 | .c => return @fieldParentPtr(C, "base", base).flush(comp), |
| 426 | .wasm => return @fieldParentPtr(Wasm, "base", base).flush(comp), | 439 | .wasm => return @fieldParentPtr(Wasm, "base", base).flush(comp), |
| 427 | .spirv => return @fieldParentPtr(SpirV, "base", base).flush(comp), | 440 | .spirv => return @fieldParentPtr(SpirV, "base", base).flush(comp), |
| 441 | .plan9 => return @fieldParentPtr(Plan9, "base", base).flush(comp), | ||
| 428 | } | 442 | } |
| 429 | } | 443 | } |
| 430 | 444 | ||
| ... | @@ -438,6 +452,7 @@ pub const File = struct { | ... | @@ -438,6 +452,7 @@ pub const File = struct { |
| 438 | .c => return @fieldParentPtr(C, "base", base).flushModule(comp), | 452 | .c => return @fieldParentPtr(C, "base", base).flushModule(comp), |
| 439 | .wasm => return @fieldParentPtr(Wasm, "base", base).flushModule(comp), | 453 | .wasm => return @fieldParentPtr(Wasm, "base", base).flushModule(comp), |
| 440 | .spirv => return @fieldParentPtr(SpirV, "base", base).flushModule(comp), | 454 | .spirv => return @fieldParentPtr(SpirV, "base", base).flushModule(comp), |
| 455 | .plan9 => return @fieldParentPtr(Plan9, "base", base).flushModule(comp), | ||
| 441 | } | 456 | } |
| 442 | } | 457 | } |
| 443 | 458 | ||
| ... | @@ -451,6 +466,7 @@ pub const File = struct { | ... | @@ -451,6 +466,7 @@ pub const File = struct { |
| 451 | .c => @fieldParentPtr(C, "base", base).freeDecl(decl), | 466 | .c => @fieldParentPtr(C, "base", base).freeDecl(decl), |
| 452 | .wasm => @fieldParentPtr(Wasm, "base", base).freeDecl(decl), | 467 | .wasm => @fieldParentPtr(Wasm, "base", base).freeDecl(decl), |
| 453 | .spirv => @fieldParentPtr(SpirV, "base", base).freeDecl(decl), | 468 | .spirv => @fieldParentPtr(SpirV, "base", base).freeDecl(decl), |
| 469 | .plan9 => @fieldParentPtr(Plan9, "base", base).freeDecl(decl), | ||
| 454 | } | 470 | } |
| 455 | } | 471 | } |
| 456 | 472 | ||
| ... | @@ -459,6 +475,7 @@ pub const File = struct { | ... | @@ -459,6 +475,7 @@ pub const File = struct { |
| 459 | .coff => return @fieldParentPtr(Coff, "base", base).error_flags, | 475 | .coff => return @fieldParentPtr(Coff, "base", base).error_flags, |
| 460 | .elf => return @fieldParentPtr(Elf, "base", base).error_flags, | 476 | .elf => return @fieldParentPtr(Elf, "base", base).error_flags, |
| 461 | .macho => return @fieldParentPtr(MachO, "base", base).error_flags, | 477 | .macho => return @fieldParentPtr(MachO, "base", base).error_flags, |
| 478 | .plan9 => return @fieldParentPtr(Plan9, "base", base).error_flags, | ||
| 462 | .c => return .{ .no_entry_point_found = false }, | 479 | .c => return .{ .no_entry_point_found = false }, |
| 463 | .wasm, .spirv => return ErrorFlags{}, | 480 | .wasm, .spirv => return ErrorFlags{}, |
| 464 | } | 481 | } |
| ... | @@ -481,6 +498,7 @@ pub const File = struct { | ... | @@ -481,6 +498,7 @@ pub const File = struct { |
| 481 | .c => return @fieldParentPtr(C, "base", base).updateDeclExports(module, decl, exports), | 498 | .c => return @fieldParentPtr(C, "base", base).updateDeclExports(module, decl, exports), |
| 482 | .wasm => return @fieldParentPtr(Wasm, "base", base).updateDeclExports(module, decl, exports), | 499 | .wasm => return @fieldParentPtr(Wasm, "base", base).updateDeclExports(module, decl, exports), |
| 483 | .spirv => return @fieldParentPtr(SpirV, "base", base).updateDeclExports(module, decl, exports), | 500 | .spirv => return @fieldParentPtr(SpirV, "base", base).updateDeclExports(module, decl, exports), |
| 501 | .plan9 => return @fieldParentPtr(Plan9, "base", base).updateDeclExports(module, decl, exports), | ||
| 484 | } | 502 | } |
| 485 | } | 503 | } |
| 486 | 504 | ||
| ... | @@ -489,6 +507,7 @@ pub const File = struct { | ... | @@ -489,6 +507,7 @@ pub const File = struct { |
| 489 | .coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl), | 507 | .coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl), |
| 490 | .elf => return @fieldParentPtr(Elf, "base", base).getDeclVAddr(decl), | 508 | .elf => return @fieldParentPtr(Elf, "base", base).getDeclVAddr(decl), |
| 491 | .macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl), | 509 | .macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl), |
| 510 | .plan9 => @panic("GET VADDR"), | ||
| 492 | .c => unreachable, | 511 | .c => unreachable, |
| 493 | .wasm => unreachable, | 512 | .wasm => unreachable, |
| 494 | .spirv => unreachable, | 513 | .spirv => unreachable, |
| ... | @@ -633,6 +652,7 @@ pub const File = struct { | ... | @@ -633,6 +652,7 @@ pub const File = struct { |
| 633 | c, | 652 | c, |
| 634 | wasm, | 653 | wasm, |
| 635 | spirv, | 654 | spirv, |
| 655 | plan9, | ||
| 636 | }; | 656 | }; |
| 637 | 657 | ||
| 638 | pub const ErrorFlags = struct { | 658 | pub const ErrorFlags = struct { |
| ... | @@ -641,6 +661,7 @@ pub const File = struct { | ... | @@ -641,6 +661,7 @@ pub const File = struct { |
| 641 | 661 | ||
| 642 | pub const C = @import("link/C.zig"); | 662 | pub const C = @import("link/C.zig"); |
| 643 | pub const Coff = @import("link/Coff.zig"); | 663 | pub const Coff = @import("link/Coff.zig"); |
| 664 | pub const Plan9 = @import("link/Plan9.zig"); | ||
| 644 | pub const Elf = @import("link/Elf.zig"); | 665 | pub const Elf = @import("link/Elf.zig"); |
| 645 | pub const MachO = @import("link/MachO.zig"); | 666 | pub const MachO = @import("link/MachO.zig"); |
| 646 | pub const SpirV = @import("link/SpirV.zig"); | 667 | pub const SpirV = @import("link/SpirV.zig"); |
src/link/Plan9.zig created+65| ... | @@ -0,0 +1,65 @@ | ||
| 1 | const Plan9 = @This(); | ||
| 2 | |||
| 3 | const std = @import("std"); | ||
| 4 | const link = @import("../link.zig"); | ||
| 5 | const Module = @import("../Module.zig"); | ||
| 6 | const Compilation = @import("../Compilation.zig"); | ||
| 7 | const File = link.File; | ||
| 8 | const Allocator = std.mem.Allocator; | ||
| 9 | |||
| 10 | const log = std.log.scoped(.link); | ||
| 11 | |||
| 12 | base: link.File, | ||
| 13 | error_flags: File.ErrorFlags = File.ErrorFlags{}, | ||
| 14 | |||
| 15 | pub const SrcFn = struct { | ||
| 16 | /// Offset from the beginning of the Debug Line Program header that contains this function. | ||
| 17 | off: u32, | ||
| 18 | /// Size of the line number program component belonging to this function, not | ||
| 19 | /// including padding. | ||
| 20 | len: u32, | ||
| 21 | |||
| 22 | /// Points to the previous and next neighbors, based on the offset from .debug_line. | ||
| 23 | /// This can be used to find, for example, the capacity of this `SrcFn`. | ||
| 24 | prev: ?*SrcFn, | ||
| 25 | next: ?*SrcFn, | ||
| 26 | |||
| 27 | pub const empty: SrcFn = .{ | ||
| 28 | .off = 0, | ||
| 29 | .len = 0, | ||
| 30 | .prev = null, | ||
| 31 | .next = null, | ||
| 32 | }; | ||
| 33 | }; | ||
| 34 | |||
| 35 | pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Plan9 { | ||
| 36 | const self = try gpa.create(Plan9); | ||
| 37 | self.* = .{ | ||
| 38 | .base = .{ | ||
| 39 | .tag = .plan9, | ||
| 40 | .options = options, | ||
| 41 | .allocator = gpa, | ||
| 42 | .file = null, | ||
| 43 | }, | ||
| 44 | }; | ||
| 45 | return self; | ||
| 46 | } | ||
| 47 | |||
| 48 | pub fn updateDecl(self: *Plan9, module: *Module, decl: *Module.Decl) !void {} | ||
| 49 | |||
| 50 | pub fn allocateDeclIndexes(self: *Plan9, decl: *Module.Decl) !void {} | ||
| 51 | |||
| 52 | pub fn flush(self: *Plan9, comp: *Compilation) !void {} | ||
| 53 | pub fn flushModule(self: *Plan9, comp: *Compilation) !void {} | ||
| 54 | pub fn freeDecl(self: *Plan9, decl: *Module.Decl) void {} | ||
| 55 | pub fn updateDeclExports( | ||
| 56 | self: *Plan9, | ||
| 57 | module: *Module, | ||
| 58 | decl: *Module.Decl, | ||
| 59 | exports: []const *Module.Export, | ||
| 60 | ) !void {} | ||
| 61 | pub fn deinit(self: *Plan9) void {} | ||
| 62 | |||
| 63 | pub const Export = struct { | ||
| 64 | sym_index: ?u32 = null, | ||
| 65 | }; | ||
src/target.zig+1-1| ... | @@ -244,7 +244,7 @@ pub fn supportsStackProbing(target: std.Target) bool { | ... | @@ -244,7 +244,7 @@ pub fn supportsStackProbing(target: std.Target) bool { |
| 244 | 244 | ||
| 245 | pub fn osToLLVM(os_tag: std.Target.Os.Tag) llvm.OSType { | 245 | pub fn osToLLVM(os_tag: std.Target.Os.Tag) llvm.OSType { |
| 246 | return switch (os_tag) { | 246 | return switch (os_tag) { |
| 247 | .freestanding, .other, .opencl, .glsl450, .vulkan => .UnknownOS, | 247 | .freestanding, .other, .opencl, .glsl450, .vulkan, .plan9 => .UnknownOS, |
| 248 | .windows, .uefi => .Win32, | 248 | .windows, .uefi => .Win32, |
| 249 | .ananas => .Ananas, | 249 | .ananas => .Ananas, |
| 250 | .cloudabi => .CloudABI, | 250 | .cloudabi => .CloudABI, |
src/type.zig+1| ... | @@ -3290,6 +3290,7 @@ pub const CType = enum { | ... | @@ -3290,6 +3290,7 @@ pub const CType = enum { |
| 3290 | .openbsd, | 3290 | .openbsd, |
| 3291 | .wasi, | 3291 | .wasi, |
| 3292 | .emscripten, | 3292 | .emscripten, |
| 3293 | .plan9, | ||
| 3293 | => switch (self) { | 3294 | => switch (self) { |
| 3294 | .short, | 3295 | .short, |
| 3295 | .ushort, | 3296 | .ushort, |