Skip to content

Commit

Permalink
Enable Windows runs of AddressSanitizer (#95758)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoritzinsky authored Jan 30, 2024
1 parent 027e2a8 commit a258bb9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
34 changes: 34 additions & 0 deletions eng/pipelines/runtime-sanitized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extends:
platforms:
- linux_x64
- osx_x64
- windows_x64
variables:
- name: _nativeSanitizersArg
value: -fsanitize address
Expand Down Expand Up @@ -81,6 +82,38 @@ extends:
scenarios:
- normal

#
# Build the whole product with CoreCLR and run libraries tests with AddressSanitizer
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: Debug
runtimeFlavor: coreclr
platforms:
- windows_x64
variables:
- name: _nativeSanitizersArg
value: -fsanitize address
jobParameters:
testGroup: innerloop
nameSuffix: CoreCLR_LibrariesTests
buildArgs: -s clr+libs+libs.tests -c $(_BuildConfig) -rc Checked $(_nativeSanitizersArg) /p:ArchiveTests=true
timeoutInMinutes: 360
# Hard-code queues here as we don't want to run on pre Win-10 queues
# and we don't want to overcompilcate helix-queues-setup.yml just for this case.
helixQueues:
- Windows.Amd64.Server2022.Open
- Windows.11.Amd64.Client.Open
# extra steps, run tests
postBuildSteps:
- template: /eng/pipelines/libraries/helix.yml
parameters:
creator: dotnet-bot
testRunNamePrefixSuffix: Libraries_$(_BuildConfig)
scenarios:
- normal

#
# NativeAOT release build and smoke tests with AddressSanitizer
#
Expand All @@ -92,6 +125,7 @@ extends:
platforms:
- linux_x64
- osx_x64
- windows_x64
variables:
- name: _nativeSanitizersArg
value: -fsanitize address
Expand Down
4 changes: 4 additions & 0 deletions eng/testing/linker/project.csproj.template
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@

<Import Project="{NativeSanitizersTargets}" />

<ItemGroup>
<Content Include="@(SanitizerRuntimeToCopy->'{SanitizerRuntimeFolder}/%(Identity)')" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion eng/testing/linker/trimmingTests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
.Replace('{MicrosoftNetCoreAppRuntimePackDir}', '$(MicrosoftNetCoreAppRuntimePackDir)')
.Replace('{NativeSanitizersTargets}', '$(RepositoryEngineeringDir)nativeSanitizers.targets')
.Replace('{AppHostSourcePath}', '$(AppHostSourcePath)')
.Replace('{SingleFileHostSourcePath}', '$(SingleFileHostSourcePath)'))"
.Replace('{SingleFileHostSourcePath}', '$(SingleFileHostSourcePath)')
.Replace('{SanitizerRuntimeFolder}', '$(DotNetHostBinDir)'))"
Overwrite="true" />
<Copy SourceFiles="$(_projectSourceFile);
@(_additionalProjectSourceFiles)"
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function(add_pgo TargetName)
endif()
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
endif(CLR_CMAKE_HOST_WIN32)
elseif(CLR_CMAKE_PGO_OPTIMIZE)
elseif(CLR_CMAKE_PGO_OPTIMIZE AND NOT CLR_CMAKE_ENABLE_SANITIZERS)
if(CLR_CMAKE_HOST_WIN32)
set(ProfileFileName "${TargetName}.pgd")
else(CLR_CMAKE_HOST_WIN32)
Expand Down
4 changes: 3 additions & 1 deletion src/tests/readytorun/tests/mainv1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<CrossGenTest>false</CrossGenTest>
<!-- https://github.com/dotnet/runtime/issues/73138 -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
<!-- This test launches crossgen2 with dotnet, so we would need a non-sanitzed jitinterface library. To simplify our infrastructure, we'll instead skip this test. -->
<CLRTestTargetUnsupported Condition="'$(EnableNativeSanitizers)' != ''">true</CLRTestTargetUnsupported>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="fieldgetter.ilproj" />
Expand Down Expand Up @@ -156,7 +158,7 @@ export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
]]></CLRTestBashPreCommands>
</PropertyGroup>

<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build">
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build" Condition="'$(CLRTestTargetUnsupported)' != 'true'">
<PropertyGroup>
<TestAssemblyName>test.dll</TestAssemblyName>
<TestAssemblySourcePath>$(OutputPath)/../testv1/test/</TestAssemblySourcePath>
Expand Down
4 changes: 3 additions & 1 deletion src/tests/readytorun/tests/mainv2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<CrossGenTest>false</CrossGenTest>
<!-- https://github.com/dotnet/runtime/issues/73954 -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
<!-- This test launches crossgen2 with dotnet, so we would need a non-sanitzed jitinterface library. To simplify our infrastructure, we'll instead skip this test. -->
<CLRTestTargetUnsupported Condition="'$(EnableNativeSanitizers)' != ''">true</CLRTestTargetUnsupported>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="fieldgetter.ilproj" />
Expand Down Expand Up @@ -158,7 +160,7 @@ export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
]]></CLRTestBashPreCommands>
</PropertyGroup>

<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build">
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build" Condition="'$(CLRTestTargetUnsupported)' != 'true'">
<PropertyGroup>
<TestAssemblyName>test.dll</TestAssemblyName>
<TestV1AssemblySourcePath>$(OutputPath)/../testv1/test/</TestV1AssemblySourcePath>
Expand Down

0 comments on commit a258bb9

Please sign in to comment.