| author | |
| committer | |
| log | b2805666a7ced0fd11ab7f25f7599d372e766c42 |
| tree | cd0c1ce52ac46860254ec7a4009fcb0ebc27fbba |
| parent | 6fdcf1ad2d860120564f328535903c4c70e30a0d |
5 files changed, 20 insertions(+), 0 deletions(-)
lib/std/build.zig+4| ... | ... | @@ -1508,6 +1508,7 @@ pub const LibExeObjStep = struct { |
| 1508 | 1508 | export_table: bool = false, |
| 1509 | 1509 | initial_memory: ?u64 = null, |
| 1510 | 1510 | max_memory: ?u64 = null, |
| 1511 | shared_memory: bool = false, | |
| 1511 | 1512 | global_base: ?u64 = null, |
| 1512 | 1513 | c_std: Builder.CStd, |
| 1513 | 1514 | override_lib_dir: ?[]const u8, |
| ... | ... | @@ -2566,6 +2567,9 @@ pub const LibExeObjStep = struct { |
| 2566 | 2567 | if (self.max_memory) |max_memory| { |
| 2567 | 2568 | try zig_args.append(builder.fmt("--max-memory={d}", .{max_memory})); |
| 2568 | 2569 | } |
| 2570 | if (self.shared_memory) { | |
| 2571 | try zig_args.append("--shared-memory"); | |
| 2572 | } | |
| 2569 | 2573 | if (self.global_base) |global_base| { |
| 2570 | 2574 | try zig_args.append(builder.fmt("--global-base={d}", .{global_base})); |
| 2571 | 2575 | } |
src/Compilation.zig+3| ... | ... | @@ -757,6 +757,7 @@ pub const InitOptions = struct { |
| 757 | 757 | linker_export_table: bool = false, |
| 758 | 758 | linker_initial_memory: ?u64 = null, |
| 759 | 759 | linker_max_memory: ?u64 = null, |
| 760 | linker_shared_memory: bool = false, | |
| 760 | 761 | linker_global_base: ?u64 = null, |
| 761 | 762 | linker_export_symbol_names: []const []const u8 = &.{}, |
| 762 | 763 | each_lib_rpath: ?bool = null, |
| ... | ... | @@ -1560,6 +1561,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1560 | 1561 | .export_table = options.linker_export_table, |
| 1561 | 1562 | .initial_memory = options.linker_initial_memory, |
| 1562 | 1563 | .max_memory = options.linker_max_memory, |
| 1564 | .shared_memory = options.linker_shared_memory, | |
| 1563 | 1565 | .global_base = options.linker_global_base, |
| 1564 | 1566 | .export_symbol_names = options.linker_export_symbol_names, |
| 1565 | 1567 | .z_nodelete = options.linker_z_nodelete, |
| ... | ... | @@ -2337,6 +2339,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes |
| 2337 | 2339 | man.hash.add(comp.bin_file.options.import_memory); |
| 2338 | 2340 | man.hash.addOptional(comp.bin_file.options.initial_memory); |
| 2339 | 2341 | man.hash.addOptional(comp.bin_file.options.max_memory); |
| 2342 | man.hash.add(comp.bin_file.options.shared_memory); | |
| 2340 | 2343 | man.hash.addOptional(comp.bin_file.options.global_base); |
| 2341 | 2344 | |
| 2342 | 2345 | // Mach-O specific stuff |
src/link.zig+1| ... | ... | @@ -125,6 +125,7 @@ pub const Options = struct { |
| 125 | 125 | export_table: bool, |
| 126 | 126 | initial_memory: ?u64, |
| 127 | 127 | max_memory: ?u64, |
| 128 | shared_memory: bool, | |
| 128 | 129 | export_symbol_names: []const []const u8, |
| 129 | 130 | global_base: ?u64, |
| 130 | 131 | is_native_os: bool, |
src/link/Wasm.zig+5| ... | ... | @@ -1652,6 +1652,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 1652 | 1652 | man.hash.add(self.base.options.export_table); |
| 1653 | 1653 | man.hash.addOptional(self.base.options.initial_memory); |
| 1654 | 1654 | man.hash.addOptional(self.base.options.max_memory); |
| 1655 | man.hash.add(self.base.options.shared_memory); | |
| 1655 | 1656 | man.hash.addOptional(self.base.options.global_base); |
| 1656 | 1657 | man.hash.add(self.base.options.export_symbol_names.len); |
| 1657 | 1658 | // 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 { |
| 1757 | 1758 | try argv.append(arg); |
| 1758 | 1759 | } |
| 1759 | 1760 | |
| 1761 | if (self.base.options.shared_memory) { | |
| 1762 | try argv.append("--shared-memory"); | |
| 1763 | } | |
| 1764 | ||
| 1760 | 1765 | if (self.base.options.global_base) |global_base| { |
| 1761 | 1766 | const arg = try std.fmt.allocPrint(arena, "--global-base={d}", .{global_base}); |
| 1762 | 1767 | try argv.append(arg); |
src/main.zig+7| ... | ... | @@ -438,6 +438,7 @@ const usage_build_generic = |
| 438 | 438 | \\ --export-table (WebAssembly) export function table to the host environment |
| 439 | 439 | \\ --initial-memory=[bytes] (WebAssembly) initial size of the linear memory |
| 440 | 440 | \\ --max-memory=[bytes] (WebAssembly) maximum size of the linear memory |
| 441 | \\ --shared-memory (WebAssembly) use shared linear memory | |
| 441 | 442 | \\ --global-base=[addr] (WebAssembly) where to start to place global data |
| 442 | 443 | \\ --export=[value] (WebAssembly) Force a symbol to be exported |
| 443 | 444 | \\ |
| ... | ... | @@ -635,6 +636,7 @@ fn buildOutputType( |
| 635 | 636 | var linker_export_table: bool = false; |
| 636 | 637 | var linker_initial_memory: ?u64 = null; |
| 637 | 638 | var linker_max_memory: ?u64 = null; |
| 639 | var linker_shared_memory: bool = false; | |
| 638 | 640 | var linker_global_base: ?u64 = null; |
| 639 | 641 | var linker_z_nodelete = false; |
| 640 | 642 | var linker_z_notext = false; |
| ... | ... | @@ -1207,6 +1209,8 @@ fn buildOutputType( |
| 1207 | 1209 | linker_initial_memory = parseIntSuffix(arg, "--initial-memory=".len); |
| 1208 | 1210 | } else if (mem.startsWith(u8, arg, "--max-memory=")) { |
| 1209 | 1211 | linker_max_memory = parseIntSuffix(arg, "--max-memory=".len); |
| 1212 | } else if (mem.startsWith(u8, arg, "--shared-memory")) { | |
| 1213 | linker_shared_memory = true; | |
| 1210 | 1214 | } else if (mem.startsWith(u8, arg, "--global-base=")) { |
| 1211 | 1215 | linker_global_base = parseIntSuffix(arg, "--global-base=".len); |
| 1212 | 1216 | } else if (mem.startsWith(u8, arg, "--export=")) { |
| ... | ... | @@ -1623,6 +1627,8 @@ fn buildOutputType( |
| 1623 | 1627 | linker_initial_memory = parseIntSuffix(arg, "--initial-memory=".len); |
| 1624 | 1628 | } else if (mem.startsWith(u8, arg, "--max-memory=")) { |
| 1625 | 1629 | linker_max_memory = parseIntSuffix(arg, "--max-memory=".len); |
| 1630 | } else if (mem.startsWith(u8, arg, "--shared-memory")) { | |
| 1631 | linker_shared_memory = true; | |
| 1626 | 1632 | } else if (mem.startsWith(u8, arg, "--global-base=")) { |
| 1627 | 1633 | linker_global_base = parseIntSuffix(arg, "--global-base=".len); |
| 1628 | 1634 | } else if (mem.startsWith(u8, arg, "--export=")) { |
| ... | ... | @@ -2620,6 +2626,7 @@ fn buildOutputType( |
| 2620 | 2626 | .linker_export_table = linker_export_table, |
| 2621 | 2627 | .linker_initial_memory = linker_initial_memory, |
| 2622 | 2628 | .linker_max_memory = linker_max_memory, |
| 2629 | .linker_shared_memory = linker_shared_memory, | |
| 2623 | 2630 | .linker_global_base = linker_global_base, |
| 2624 | 2631 | .linker_export_symbol_names = linker_export_symbol_names.items, |
| 2625 | 2632 | .linker_z_nodelete = linker_z_nodelete, |