Skip to content

Commit

Permalink
fix zig cc linker flags for Wasm
Browse files Browse the repository at this point in the history
Closes #15258
  • Loading branch information
Luukdegram authored and andrewrk committed Apr 14, 2023
1 parent e089073 commit 61c08d3
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ 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")) {
} else if (mem.eql(u8, arg, "--shared-memory")) {
linker_shared_memory = true;
} else if (mem.startsWith(u8, arg, "--global-base=")) {
linker_global_base = parseIntSuffix(arg, "--global-base=".len);
Expand Down Expand Up @@ -1959,16 +1959,23 @@ fn buildOutputType(
linker_import_table = true;
} else if (mem.eql(u8, arg, "--export-table")) {
linker_export_table = true;
} else if (mem.startsWith(u8, arg, "--initial-memory=")) {
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")) {
} else if (mem.eql(u8, arg, "--initial-memory")) {
const next_arg = linker_args_it.nextOrFatal();
linker_initial_memory = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| {
fatal("unable to parse initial memory size '{s}': {s}", .{ next_arg, @errorName(err) });
};
} else if (mem.eql(u8, arg, "--max-memory")) {
const next_arg = linker_args_it.nextOrFatal();
linker_max_memory = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| {
fatal("unable to parse max memory size '{s}': {s}", .{ next_arg, @errorName(err) });
};
} else if (mem.eql(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=")) {
try linker_export_symbol_names.append(arg["--export=".len..]);
} else if (mem.eql(u8, arg, "--global-base")) {
const next_arg = linker_args_it.nextOrFatal();
linker_global_base = std.fmt.parseUnsigned(u32, eatIntPrefix(next_arg, 16), 16) catch |err| {
fatal("unable to parse global base '{s}': {s}", .{ next_arg, @errorName(err) });
};
} else if (mem.eql(u8, arg, "--export")) {
try linker_export_symbol_names.append(linker_args_it.nextOrFatal());
} else if (mem.eql(u8, arg, "--compress-debug-sections")) {
Expand Down

0 comments on commit 61c08d3

Please sign in to comment.