aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorLuuk de Gram <luuk@degram.dev>2022-10-26 14:04:16 +0200
committerGitHub <noreply@github.com>2022-10-26 14:04:16 +0200
commit875e98a57d99c1b6ce8a4a2f9f103b8fe417b8be (patch)
treeb78fd03f9ce225de9c1b88cf0aef59aa1cf6a052 /lib/std
parentd42a719e8f7ba31a9e18d6be9d58691b0b38c69a (diff)
parentc0710b0c42716bb7173b9fcc2785f9bf5175ae0f (diff)
downloadzig-875e98a57d99c1b6ce8a4a2f9f103b8fe417b8be.tar.gz
zig-875e98a57d99c1b6ce8a4a2f9f103b8fe417b8be.zip
Merge pull request #13287 from Luukdegram/wasm-features
wasm-linker: feature compatibility validation
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/build/CheckObjectStep.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/std/build/CheckObjectStep.zig b/lib/std/build/CheckObjectStep.zig
index 315bbd9b03..63b361473b 100644
--- a/lib/std/build/CheckObjectStep.zig
+++ b/lib/std/build/CheckObjectStep.zig
@@ -649,6 +649,8 @@ const WasmDumper = struct {
try parseDumpNames(reader, writer, data);
} else if (mem.eql(u8, name, "producers")) {
try parseDumpProducers(reader, writer, data);
+ } else if (mem.eql(u8, name, "target_features")) {
+ try parseDumpFeatures(reader, writer, data);
}
// TODO: Implement parsing and dumping other custom sections (such as relocations)
},
@@ -902,4 +904,19 @@ const WasmDumper = struct {
}
}
}
+
+ fn parseDumpFeatures(reader: anytype, writer: anytype, data: []const u8) !void {
+ const feature_count = try std.leb.readULEB128(u32, reader);
+ try writer.print("features {d}\n", .{feature_count});
+
+ var index: u32 = 0;
+ while (index < feature_count) : (index += 1) {
+ const prefix_byte = try std.leb.readULEB128(u8, reader);
+ const name_length = try std.leb.readULEB128(u32, reader);
+ const feature_name = data[reader.context.pos..][0..name_length];
+ reader.context.pos += name_length;
+
+ try writer.print("{c} {s}\n", .{ prefix_byte, feature_name });
+ }
+ }
};