Skip to content

Commit

Permalink
add more options in EmLinkStep
Browse files Browse the repository at this point in the history
* add mimalloc support (xpack-ems works)
   note: emmalloc works with betterC/nogc (no support typeinfo size) only.
   ref.: #40
* assert on/off
* offset_converter on/off
  • Loading branch information
kassane committed Jan 14, 2025
1 parent 7b9efc8 commit d420ca1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ pub const EmLinkOptions = struct {
use_webgpu: bool = false,
use_webgl2: bool = false,
use_emmalloc: bool = false,
use_mimalloc: bool = false,
use_assert: bool = false,
use_offset_converter: bool = false,
use_filesystem: bool = true,
use_ubsan: bool = false,
shell_file_path: ?Build.LazyPath,
Expand All @@ -846,7 +849,6 @@ pub fn emLinkStep(b: *Build, options: EmLinkOptions) !*Build.Step.InstallDir {
"-sSTACK_OVERFLOW_CHECK=1",
});
} else {
emcc.addArg("-sASSERTIONS=0");
if (options.optimize == .ReleaseSmall) {
emcc.addArg("-Oz");
} else {
Expand All @@ -859,6 +861,11 @@ pub fn emLinkStep(b: *Build, options: EmLinkOptions) !*Build.Step.InstallDir {
emcc.addArgs(&.{ "--closure", "1" });
}
}
if (options.use_assert) {
emcc.addArg("-sASSERTIONS=1");
} else {
emcc.addArg("-sASSERTIONS=0");
}
if (options.use_webgpu) {
emcc.addArg("-sUSE_WEBGPU=1");
}
Expand All @@ -871,6 +878,12 @@ pub fn emLinkStep(b: *Build, options: EmLinkOptions) !*Build.Step.InstallDir {
if (options.use_emmalloc) {
emcc.addArg("-sMALLOC='emmalloc'");
}
if (options.use_mimalloc) {
emcc.addArg("-sMALLOC='mimalloc'");
}
if (options.use_offset_converter) {
emcc.addArg("-sUSE_OFFSET_CONVERTER");
}
if (options.use_ubsan) {
emcc.addArg("-fsanitize=undefined");
}
Expand Down

0 comments on commit d420ca1

Please sign in to comment.