mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
stage1-wasm: implement shared memory
This commit is contained in:
parent
6fdcf1ad2d
commit
b2805666a7
@ -1508,6 +1508,7 @@ pub const LibExeObjStep = struct {
|
||||
export_table: bool = false,
|
||||
initial_memory: ?u64 = null,
|
||||
max_memory: ?u64 = null,
|
||||
shared_memory: bool = false,
|
||||
global_base: ?u64 = null,
|
||||
c_std: Builder.CStd,
|
||||
override_lib_dir: ?[]const u8,
|
||||
@ -2566,6 +2567,9 @@ pub const LibExeObjStep = struct {
|
||||
if (self.max_memory) |max_memory| {
|
||||
try zig_args.append(builder.fmt("--max-memory={d}", .{max_memory}));
|
||||
}
|
||||
if (self.shared_memory) {
|
||||
try zig_args.append("--shared-memory");
|
||||
}
|
||||
if (self.global_base) |global_base| {
|
||||
try zig_args.append(builder.fmt("--global-base={d}", .{global_base}));
|
||||
}
|
||||
|
||||
@ -757,6 +757,7 @@ pub const InitOptions = struct {
|
||||
linker_export_table: bool = false,
|
||||
linker_initial_memory: ?u64 = null,
|
||||
linker_max_memory: ?u64 = null,
|
||||
linker_shared_memory: bool = false,
|
||||
linker_global_base: ?u64 = null,
|
||||
linker_export_symbol_names: []const []const u8 = &.{},
|
||||
each_lib_rpath: ?bool = null,
|
||||
@ -1560,6 +1561,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
|
||||
.export_table = options.linker_export_table,
|
||||
.initial_memory = options.linker_initial_memory,
|
||||
.max_memory = options.linker_max_memory,
|
||||
.shared_memory = options.linker_shared_memory,
|
||||
.global_base = options.linker_global_base,
|
||||
.export_symbol_names = options.linker_export_symbol_names,
|
||||
.z_nodelete = options.linker_z_nodelete,
|
||||
@ -2337,6 +2339,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes
|
||||
man.hash.add(comp.bin_file.options.import_memory);
|
||||
man.hash.addOptional(comp.bin_file.options.initial_memory);
|
||||
man.hash.addOptional(comp.bin_file.options.max_memory);
|
||||
man.hash.add(comp.bin_file.options.shared_memory);
|
||||
man.hash.addOptional(comp.bin_file.options.global_base);
|
||||
|
||||
// Mach-O specific stuff
|
||||
|
||||
@ -125,6 +125,7 @@ pub const Options = struct {
|
||||
export_table: bool,
|
||||
initial_memory: ?u64,
|
||||
max_memory: ?u64,
|
||||
shared_memory: bool,
|
||||
export_symbol_names: []const []const u8,
|
||||
global_base: ?u64,
|
||||
is_native_os: bool,
|
||||
|
||||
@ -1652,6 +1652,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
|
||||
man.hash.add(self.base.options.export_table);
|
||||
man.hash.addOptional(self.base.options.initial_memory);
|
||||
man.hash.addOptional(self.base.options.max_memory);
|
||||
man.hash.add(self.base.options.shared_memory);
|
||||
man.hash.addOptional(self.base.options.global_base);
|
||||
man.hash.add(self.base.options.export_symbol_names.len);
|
||||
// strip does not need to go into the linker hash because it is part of the hash namespace
|
||||
@ -1757,6 +1758,10 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
|
||||
try argv.append(arg);
|
||||
}
|
||||
|
||||
if (self.base.options.shared_memory) {
|
||||
try argv.append("--shared-memory");
|
||||
}
|
||||
|
||||
if (self.base.options.global_base) |global_base| {
|
||||
const arg = try std.fmt.allocPrint(arena, "--global-base={d}", .{global_base});
|
||||
try argv.append(arg);
|
||||
|
||||
@ -438,6 +438,7 @@ const usage_build_generic =
|
||||
\\ --export-table (WebAssembly) export function table to the host environment
|
||||
\\ --initial-memory=[bytes] (WebAssembly) initial size of the linear memory
|
||||
\\ --max-memory=[bytes] (WebAssembly) maximum size of the linear memory
|
||||
\\ --shared-memory (WebAssembly) use shared linear memory
|
||||
\\ --global-base=[addr] (WebAssembly) where to start to place global data
|
||||
\\ --export=[value] (WebAssembly) Force a symbol to be exported
|
||||
\\
|
||||
@ -635,6 +636,7 @@ fn buildOutputType(
|
||||
var linker_export_table: bool = false;
|
||||
var linker_initial_memory: ?u64 = null;
|
||||
var linker_max_memory: ?u64 = null;
|
||||
var linker_shared_memory: bool = false;
|
||||
var linker_global_base: ?u64 = null;
|
||||
var linker_z_nodelete = false;
|
||||
var linker_z_notext = false;
|
||||
@ -1207,6 +1209,8 @@ fn buildOutputType(
|
||||
linker_initial_memory = parseIntSuffix(arg, "--initial-memory=".len);
|
||||
} else if (mem.startsWith(u8, arg, "--max-memory=")) {
|
||||
linker_max_memory = parseIntSuffix(arg, "--max-memory=".len);
|
||||
} else if (mem.startsWith(u8, arg, "--shared-memory")) {
|
||||
linker_shared_memory = true;
|
||||
} else if (mem.startsWith(u8, arg, "--global-base=")) {
|
||||
linker_global_base = parseIntSuffix(arg, "--global-base=".len);
|
||||
} else if (mem.startsWith(u8, arg, "--export=")) {
|
||||
@ -1623,6 +1627,8 @@ fn buildOutputType(
|
||||
linker_initial_memory = parseIntSuffix(arg, "--initial-memory=".len);
|
||||
} else if (mem.startsWith(u8, arg, "--max-memory=")) {
|
||||
linker_max_memory = parseIntSuffix(arg, "--max-memory=".len);
|
||||
} else if (mem.startsWith(u8, arg, "--shared-memory")) {
|
||||
linker_shared_memory = true;
|
||||
} else if (mem.startsWith(u8, arg, "--global-base=")) {
|
||||
linker_global_base = parseIntSuffix(arg, "--global-base=".len);
|
||||
} else if (mem.startsWith(u8, arg, "--export=")) {
|
||||
@ -2620,6 +2626,7 @@ fn buildOutputType(
|
||||
.linker_export_table = linker_export_table,
|
||||
.linker_initial_memory = linker_initial_memory,
|
||||
.linker_max_memory = linker_max_memory,
|
||||
.linker_shared_memory = linker_shared_memory,
|
||||
.linker_global_base = linker_global_base,
|
||||
.linker_export_symbol_names = linker_export_symbol_names.items,
|
||||
.linker_z_nodelete = linker_z_nodelete,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user