I’m trying to use zig as my C project toolchain.
I’m trying to understand the implication of `standardOptimizeOption` on my compiler flags. Is there some documentation about what flags will be set if I compile in “ReleaseSafe“ ?
BTW, any suggestion about how to use the zig toolchain with C is welcome (especially when it comes to sanitizer).
Thanks !
Here’s my build.zig:
const std = @import("std");
pub fn build(b: *std.Build) void {
// define our executable
const exe = b.addExecutable(.{
.name = "main",
.root_module = b.createModule(.{
.target = b.standardTargetOptions(.{}),
.optimize = b.standardOptimizeOption(.{}),
.sanitize_c = .full,
.link_libc = true,
}),
});
exe.addCSourceFiles(.{
.root = b.path("src"),
.files = &.{"main.c"},
.flags = &.{
"-std=c23",
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wconversion",
"-Wsign-conversion",
"-Wshadow",
"-Wundef",
"-Wformat=2",
},
});
// add the `zig build install` i.e. `zig build` command.
b.installArtifact(exe);
// add `zig build run` command.
const run_exe = b.addRunArtifact(exe);
const run_step = b.step("run", "Run the compiled binary");
run_step.dependOn(&run_exe.step);
}