| author | |
| committer | |
| log | 280ced66eb712f5c74835b10fa6ba0bd915ee96b |
| tree | 0ba02dbed0c698345a2cd2341cdbb812886c1e61 |
| parent | 206373ca61ec6803e979aad9491e1da16cbf94b6 |
| signature |
See: https://github.com/WebAssembly/tool-conventions/pull/235
This is not *quite* using the same features as the spec'd lime1 model because
LLVM 19 doesn't have the level of feature granularity that we need for that.
This will be fixed once we upgrade to LLVM 20.
Part of #21818.5 files changed, 34 insertions(+), 13 deletions(-)
build.zig+7-7| ... | @@ -594,15 +594,14 @@ pub fn build(b: *std.Build) !void { | ... | @@ -594,15 +594,14 @@ pub fn build(b: *std.Build) !void { |
| 594 | fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { | 594 | fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { |
| 595 | const semver = try std.SemanticVersion.parse(version); | 595 | const semver = try std.SemanticVersion.parse(version); |
| 596 | 596 | ||
| 597 | var target_query: std.Target.Query = .{ | ||
| 598 | .cpu_arch = .wasm32, | ||
| 599 | .os_tag = .wasi, | ||
| 600 | }; | ||
| 601 | target_query.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory)); | ||
| 602 | |||
| 603 | const exe = addCompilerStep(b, .{ | 597 | const exe = addCompilerStep(b, .{ |
| 604 | .optimize = .ReleaseSmall, | 598 | .optimize = .ReleaseSmall, |
| 605 | .target = b.resolveTargetQuery(target_query), | 599 | .target = b.resolveTargetQuery(std.Target.Query.parse(.{ |
| 600 | .arch_os_abi = "wasm32-wasi", | ||
| 601 | // `extended_const` is not supported by the `wasm-opt` version in CI. | ||
| 602 | // `nontrapping_fptoint` is not supported by `wasm2c`. | ||
| 603 | .cpu_features = "baseline-extended_const-nontrapping_fptoint", | ||
| 604 | }) catch unreachable), | ||
| 606 | }); | 605 | }); |
| 607 | 606 | ||
| 608 | const exe_options = b.addOptions(); | 607 | const exe_options = b.addOptions(); |
| ... | @@ -644,6 +643,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { | ... | @@ -644,6 +643,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { |
| 644 | "wasm-opt", | 643 | "wasm-opt", |
| 645 | "-Oz", | 644 | "-Oz", |
| 646 | "--enable-bulk-memory", | 645 | "--enable-bulk-memory", |
| 646 | "--enable-mutable-globals", | ||
| 647 | "--enable-sign-ext", | 647 | "--enable-sign-ext", |
| 648 | }); | 648 | }); |
| 649 | run_opt.addArtifactArg(exe); | 649 | run_opt.addArtifactArg(exe); |
lib/std/Target.zig+1-1| ... | @@ -2012,7 +2012,7 @@ pub const Cpu = struct { | ... | @@ -2012,7 +2012,7 @@ pub const Cpu = struct { |
| 2012 | else => generic(arch), | 2012 | else => generic(arch), |
| 2013 | }, | 2013 | }, |
| 2014 | .xcore => &xcore.cpu.xs1b_generic, | 2014 | .xcore => &xcore.cpu.xs1b_generic, |
| 2015 | .wasm32, .wasm64 => &wasm.cpu.generic, | 2015 | .wasm32, .wasm64 => &wasm.cpu.lime1, |
| 2016 | 2016 | ||
| 2017 | else => generic(arch), | 2017 | else => generic(arch), |
| 2018 | }; | 2018 | }; |
lib/std/Target/wasm.zig+12| ... | @@ -139,6 +139,18 @@ pub const cpu = struct { | ... | @@ -139,6 +139,18 @@ pub const cpu = struct { |
| 139 | .sign_ext, | 139 | .sign_ext, |
| 140 | }), | 140 | }), |
| 141 | }; | 141 | }; |
| 142 | pub const lime1: CpuModel = .{ | ||
| 143 | .name = "lime1", | ||
| 144 | .llvm_name = null, | ||
| 145 | .features = featureSet(&[_]Feature{ | ||
| 146 | .bulk_memory, | ||
| 147 | .extended_const, | ||
| 148 | .multivalue, | ||
| 149 | .mutable_globals, | ||
| 150 | .nontrapping_fptoint, | ||
| 151 | .sign_ext, | ||
| 152 | }), | ||
| 153 | }; | ||
| 142 | pub const mvp: CpuModel = .{ | 154 | pub const mvp: CpuModel = .{ |
| 143 | .name = "mvp", | 155 | .name = "mvp", |
| 144 | .llvm_name = "mvp", | 156 | .llvm_name = "mvp", |
src/Compilation.zig-5| ... | @@ -4150,14 +4150,9 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye | ... | @@ -4150,14 +4150,9 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 4150 | .os_tag = .freestanding, | 4150 | .os_tag = .freestanding, |
| 4151 | .cpu_features_add = std.Target.wasm.featureSet(&.{ | 4151 | .cpu_features_add = std.Target.wasm.featureSet(&.{ |
| 4152 | .atomics, | 4152 | .atomics, |
| 4153 | .bulk_memory, | ||
| 4154 | // .extended_const, not supported by Safari | 4153 | // .extended_const, not supported by Safari |
| 4155 | .multivalue, | ||
| 4156 | .mutable_globals, | ||
| 4157 | .nontrapping_fptoint, | ||
| 4158 | .reference_types, | 4154 | .reference_types, |
| 4159 | //.relaxed_simd, not supported by Firefox or Safari | 4155 | //.relaxed_simd, not supported by Firefox or Safari |
| 4160 | .sign_ext, | ||
| 4161 | // observed to cause Error occured during wast conversion : | 4156 | // observed to cause Error occured during wast conversion : |
| 4162 | // Unknown operator: 0xfd058 in Firefox 117 | 4157 | // Unknown operator: 0xfd058 in Firefox 117 |
| 4163 | //.simd128, | 4158 | //.simd128, |
tools/update_cpu_features.zig+14| ... | @@ -1033,6 +1033,20 @@ const llvm_targets = [_]LlvmTarget{ | ... | @@ -1033,6 +1033,20 @@ const llvm_targets = [_]LlvmTarget{ |
| 1033 | .zig_name = "wasm", | 1033 | .zig_name = "wasm", |
| 1034 | .llvm_name = "WebAssembly", | 1034 | .llvm_name = "WebAssembly", |
| 1035 | .td_name = "WebAssembly.td", | 1035 | .td_name = "WebAssembly.td", |
| 1036 | .extra_cpus = &.{ | ||
| 1037 | .{ | ||
| 1038 | .llvm_name = null, | ||
| 1039 | .zig_name = "lime1", | ||
| 1040 | .features = &.{ | ||
| 1041 | "bulk_memory", | ||
| 1042 | "extended_const", | ||
| 1043 | "multivalue", | ||
| 1044 | "mutable_globals", | ||
| 1045 | "nontrapping_fptoint", | ||
| 1046 | "sign_ext", | ||
| 1047 | }, | ||
| 1048 | }, | ||
| 1049 | }, | ||
| 1036 | }, | 1050 | }, |
| 1037 | .{ | 1051 | .{ |
| 1038 | .zig_name = "x86", | 1052 | .zig_name = "x86", |