mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std.Target: Define and use lime1 as the baseline CPU model for WebAssembly.
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.
This commit is contained in:
parent
206373ca61
commit
280ced66eb
5 changed files with 34 additions and 13 deletions
14
build.zig
14
build.zig
|
|
@ -594,15 +594,14 @@ pub fn build(b: *std.Build) !void {
|
|||
fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
||||
const semver = try std.SemanticVersion.parse(version);
|
||||
|
||||
var target_query: std.Target.Query = .{
|
||||
.cpu_arch = .wasm32,
|
||||
.os_tag = .wasi,
|
||||
};
|
||||
target_query.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory));
|
||||
|
||||
const exe = addCompilerStep(b, .{
|
||||
.optimize = .ReleaseSmall,
|
||||
.target = b.resolveTargetQuery(target_query),
|
||||
.target = b.resolveTargetQuery(std.Target.Query.parse(.{
|
||||
.arch_os_abi = "wasm32-wasi",
|
||||
// `extended_const` is not supported by the `wasm-opt` version in CI.
|
||||
// `nontrapping_fptoint` is not supported by `wasm2c`.
|
||||
.cpu_features = "baseline-extended_const-nontrapping_fptoint",
|
||||
}) catch unreachable),
|
||||
});
|
||||
|
||||
const exe_options = b.addOptions();
|
||||
|
|
@ -644,6 +643,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
|||
"wasm-opt",
|
||||
"-Oz",
|
||||
"--enable-bulk-memory",
|
||||
"--enable-mutable-globals",
|
||||
"--enable-sign-ext",
|
||||
});
|
||||
run_opt.addArtifactArg(exe);
|
||||
|
|
|
|||
|
|
@ -2012,7 +2012,7 @@ pub const Cpu = struct {
|
|||
else => generic(arch),
|
||||
},
|
||||
.xcore => &xcore.cpu.xs1b_generic,
|
||||
.wasm32, .wasm64 => &wasm.cpu.generic,
|
||||
.wasm32, .wasm64 => &wasm.cpu.lime1,
|
||||
|
||||
else => generic(arch),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -139,6 +139,18 @@ pub const cpu = struct {
|
|||
.sign_ext,
|
||||
}),
|
||||
};
|
||||
pub const lime1: CpuModel = .{
|
||||
.name = "lime1",
|
||||
.llvm_name = null,
|
||||
.features = featureSet(&[_]Feature{
|
||||
.bulk_memory,
|
||||
.extended_const,
|
||||
.multivalue,
|
||||
.mutable_globals,
|
||||
.nontrapping_fptoint,
|
||||
.sign_ext,
|
||||
}),
|
||||
};
|
||||
pub const mvp: CpuModel = .{
|
||||
.name = "mvp",
|
||||
.llvm_name = "mvp",
|
||||
|
|
|
|||
|
|
@ -4150,14 +4150,9 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) anye
|
|||
.os_tag = .freestanding,
|
||||
.cpu_features_add = std.Target.wasm.featureSet(&.{
|
||||
.atomics,
|
||||
.bulk_memory,
|
||||
// .extended_const, not supported by Safari
|
||||
.multivalue,
|
||||
.mutable_globals,
|
||||
.nontrapping_fptoint,
|
||||
.reference_types,
|
||||
//.relaxed_simd, not supported by Firefox or Safari
|
||||
.sign_ext,
|
||||
// observed to cause Error occured during wast conversion :
|
||||
// Unknown operator: 0xfd058 in Firefox 117
|
||||
//.simd128,
|
||||
|
|
|
|||
|
|
@ -1033,6 +1033,20 @@ const llvm_targets = [_]LlvmTarget{
|
|||
.zig_name = "wasm",
|
||||
.llvm_name = "WebAssembly",
|
||||
.td_name = "WebAssembly.td",
|
||||
.extra_cpus = &.{
|
||||
.{
|
||||
.llvm_name = null,
|
||||
.zig_name = "lime1",
|
||||
.features = &.{
|
||||
"bulk_memory",
|
||||
"extended_const",
|
||||
"multivalue",
|
||||
"mutable_globals",
|
||||
"nontrapping_fptoint",
|
||||
"sign_ext",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
.{
|
||||
.zig_name = "x86",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue