allyourcodebase / AFLplusplus

Zig build for AFL++
MIT License
5 stars 0 forks source link

Problem relative to heavy use of b.run() #2

Closed kristoff-it closed 3 months ago

kristoff-it commented 3 months ago

As the build script currently works, it calls b.run("llvm-config" , ...) a bunch of times as part of the build setup process.

Unfortunately this means that any project that depends on this build script, even indirectly, will fail to build if llvm-config is not found. This will happen even if the build step selected has nothing to do with fuzzing because b.run is not b.addSystemCommand.

See my CI for example, where zig build test fails even though I don't try to build any instrumented executable: https://github.com/kristoff-it/superhtml/actions/runs/10063015979/job/27816833324

One solution would be to turn all usage of b.run into usage of addSystemCommand. It's a bit of work, but unfortunately I can't think of a better option.

Pinging @marler8997 in case he has ideas to share.

tensorush commented 3 months ago

I agree, but don't know how to get the string output of b.addSystemCommand to operate on, i.e. parse and b.fmt it into some other string. There's the option to captureStdOut, but that would return a LazyPath.

tensorush commented 3 months ago

Is there a way to get which build step the user specifies? We could just branch out of doing any LLVM stuff when the user specifies some non-LLVM step.

kristoff-it commented 3 months ago

I'm chatting with the core team they're recommending a better approach, I'll be able to PR this myself

kristoff-it commented 3 months ago

@tensorush if you look at my commit from today you will see that I implemented a fix to this problem by conditionally wiring a fail step to replace a bunch of logic that depends on llvm-config. Fail step was introduced in 0.14 and I backported it so that we can use this script also from 0.13.0