Rowan Hart 0b25d723c0
Windows Support for LibAFL-LibFuzzer (#3130)
* Add windows build script and additional changes to support windows for libafl-libfuzzer

* Update build scripts and harness wrapping directives

* Resolve issue with corpus edge count calculation

* Add help message and make fork do nothing on Windows

* Format harness_wrap.cpp

* Clippy happiness pass

* Clippy happiness pass

* Clippy happiness pass

* Correct logic

* Correct logic

* Update help output and make runs argument work

* Add test for libafl_libfuzzer on windows

* Add workflow for libafl_libfuzzer test

* Fix copy without dependent task

* Add libafl_libfuzzer_windows to preflight list

* Format harness

* Explicitly ignore windows fuzzer

* Remove windows-specific copy from unix instructions

* Ensure using nightly

* Fix job name

* Update build to use libFuzzer.lib on Windows to keep consistent with Linux

* Remove nightly requirement

---------

Co-authored-by: Rowan Hart <rowanhart@microsoft.com>
2025-05-21 01:35:48 +02:00

46 lines
1.2 KiB
PowerShell

#!/usr/bin/env pwsh
$ErrorActionPreference = "Stop"
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $SCRIPT_DIR
if ($args.Count -eq 0) {
$profile = "release"
} else {
$profile = $args[0]
}
Write-Host "Building libafl_libfuzzer runtime with profile '$profile'" -ForegroundColor Green
Invoke-Expression "cargo build --profile $profile"
$tmpdir = Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tmpdir | Out-Null
function Cleanup {
if (Test-Path $tmpdir) {
Remove-Item -Recurse -Force $tmpdir
}
}
try {
if ($profile -eq "dev") {
# Set the profile to debug for dev builds, because the path isn't the same
# as the profile name
$profile = "debug"
}
$targetPath = Join-Path $SCRIPT_DIR "target\$profile\afl_libfuzzer_runtime.lib"
$outputPath = Join-Path $SCRIPT_DIR "libFuzzer.lib"
Copy-Item -Path $targetPath -Destination $outputPath -Force | Out-Null
if ($LASTEXITCODE -ne 0) {
throw "Failed to copy final library"
}
Write-Host "Done! Wrote the runtime to '$outputPath'" -ForegroundColor Green
} finally {
Cleanup
}