Skip to content

Commit

Permalink
Keep asserts on in fuzz-testing builds (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn authored Oct 6, 2024
1 parent b3486bc commit 41a842c
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 251 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
interval: weekly
2 changes: 1 addition & 1 deletion .github/workflows/vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
with:
runVcpkgInstall: true
vcpkgJsonGlob: '**/build/vcpkg.json'
vcpkgGitCommitId: '7516a02de04e8f8ff4e4beb8f5bac0565f9bf9da'
vcpkgGitCommitId: '${{ vars.VCPKG_COMMIT_ID }}'

- name: 'Configure CMake'
working-directory: ${{ github.workspace }}
Expand Down
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,15 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE "/Qspectre")
endif()

if(BUILD_FUZZING
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.32)
AND (NOT WINDOWS_STORE))
target_compile_options(${PROJECT_NAME} PRIVATE ${ASAN_SWITCHES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${ASAN_LIBS})

if(BUILD_FUZZING AND (NOT WINDOWS_STORE))
string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "/DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.32)
target_compile_options(${PROJECT_NAME} PRIVATE ${ASAN_SWITCHES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${ASAN_LIBS})
endif()
endif()
endif()

Expand Down
33 changes: 21 additions & 12 deletions build/DirectXTK12-GitHub-GDK.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=615561
# https://go.microsoft.com/fwlink/?LinkID=615561

# Builds the library and test suite using the Microsoft GDK.

Expand Down Expand Up @@ -52,6 +52,11 @@ resources:
- repository: self
type: git
ref: refs/heads/main
- repository: testRepo
name: walbourn/directxtk12test
type: github
endpoint: microsoft
ref: refs/heads/main

name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

Expand All @@ -63,7 +68,6 @@ variables:
EXTRACTED_FOLDER: $(ExtractedFolder)
GDK_EDITION: $(GDKEditionNumber)
GDKEnableBWOI: true
GITHUB_PAT: $(GITHUBPUBLICTOKEN)
URL_FEED: $(ADOFeedURL)
skipNugetSecurityAnalysis: true # We explicitly call this task so we don't need it to be auto-injected

Expand All @@ -76,6 +80,7 @@ jobs:
- checkout: self
clean: true
fetchTags: false
fetchDepth: 1
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
Expand Down Expand Up @@ -188,12 +193,14 @@ jobs:
- checkout: self
clean: true
fetchTags: false
- task: CmdLine@2
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
inputs:
script: git clone --no-tags --quiet https://%GITHUB_PAT%@github.com/walbourn/directxtk12test.git Tests
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: true
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
Expand Down Expand Up @@ -276,12 +283,14 @@ jobs:
- checkout: self
clean: true
fetchTags: false
- task: CmdLine@2
fetchDepth: 1
path: 's'
- checkout: testRepo
displayName: Fetch Tests
inputs:
script: git clone --quiet https://%GITHUB_PAT%@github.com/walbourn/directxtk12test.git Tests
workingDirectory: $(Build.SourcesDirectory)
failOnStderr: true
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet'
- task: PowerShell@2
Expand Down
129 changes: 57 additions & 72 deletions build/DirectXTK12-GitHub-MinGW.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#
# http://go.microsoft.com/fwlink/?LinkID=615561
# https://go.microsoft.com/fwlink/?LinkID=615561

# Builds the library and test suite using the MinGW compiler.

Expand All @@ -23,7 +23,7 @@ trigger:
- '.github/*'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
Expand All @@ -40,7 +40,7 @@ pr:
- '.github/*'
- '.nuget/*'
- build/*.cmd
- build/*.json
- build/OneFuzz*.json
- build/*.props
- build/*.ps1
- build/*.targets
Expand All @@ -52,6 +52,16 @@ resources:
- repository: self
type: git
ref: refs/heads/main
- repository: vcpkgRepo
name: Microsoft/vcpkg
type: github
endpoint: microsoft
ref: refs/tags/$(VCPKG_TAG)
- repository: testRepo
name: walbourn/directxtk12test
type: github
endpoint: microsoft
ref: refs/heads/main

name: $(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

Expand All @@ -60,9 +70,10 @@ pool:

variables:
Codeql.Enabled: false
DIRECTX_DXC_DIR: '$(VCPKG_ROOT)/installed/x64-mingw-static/tools/directx-dxc'
VCPKG_CMAKE_DIR: '$(VCPKG_ROOT)/scripts/buildsystems/vcpkg.cmake'
GITHUB_PAT: $(GITHUBPUBLICTOKEN)
VCPKG_ROOT: $(Build.SourcesDirectory)/vcpkg
VCPKG_CMAKE_DIR: $(Build.SourcesDirectory)/vcpkg/scripts/buildsystems/vcpkg.cmake
VCPKG_MANIFEST_DIR: $(Build.SourcesDirectory)/build
DIRECTX_DXC_DIR: $(Build.SourcesDirectory)/vcpkg/installed/x64-mingw-static/tools/directx-dxc
WIN11_SDK: '10.0.22000.0'
URL_MINGW32: https://github.com/brechtsanders/winlibs_mingw/releases/download/12.2.0-14.0.6-10.0.0-ucrt-r2/winlibs-i686-posix-dwarf-gcc-12.2.0-llvm-14.0.6-mingw-w64ucrt-10.0.0-r2.zip
HASH_MINGW32: 'fcd1e11b896190da01c83d5b5fb0d37b7c61585e53446c2dab0009debc3915e757213882c35e35396329338de6f0222ba012e23a5af86932db45186a225d1272'
Expand All @@ -74,15 +85,14 @@ jobs:
- checkout: self
clean: true
fetchTags: false
- task: CmdLine@2
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
inputs:
script: git clone --quiet --no-tags https://%GITHUB_PAT%@github.com/microsoft/vcpkg.git
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2
displayName: Fetch Tests
inputs:
script: git clone --quiet --no-tags https://%GITHUB_PAT%@github.com/walbourn/directxtk12test.git Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- task: CmdLine@2
# Note we have to use x64-mingw-static for the host to use the directx-dxc port.
displayName: VCPKG Bootstrap
Expand All @@ -94,7 +104,7 @@ jobs:
workingDirectory: $(Build.SourcesDirectory)\vcpkg
- task: PowerShell@2
displayName: Install MinGW32 and setup for Windows 11 SDK
displayName: Install MinGW32
inputs:
targetType: inline
script: |
Expand All @@ -113,49 +123,30 @@ jobs:
Write-Host "Extracted."
Write-Host "Added to path: $env:BUILD_SOURCESDIRECTORY\gw32\mingw32\bin"
Write-Host "##vso[task.prependpath]$env:BUILD_SOURCESDIRECTORY\gw32\mingw32\bin"
$sdkroot = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows Kits\Installed Roots' | Select-Object -ExpandProperty KitsRoot10
$windows11sdk = "{0}bin\$(WIN11_SDK)\" -f $sdkroot
if (Test-Path "$windows11sdk") {
Write-Host "##vso[task.setvariable variable=WindowsSdkVerBinPath;]$windows11sdk"
}
else {
Write-Error -Message "##[error]Can't find Windows SDK ($(WIN11_SDK))" -ErrorAction Stop
}
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2
displayName: GCC version
inputs:
script: g++ --version
- task: CmdLine@2
displayName: VCPKG install headers
displayName: VCPKG install packages
inputs:
script: |
call vcpkg install directxmath
@if ERRORLEVEL 1 goto error
call vcpkg install directx-headers
@if ERRORLEVEL 1 goto error
call vcpkg install xaudio2redist
@if ERRORLEVEL 1 goto error
call vcpkg install directx-dxc:x64-mingw-static
@if ERRORLEVEL 1 goto error
:finish
@echo --- VCPKG COMPLETE ---
exit /b 0
:error
@echo --- ERROR: VCPKG FAILED ---
exit /b 1
workingDirectory: $(Build.SourcesDirectory)\vcpkg
script: call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x86-mingw-static
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: CMake (MinGW32)
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: -B out -DCMAKE_BUILD_TYPE="Debug" -DDIRECTX_ARCH=x86 -DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)" -DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x86-mingw-static -DVCPKG_HOST_TRIPLET=x64-mingw-static -DBUILD_XAUDIO_REDIST=ON -DDIRECTX_DXC_PATH="$(DIRECTX_DXC_DIR)"
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE="Debug" -DDIRECTX_ARCH=x86 -DBUILD_XAUDIO_REDIST=ON
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)" -DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x86-mingw-static
-DVCPKG_HOST_TRIPLET=x64-mingw-static -DDIRECTX_DXC_PATH="$(DIRECTX_DXC_DIR)"
- task: CMake@1
displayName: CMake (MinGW32) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out

- job: MINGW64_BUILD
Expand All @@ -164,15 +155,20 @@ jobs:
- checkout: self
clean: true
fetchTags: false
- task: CmdLine@2
fetchDepth: 1
path: 's'
- checkout: vcpkgRepo
displayName: Fetch VCPKG
inputs:
script: git clone --quiet --no-tags https://%GITHUB_PAT%@github.com/microsoft/vcpkg.git
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2
clean: true
fetchTags: false
fetchDepth: 1
path: 's/vcpkg'
- checkout: testRepo
displayName: Fetch Tests
inputs:
script: git clone --quiet --no-tags https://%GITHUB_PAT%@github.com/walbourn/directxtk12test.git Tests
clean: true
fetchTags: false
fetchDepth: 1
path: 's/Tests'
- task: CmdLine@2
displayName: VCPKG Bootstrap
inputs:
Expand All @@ -187,32 +183,21 @@ jobs:
inputs:
script: g++ --version
- task: CmdLine@2
displayName: VCPKG install headers
displayName: VCPKG install packages
inputs:
script: |
call vcpkg install directxmath
@if ERRORLEVEL 1 goto error
call vcpkg install directx-headers
@if ERRORLEVEL 1 goto error
call vcpkg install xaudio2redist
@if ERRORLEVEL 1 goto error
call vcpkg install directx-dxc
@if ERRORLEVEL 1 goto error
:finish
@echo --- VCPKG COMPLETE ---
exit /b 0
:error
@echo --- ERROR: VCPKG FAILED ---
exit /b 1
workingDirectory: $(Build.SourcesDirectory)\vcpkg
script: call vcpkg install --x-manifest-root=$(VCPKG_MANIFEST_DIR) --triplet=x64-mingw-static
workingDirectory: $(VCPKG_ROOT)
- task: CMake@1
displayName: CMake (MinGW-W64)
inputs:
cwd: '$(Build.SourcesDirectory)'
cmakeArgs: -B out -DCMAKE_BUILD_TYPE="Debug" -DDIRECTX_ARCH=x64 -DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)" -DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DBUILD_XAUDIO_REDIST=ON -DDIRECTX_DXC_PATH="$(DIRECTX_DXC_DIR)"
cwd: $(Build.SourcesDirectory)
cmakeArgs: >
-B out -DCMAKE_BUILD_TYPE="Debug" -DDIRECTX_ARCH=x64 -DBUILD_XAUDIO_REDIST=ON
-DCMAKE_CXX_COMPILER="g++.exe" -G "MinGW Makefiles"
-DCMAKE_TOOLCHAIN_FILE="$(VCPKG_CMAKE_DIR)" -DVCPKG_MANIFEST_DIR="$(VCPKG_MANIFEST_DIR)" -DVCPKG_TARGET_TRIPLET=x64-mingw-static
-DVCPKG_HOST_TRIPLET=x64-mingw-static -DDIRECTX_DXC_PATH="$(DIRECTX_DXC_DIR)"
- task: CMake@1
displayName: CMake (MinGW-W64) Build
inputs:
cwd: '$(Build.SourcesDirectory)'
cwd: $(Build.SourcesDirectory)
cmakeArgs: --build out
Loading

0 comments on commit 41a842c

Please sign in to comment.