| author | |
| committer | |
| log | c610cde1eb460ddf80910f34e19c8a68d1bc86a9 |
| tree | 7ddba1eab424cc3c6c26d30d4d73cbb570e7d666 |
| parent | 06af9cc101d0e688f7c6a1c2cc009b917f0a7bdf |
Specifically this is to make sure llvm data layout generation doesn't
regress. The no emit bin is to allow testing targets that can't
currently be linked. The commented out targets are ones that fail in
the linker anyway when no emit bin is passed.7 files changed, 144 insertions(+), 6 deletions(-)
lib/std/Build/Step.zig+3-1| ... | @@ -294,7 +294,7 @@ pub fn evalZigProcess( | ... | @@ -294,7 +294,7 @@ pub fn evalZigProcess( |
| 294 | s: *Step, | 294 | s: *Step, |
| 295 | argv: []const []const u8, | 295 | argv: []const []const u8, |
| 296 | prog_node: *std.Progress.Node, | 296 | prog_node: *std.Progress.Node, |
| 297 | ) ![]const u8 { | 297 | ) !?[]const u8 { |
| 298 | assert(argv.len != 0); | 298 | assert(argv.len != 0); |
| 299 | const b = s.owner; | 299 | const b = s.owner; |
| 300 | const arena = b.allocator; | 300 | const arena = b.allocator; |
| ... | @@ -423,6 +423,8 @@ pub fn evalZigProcess( | ... | @@ -423,6 +423,8 @@ pub fn evalZigProcess( |
| 423 | }); | 423 | }); |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | if (s.cast(Compile)) |compile| if (compile.emit_bin == .no_emit) return result; | ||
| 427 | |||
| 426 | return result orelse return s.fail( | 428 | return result orelse return s.fail( |
| 427 | "the following command failed to communicate the compilation result:\n{s}", | 429 | "the following command failed to communicate the compilation result:\n{s}", |
| 428 | .{try allocPrintCmd(arena, null, argv)}, | 430 | .{try allocPrintCmd(arena, null, argv)}, |
lib/std/Build/Step/Compile.zig+4-3| ... | @@ -1997,7 +1997,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -1997,7 +1997,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1997 | try zig_args.append(resolved_args_file); | 1997 | try zig_args.append(resolved_args_file); |
| 1998 | } | 1998 | } |
| 1999 | 1999 | ||
| 2000 | const output_bin_path = step.evalZigProcess(zig_args.items, prog_node) catch |err| switch (err) { | 2000 | const maybe_output_bin_path = step.evalZigProcess(zig_args.items, prog_node) catch |err| switch (err) { |
| 2001 | error.NeedCompileErrorCheck => { | 2001 | error.NeedCompileErrorCheck => { |
| 2002 | assert(self.expect_errors.len != 0); | 2002 | assert(self.expect_errors.len != 0); |
| 2003 | try checkCompileErrors(self); | 2003 | try checkCompileErrors(self); |
| ... | @@ -2005,10 +2005,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -2005,10 +2005,11 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 2005 | }, | 2005 | }, |
| 2006 | else => |e| return e, | 2006 | else => |e| return e, |
| 2007 | }; | 2007 | }; |
| 2008 | const output_dir = fs.path.dirname(output_bin_path).?; | ||
| 2009 | 2008 | ||
| 2010 | // Update generated files | 2009 | // Update generated files |
| 2011 | { | 2010 | if (maybe_output_bin_path) |output_bin_path| { |
| 2011 | const output_dir = fs.path.dirname(output_bin_path).?; | ||
| 2012 | |||
| 2012 | self.output_dirname_source.path = output_dir; | 2013 | self.output_dirname_source.path = output_dir; |
| 2013 | 2014 | ||
| 2014 | self.output_path_source.path = b.pathJoin( | 2015 | self.output_path_source.path = b.pathJoin( |
lib/std/Build/Step/TranslateC.zig+2-2| ... | @@ -148,8 +148,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -148,8 +148,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 148 | 148 | ||
| 149 | const output_path = try step.evalZigProcess(argv_list.items, prog_node); | 149 | const output_path = try step.evalZigProcess(argv_list.items, prog_node); |
| 150 | 150 | ||
| 151 | self.out_basename = fs.path.basename(output_path); | 151 | self.out_basename = fs.path.basename(output_path.?); |
| 152 | const output_dir = fs.path.dirname(output_path).?; | 152 | const output_dir = fs.path.dirname(output_path.?).?; |
| 153 | 153 | ||
| 154 | self.output_file.path = try fs.path.join( | 154 | self.output_file.path = try fs.path.join( |
| 155 | b.allocator, | 155 | b.allocator, |
src/Compilation.zig+1| ... | @@ -1053,6 +1053,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { | ... | @@ -1053,6 +1053,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1053 | buf.appendSliceAssumeCapacity(","); | 1053 | buf.appendSliceAssumeCapacity(","); |
| 1054 | } | 1054 | } |
| 1055 | } | 1055 | } |
| 1056 | if (buf.items.len == 0) break :blk ""; | ||
| 1056 | assert(mem.endsWith(u8, buf.items, ",")); | 1057 | assert(mem.endsWith(u8, buf.items, ",")); |
| 1057 | buf.items[buf.items.len - 1] = 0; | 1058 | buf.items[buf.items.len - 1] = 0; |
| 1058 | buf.shrinkAndFree(buf.items.len); | 1059 | buf.shrinkAndFree(buf.items.len); |
test/cases.zig+1| ... | @@ -4,5 +4,6 @@ const Cases = @import("src/Cases.zig"); | ... | @@ -4,5 +4,6 @@ const Cases = @import("src/Cases.zig"); |
| 4 | pub fn addCases(cases: *Cases) !void { | 4 | pub fn addCases(cases: *Cases) !void { |
| 5 | try @import("compile_errors.zig").addCases(cases); | 5 | try @import("compile_errors.zig").addCases(cases); |
| 6 | try @import("cbe.zig").addCases(cases); | 6 | try @import("cbe.zig").addCases(cases); |
| 7 | try @import("llvm_targets.zig").addCases(cases); | ||
| 7 | try @import("nvptx.zig").addCases(cases); | 8 | try @import("nvptx.zig").addCases(cases); |
| 8 | } | 9 | } |
test/llvm_targets.zig created+117| ... | @@ -0,0 +1,117 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const Cases = @import("src/Cases.zig"); | ||
| 3 | |||
| 4 | const targets = [_]std.zig.CrossTarget{ | ||
| 5 | .{ .cpu_arch = .aarch64, .os_tag = .freestanding, .abi = .none }, | ||
| 6 | .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .none }, | ||
| 7 | .{ .cpu_arch = .aarch64, .os_tag = .macos, .abi = .none }, | ||
| 8 | .{ .cpu_arch = .aarch64, .os_tag = .uefi, .abi = .none }, | ||
| 9 | .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .gnu }, | ||
| 10 | .{ .cpu_arch = .aarch64, .os_tag = .windows, .abi = .msvc }, | ||
| 11 | .{ .cpu_arch = .aarch64_be, .os_tag = .freestanding, .abi = .none }, | ||
| 12 | .{ .cpu_arch = .aarch64_be, .os_tag = .linux, .abi = .none }, | ||
| 13 | .{ .cpu_arch = .aarch64_32, .os_tag = .freestanding, .abi = .none }, | ||
| 14 | .{ .cpu_arch = .aarch64_32, .os_tag = .linux, .abi = .none }, | ||
| 15 | .{ .cpu_arch = .amdgcn, .os_tag = .amdhsa, .abi = .none }, | ||
| 16 | .{ .cpu_arch = .amdgcn, .os_tag = .amdpal, .abi = .none }, | ||
| 17 | .{ .cpu_arch = .amdgcn, .os_tag = .linux, .abi = .none }, | ||
| 18 | //.{ .cpu_arch = .amdgcn, .os_tag = .mesa3d, .abi = .none }, | ||
| 19 | .{ .cpu_arch = .arm, .os_tag = .freestanding, .abi = .none }, | ||
| 20 | .{ .cpu_arch = .arm, .os_tag = .linux, .abi = .none }, | ||
| 21 | .{ .cpu_arch = .arm, .os_tag = .uefi, .abi = .none }, | ||
| 22 | .{ .cpu_arch = .armeb, .os_tag = .freestanding, .abi = .none }, | ||
| 23 | .{ .cpu_arch = .armeb, .os_tag = .linux, .abi = .none }, | ||
| 24 | .{ .cpu_arch = .avr, .os_tag = .freebsd, .abi = .none }, | ||
| 25 | .{ .cpu_arch = .avr, .os_tag = .freestanding, .abi = .none }, | ||
| 26 | .{ .cpu_arch = .avr, .os_tag = .linux, .abi = .none }, | ||
| 27 | .{ .cpu_arch = .bpfel, .os_tag = .linux, .abi = .gnu }, | ||
| 28 | .{ .cpu_arch = .bpfel, .os_tag = .linux, .abi = .none }, | ||
| 29 | .{ .cpu_arch = .bpfeb, .os_tag = .linux, .abi = .gnu }, | ||
| 30 | .{ .cpu_arch = .bpfeb, .os_tag = .linux, .abi = .none }, | ||
| 31 | .{ .cpu_arch = .hexagon, .os_tag = .linux, .abi = .none }, | ||
| 32 | .{ .cpu_arch = .mips, .os_tag = .linux, .abi = .gnueabihf }, | ||
| 33 | .{ .cpu_arch = .mips, .os_tag = .linux, .abi = .musl }, | ||
| 34 | .{ .cpu_arch = .mips, .os_tag = .linux, .abi = .none }, | ||
| 35 | .{ .cpu_arch = .mipsel, .os_tag = .linux, .abi = .gnueabihf }, | ||
| 36 | .{ .cpu_arch = .mipsel, .os_tag = .linux, .abi = .musl }, | ||
| 37 | .{ .cpu_arch = .mipsel, .os_tag = .linux, .abi = .none }, | ||
| 38 | .{ .cpu_arch = .mips64, .os_tag = .linux, .abi = .none }, | ||
| 39 | .{ .cpu_arch = .mips64el, .os_tag = .linux, .abi = .none }, | ||
| 40 | .{ .cpu_arch = .msp430, .os_tag = .freebsd, .abi = .none }, | ||
| 41 | .{ .cpu_arch = .msp430, .os_tag = .freestanding, .abi = .none }, | ||
| 42 | .{ .cpu_arch = .msp430, .os_tag = .linux, .abi = .none }, | ||
| 43 | //.{ .cpu_arch = .nvptx, .os_tag = .cuda, .abi = .none }, | ||
| 44 | //.{ .cpu_arch = .nvptx64, .os_tag = .cuda, .abi = .none }, | ||
| 45 | .{ .cpu_arch = .powerpc, .os_tag = .freebsd, .abi = .none }, | ||
| 46 | .{ .cpu_arch = .powerpc, .os_tag = .freestanding, .abi = .none }, | ||
| 47 | .{ .cpu_arch = .powerpc, .os_tag = .linux, .abi = .gnueabihf }, | ||
| 48 | .{ .cpu_arch = .powerpc, .os_tag = .linux, .abi = .musl }, | ||
| 49 | .{ .cpu_arch = .powerpc, .os_tag = .linux, .abi = .none }, | ||
| 50 | .{ .cpu_arch = .powerpcle, .os_tag = .freebsd, .abi = .none }, | ||
| 51 | .{ .cpu_arch = .powerpcle, .os_tag = .freestanding, .abi = .none }, | ||
| 52 | .{ .cpu_arch = .powerpcle, .os_tag = .linux, .abi = .gnu }, | ||
| 53 | .{ .cpu_arch = .powerpcle, .os_tag = .linux, .abi = .musl }, | ||
| 54 | .{ .cpu_arch = .powerpcle, .os_tag = .linux, .abi = .none }, | ||
| 55 | .{ .cpu_arch = .powerpc64, .os_tag = .freebsd, .abi = .none }, | ||
| 56 | .{ .cpu_arch = .powerpc64, .os_tag = .freestanding, .abi = .none }, | ||
| 57 | .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .gnu }, | ||
| 58 | .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .musl }, | ||
| 59 | .{ .cpu_arch = .powerpc64, .os_tag = .linux, .abi = .none }, | ||
| 60 | .{ .cpu_arch = .powerpc64le, .os_tag = .freebsd, .abi = .none }, | ||
| 61 | .{ .cpu_arch = .powerpc64le, .os_tag = .freestanding, .abi = .none }, | ||
| 62 | .{ .cpu_arch = .powerpc64le, .os_tag = .linux, .abi = .gnu }, | ||
| 63 | .{ .cpu_arch = .powerpc64le, .os_tag = .linux, .abi = .musl }, | ||
| 64 | .{ .cpu_arch = .powerpc64le, .os_tag = .linux, .abi = .none }, | ||
| 65 | //.{ .cpu_arch = .r600, .os_tag = .mesa3d, .abi = .none }, | ||
| 66 | .{ .cpu_arch = .riscv32, .os_tag = .freestanding, .abi = .none }, | ||
| 67 | .{ .cpu_arch = .riscv32, .os_tag = .linux, .abi = .none }, | ||
| 68 | .{ .cpu_arch = .riscv64, .os_tag = .freestanding, .abi = .none }, | ||
| 69 | .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .gnu }, | ||
| 70 | .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .musl }, | ||
| 71 | .{ .cpu_arch = .riscv64, .os_tag = .linux, .abi = .none }, | ||
| 72 | .{ .cpu_arch = .s390x, .os_tag = .freestanding, .abi = .none }, | ||
| 73 | .{ .cpu_arch = .s390x, .os_tag = .linux, .abi = .gnu }, | ||
| 74 | .{ .cpu_arch = .sparc, .os_tag = .freestanding, .abi = .none }, | ||
| 75 | .{ .cpu_arch = .sparc, .os_tag = .linux, .abi = .gnu }, | ||
| 76 | .{ .cpu_arch = .sparc, .os_tag = .linux, .abi = .none }, | ||
| 77 | .{ .cpu_arch = .sparcel, .os_tag = .freestanding, .abi = .none }, | ||
| 78 | .{ .cpu_arch = .sparcel, .os_tag = .linux, .abi = .gnu }, | ||
| 79 | .{ .cpu_arch = .sparc64, .os_tag = .freestanding, .abi = .none }, | ||
| 80 | .{ .cpu_arch = .sparc64, .os_tag = .linux, .abi = .gnu }, | ||
| 81 | //.{ .cpu_arch = .spirv32, .os_tag = .opencl, .abi = .none }, | ||
| 82 | //.{ .cpu_arch = .spirv32, .os_tag = .glsl450, .abi = .none }, | ||
| 83 | //.{ .cpu_arch = .spirv32, .os_tag = .vulkan, .abi = .none }, | ||
| 84 | //.{ .cpu_arch = .spirv64, .os_tag = .opencl, .abi = .none }, | ||
| 85 | //.{ .cpu_arch = .spirv64, .os_tag = .glsl450, .abi = .none }, | ||
| 86 | //.{ .cpu_arch = .spirv64, .os_tag = .vulkan, .abi = .none }, | ||
| 87 | .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .none }, | ||
| 88 | .{ .cpu_arch = .thumbeb, .os_tag = .freestanding, .abi = .none }, | ||
| 89 | .{ .cpu_arch = .ve, .os_tag = .linux, .abi = .none }, | ||
| 90 | .{ .cpu_arch = .wasm32, .os_tag = .emscripten, .abi = .none }, | ||
| 91 | .{ .cpu_arch = .wasm32, .os_tag = .freestanding, .abi = .none }, | ||
| 92 | .{ .cpu_arch = .wasm32, .os_tag = .linux, .abi = .none }, | ||
| 93 | .{ .cpu_arch = .wasm32, .os_tag = .wasi, .abi = .none }, | ||
| 94 | .{ .cpu_arch = .wasm64, .os_tag = .emscripten, .abi = .none }, | ||
| 95 | .{ .cpu_arch = .wasm64, .os_tag = .freestanding, .abi = .none }, | ||
| 96 | .{ .cpu_arch = .wasm64, .os_tag = .linux, .abi = .none }, | ||
| 97 | .{ .cpu_arch = .wasm64, .os_tag = .wasi, .abi = .none }, | ||
| 98 | .{ .cpu_arch = .x86, .os_tag = .freestanding, .abi = .none }, | ||
| 99 | .{ .cpu_arch = .x86, .os_tag = .linux, .abi = .none }, | ||
| 100 | .{ .cpu_arch = .x86, .os_tag = .uefi, .abi = .none }, | ||
| 101 | .{ .cpu_arch = .x86, .os_tag = .windows, .abi = .gnu }, | ||
| 102 | .{ .cpu_arch = .x86, .os_tag = .windows, .abi = .msvc }, | ||
| 103 | .{ .cpu_arch = .x86_64, .os_tag = .freebsd, .abi = .none }, | ||
| 104 | .{ .cpu_arch = .x86_64, .os_tag = .freestanding, .abi = .none }, | ||
| 105 | .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .none }, | ||
| 106 | .{ .cpu_arch = .x86_64, .os_tag = .macos, .abi = .none }, | ||
| 107 | .{ .cpu_arch = .x86_64, .os_tag = .uefi, .abi = .none }, | ||
| 108 | .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu }, | ||
| 109 | .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .msvc }, | ||
| 110 | }; | ||
| 111 | |||
| 112 | pub fn addCases(ctx: *Cases) !void { | ||
| 113 | for (targets) |target| { | ||
| 114 | var case = ctx.noEmitUsingLlvmBackend("llvm_targets", target); | ||
| 115 | case.addCompile(""); | ||
| 116 | } | ||
| 117 | } | ||
test/src/Cases.zig+16| ... | @@ -76,6 +76,7 @@ pub const Case = struct { | ... | @@ -76,6 +76,7 @@ pub const Case = struct { |
| 76 | output_mode: std.builtin.OutputMode, | 76 | output_mode: std.builtin.OutputMode, |
| 77 | optimize_mode: std.builtin.Mode = .Debug, | 77 | optimize_mode: std.builtin.Mode = .Debug, |
| 78 | updates: std.ArrayList(Update), | 78 | updates: std.ArrayList(Update), |
| 79 | emit_bin: bool = true, | ||
| 79 | emit_h: bool = false, | 80 | emit_h: bool = false, |
| 80 | is_test: bool = false, | 81 | is_test: bool = false, |
| 81 | expect_exact: bool = false, | 82 | expect_exact: bool = false, |
| ... | @@ -176,6 +177,19 @@ pub fn exeFromCompiledC(ctx: *Cases, name: []const u8, target: CrossTarget) *Cas | ... | @@ -176,6 +177,19 @@ pub fn exeFromCompiledC(ctx: *Cases, name: []const u8, target: CrossTarget) *Cas |
| 176 | return &ctx.cases.items[ctx.cases.items.len - 1]; | 177 | return &ctx.cases.items[ctx.cases.items.len - 1]; |
| 177 | } | 178 | } |
| 178 | 179 | ||
| 180 | pub fn noEmitUsingLlvmBackend(ctx: *Cases, name: []const u8, target: CrossTarget) *Case { | ||
| 181 | ctx.cases.append(Case{ | ||
| 182 | .name = name, | ||
| 183 | .target = target, | ||
| 184 | .updates = std.ArrayList(Update).init(ctx.cases.allocator), | ||
| 185 | .output_mode = .Obj, | ||
| 186 | .emit_bin = false, | ||
| 187 | .deps = std.ArrayList(DepModule).init(ctx.arena), | ||
| 188 | .backend = .llvm, | ||
| 189 | }) catch @panic("out of memory"); | ||
| 190 | return &ctx.cases.items[ctx.cases.items.len - 1]; | ||
| 191 | } | ||
| 192 | |||
| 179 | /// Adds a test case that uses the LLVM backend to emit an executable. | 193 | /// Adds a test case that uses the LLVM backend to emit an executable. |
| 180 | /// Currently this implies linking libc, because only then we can generate a testable executable. | 194 | /// Currently this implies linking libc, because only then we can generate a testable executable. |
| 181 | pub fn exeUsingLlvmBackend(ctx: *Cases, name: []const u8, target: CrossTarget) *Case { | 195 | pub fn exeUsingLlvmBackend(ctx: *Cases, name: []const u8, target: CrossTarget) *Case { |
| ... | @@ -537,6 +551,8 @@ pub fn lowerToBuildSteps( | ... | @@ -537,6 +551,8 @@ pub fn lowerToBuildSteps( |
| 537 | }), | 551 | }), |
| 538 | }; | 552 | }; |
| 539 | 553 | ||
| 554 | artifact.emit_bin = if (case.emit_bin) .default else .no_emit; | ||
| 555 | |||
| 540 | if (case.link_libc) artifact.linkLibC(); | 556 | if (case.link_libc) artifact.linkLibC(); |
| 541 | 557 | ||
| 542 | switch (case.backend) { | 558 | switch (case.backend) { |