diff options
| author | 2024-12-08 12:20:55 +0100 | |
|---|---|---|
| committer | 2024-12-08 12:20:55 +0100 | |
| commit | 00119c76d5f552eb02cbd974849bb34a269001d0 (patch) | |
| tree | 7315c5c26dd08f7d433b15db679645502bdc7745 /build.zig | |
| parent | Merge pull request #170 from vrischmann/ci-ubuntu-2404 (diff) | |
| download | zig-sqlite-00119c76d5f552eb02cbd974849bb34a269001d0.tar.gz zig-sqlite-00119c76d5f552eb02cbd974849bb34a269001d0.tar.xz zig-sqlite-00119c76d5f552eb02cbd974849bb34a269001d0.zip | |
build: remove adhoc fuzzing
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 48 |
1 files changed, 0 insertions, 48 deletions
| @@ -242,8 +242,6 @@ pub fn build(b: *std.Build) !void { | |||
| 242 | test_step.dependOn(&run_tests.step); | 242 | test_step.dependOn(&run_tests.step); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | // Fuzzing | ||
| 246 | |||
| 247 | const lib = b.addStaticLibrary(.{ | 245 | const lib = b.addStaticLibrary(.{ |
| 248 | .name = "sqlite", | 246 | .name = "sqlite", |
| 249 | .target = getTarget(target, true), | 247 | .target = getTarget(target, true), |
| @@ -253,52 +251,6 @@ pub fn build(b: *std.Build) !void { | |||
| 253 | lib.addIncludePath(b.path("c")); | 251 | lib.addIncludePath(b.path("c")); |
| 254 | lib.linkLibC(); | 252 | lib.linkLibC(); |
| 255 | 253 | ||
| 256 | // The library | ||
| 257 | const fuzz_lib = b.addStaticLibrary(.{ | ||
| 258 | .name = "fuzz-lib", | ||
| 259 | .root_source_file = b.path("fuzz/main.zig"), | ||
| 260 | .target = getTarget(target, true), | ||
| 261 | .optimize = optimize, | ||
| 262 | }); | ||
| 263 | fuzz_lib.addIncludePath(b.path("c")); | ||
| 264 | fuzz_lib.linkLibrary(lib); | ||
| 265 | fuzz_lib.want_lto = true; | ||
| 266 | fuzz_lib.bundle_compiler_rt = true; | ||
| 267 | fuzz_lib.root_module.addImport("sqlite", sqlite_mod); | ||
| 268 | |||
| 269 | // Setup the output name | ||
| 270 | const fuzz_executable_name = "fuzz"; | ||
| 271 | const fuzz_exe_path = try b.cache_root.join(b.allocator, &.{fuzz_executable_name}); | ||
| 272 | |||
| 273 | // We want `afl-clang-lto -o path/to/output path/to/library` | ||
| 274 | const fuzz_compile = b.addSystemCommand(&.{ "afl-clang-lto", "-o", fuzz_exe_path }); | ||
| 275 | fuzz_compile.addArtifactArg(lib); | ||
| 276 | fuzz_compile.addArtifactArg(fuzz_lib); | ||
| 277 | |||
| 278 | // Install the cached output to the install 'bin' path | ||
| 279 | const fuzz_install = b.addInstallBinFile(.{ .cwd_relative = fuzz_exe_path }, fuzz_executable_name); | ||
| 280 | |||
| 281 | // Add a top-level step that compiles and installs the fuzz executable | ||
| 282 | const fuzz_compile_run = b.step("fuzz", "Build executable for fuzz testing using afl-clang-lto"); | ||
| 283 | // fuzz_compile_run.dependOn(&fuzz_lib.step); | ||
| 284 | fuzz_compile_run.dependOn(&fuzz_compile.step); | ||
| 285 | fuzz_compile_run.dependOn(&fuzz_install.step); | ||
| 286 | |||
| 287 | // Compile a companion exe for debugging crashes | ||
| 288 | const fuzz_debug_exe = b.addExecutable(.{ | ||
| 289 | .name = "fuzz-debug", | ||
| 290 | .root_source_file = b.path("fuzz/main.zig"), | ||
| 291 | .target = getTarget(target, true), | ||
| 292 | .optimize = optimize, | ||
| 293 | }); | ||
| 294 | fuzz_debug_exe.addIncludePath(b.path("c")); | ||
| 295 | fuzz_debug_exe.linkLibrary(lib); | ||
| 296 | fuzz_debug_exe.root_module.addImport("sqlite", sqlite_mod); | ||
| 297 | |||
| 298 | // Only install fuzz-debug when the fuzz step is run | ||
| 299 | const install_fuzz_debug_exe = b.addInstallArtifact(fuzz_debug_exe, .{}); | ||
| 300 | fuzz_compile_run.dependOn(&install_fuzz_debug_exe.step); | ||
| 301 | |||
| 302 | // | 254 | // |
| 303 | // Examples | 255 | // Examples |
| 304 | // | 256 | // |