Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,31 @@ pub fn activateEmsdkStep(b: *std.Build) *std.Build.Step {

pub const EmccFlags = std.StringHashMap(void);

pub fn emccDefaultFlags(allocator: std.mem.Allocator, optimize: std.builtin.OptimizeMode) EmccFlags {
pub fn emccDefaultFlags(allocator: std.mem.Allocator, options: struct {
optimize: std.builtin.OptimizeMode,
fsanitize: bool,
}) EmccFlags {
var args = EmccFlags.init(allocator);
switch (optimize) {
switch (options.optimize) {
.Debug => {
args.put("-O0", {}) catch unreachable;
args.put("-gsource-map", {}) catch unreachable;
if (options.fsanitize)
args.put("-fsanitize=undefined", {}) catch unreachable;
},
.ReleaseSmall, .ReleaseFast => {
.ReleaseSafe => {
args.put("-O3", {}) catch unreachable;
if (options.fsanitize) {
args.put("-fsanitize=undefined", {}) catch unreachable;
args.put("-fsanitize-minimal-runtime", {}) catch unreachable;
}
},
.ReleaseFast => {
args.put("-O3", {}) catch unreachable;
},
.ReleaseSmall => {
args.put("-Oz", {}) catch unreachable;
},
else => {},
}
return args;
}
Expand Down
Loading