Skip to content

Commit

Permalink
build: don't use the C backend for fuzz builds
Browse files Browse the repository at this point in the history
No longer seems to be necessary
  • Loading branch information
ehaas committed Apr 23, 2024
1 parent 47e12cf commit cc4497e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 95 deletions.
35 changes: 5 additions & 30 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const std = @import("std");
const Build = std.Build;
const GenerateDef = @import("build/GenerateDef.zig");
const ZigLibDirStep = @import("build/ZigLibDir.zig");

const aro_version = std.SemanticVersion{
.major = 0,
Expand All @@ -11,44 +10,20 @@ const aro_version = std.SemanticVersion{

fn addFuzzStep(b: *Build, target: std.Build.ResolvedTarget, afl_clang_lto_path: []const u8, aro_module: *std.Build.Module) !void {
const fuzz_step = b.step("fuzz", "Build executable for fuzz testing.");
const fuzz_target = blk: {
var query = target.query;
query.ofmt = .c;
break :blk b.resolveTargetQuery(query);
};

const lib_dir_step = try ZigLibDirStep.create(b);

const compiler_rt = b.createModule(.{
.root_source_file = lib_dir_step.getCompilerRTPath(),
});
const fuzz_lib = b.addStaticLibrary(.{
.name = "fuzz-lib",
.root_source_file = .{ .path = "test/fuzz/fuzz_lib.zig" },
.optimize = .Debug,
.target = fuzz_target,
.target = target,
.single_threaded = true,
});
fuzz_lib.root_module.addImport("compiler_rt", compiler_rt);
fuzz_lib.want_lto = true;
fuzz_lib.bundle_compiler_rt = true;
fuzz_lib.pie = true;

fuzz_lib.root_module.addImport("aro", aro_module);
const fuzz_compile = b.addSystemCommand(&.{
afl_clang_lto_path,
"-Wno-incompatible-pointer-types",
"-nostdinc",
"-isystem",
});
fuzz_compile.addDirectoryArg(lib_dir_step.getIncludePath());
fuzz_compile.addArgs(&.{
"-isystem",
"/usr/include",
"-isystem",
"/usr/local/include",
"-std=c99",
});
const fuzz_compile = b.addSystemCommand(&.{afl_clang_lto_path});
fuzz_compile.addFileArg(.{ .path = "test/fuzz/main.c" });
fuzz_compile.addArg("-I");
fuzz_compile.addDirectoryArg(lib_dir_step.getLibPath());
fuzz_compile.addArg("-o");
const fuzz_exe = fuzz_compile.addOutputFileArg("arofuzz");
const fuzz_install = b.addInstallBinFile(fuzz_exe, "arofuzz");
Expand Down
65 changes: 0 additions & 65 deletions build/ZigLibDir.zig

This file was deleted.

0 comments on commit cc4497e

Please sign in to comment.