Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions eng/native/ijw/IJW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ if (CLR_CMAKE_HOST_WIN32)
set_target_properties(${targetName} PROPERTIES COMPILE_OPTIONS "${compileOptions}")
endfunction()

function(disable_optimizations_for_directory)
# Some IJW tests need to emit fully unoptimized IL
# for us to validate basic JIT behavior.
# MSVC doesn't respect #pragma optimize("", off) for C++/CLI
# so we need to replace the existing optimization settings with /Od.
# We can't just append /Od otherwise we get warnings like the following:
# 'D9025: overriding /O2 with /Od'
get_directory_property(dirCompileOptions COMPILE_OPTIONS)
list(FILTER dirCompileOptions EXCLUDE REGEX "/O[2xd]>?$")
set_directory_properties(PROPERTIES COMPILE_OPTIONS "${dirCompileOptions}")
add_compile_options(/Od)
endfunction()

function(add_ijw_msbuild_project_properties targetName ijwhost_target)
# When we're building with MSBuild, we need to set some project properties
# in case CMake has decided to use the SDK support.
Expand Down
12 changes: 12 additions & 0 deletions src/tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@
<AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
</PropertyGroup>

<Target Name="CopyInteropNativeRuntimeDependencies"
BeforeTargets="CopyAllNativeProjectReferenceBinaries"
Condition="'$(TargetsWindows)' == 'true' And ('$(Configuration)' == 'Debug' Or '$(Configuration)' == 'Checked') And '$(CopyDebugCRTDllsToOutputDirectory)' == 'true'" >
<Warning Text="Building C++/CLI tests requires a Visual Studio Dev Command Prompt" Condition="'$(VCToolsRedistDir)' == '' or '$(ExtensionSdkDir)' == ''" />
<ItemGroup Condition="'$(VCToolsRedistDir)' != '' and '$(ExtensionSdkDir)' != ''">
<InteropNativeRuntimeDependencies Include="$(VCToolsRedistDir)onecore/debug_nonredist/$(TargetArchitecture)/Microsoft.VC*.DebugCRT/vcruntime*d.dll" />
<InteropNativeRuntimeDependencies Include="$(VCToolsRedistDir)onecore/debug_nonredist/$(TargetArchitecture)/Microsoft.VC*.DebugCRT/msvcp*d.dll" />
<InteropNativeRuntimeDependencies Include="$(ExtensionSdkDir)/Microsoft.UniversalCRT.Debug/$(UCRTVersion)/Redist/Debug/$(TargetArchitecture)/ucrtbased.dll" />
</ItemGroup>
<Copy SourceFiles="@(InteropNativeRuntimeDependencies)" DestinationFolder="$(OutputPath)" />
</Target>

<!-- Project language -->
<!-- TODO: This might just be the Language property -->
<PropertyGroup Condition="'$(ProjectLanguage)' == ''">
Expand Down
4 changes: 4 additions & 0 deletions src/tests/Interop/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<InteropCommonDir>$(MSBuildThisFileDirectory)common/</InteropCommonDir>
</PropertyGroup>

<ItemGroup Condition="'$(IgnoreCoreCLRTestLibraryDependency)' != 'true'">
<ProjectReference Include="$(TestLibraryProjectPath)" />
Comment thread
jkoritzinsky marked this conversation as resolved.
</ItemGroup>
</Project>
23 changes: 0 additions & 23 deletions src/tests/Interop/Directory.Build.targets

This file was deleted.

4 changes: 2 additions & 2 deletions src/tests/JIT/Directed/Directed_ro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@
<MergedWrapperProjectReference Include="throwbox\filter.ilproj" />
<MergedWrapperProjectReference Include="throwbox\finally.ilproj" />
<MergedWrapperProjectReference Include="throwbox\rethrow.ilproj" />
<MergedWrapperProjectReference Include="tls\mutualrecurthd-tls.ilproj" />
<MergedWrapperProjectReference Include="tls\MutualRecurThd-TLS.csproj" />
<MergedWrapperProjectReference Include="tls\StaticTlsResolver.csproj" />
<MergedWrapperProjectReference Include="tls\test-tls.ilproj" />
<MergedWrapperProjectReference Include="tls\Test-TLS.csproj" />
<MergedWrapperProjectReference Include="tls\TestTLSWithLoadedDlls.csproj" />
<MergedWrapperProjectReference Include="UnrollLoop\loop2_cs_ro.csproj" />
<MergedWrapperProjectReference Include="zeroinit\Dev10_863995.ilproj" />
Expand Down
8 changes: 8 additions & 0 deletions src/tests/JIT/Directed/tls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ add_library(usetls ${TEST_LIB_TYPE} testtls.cpp)

install (TARGETS usetls DESTINATION bin)

if(CLR_CMAKE_HOST_WIN32)
add_subdirectory(cppcli)
endif()

if(CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
add_definitions(-mtls-dialect=desc)
endif()

if(CLR_CMAKE_HOST_WIN32)
add_subdirectory(cppcli-mutual)
endif()
31 changes: 31 additions & 0 deletions src/tests/JIT/Directed/tls/MutualRecurThd-TLS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;
using System.Threading;
using Xunit;

public class MutualRecurThdTLS
{
[SkipOnCoreClr("https://github.com/dotnet/runtime/issues/133538", RuntimeConfiguration.Checked)]
[Fact]
public static void TestEntryPoint()
{
Thread[] threads = new Thread[10];

for (int i = 0; i < threads.Length; i++)
{
threads[i] = new Thread(() => CallRun(null));
threads[i].Start();
}

foreach (Thread thread in threads)
{
thread.Join();
}

}

[UnsafeAccessor(UnsafeAccessorKind.StaticMethod, Name = "Run")]
extern static void CallRun([UnsafeAccessorType("Thread_EA, MutualRecurThdTLSNative")] object? a);
}
23 changes: 23 additions & 0 deletions src/tests/JIT/Directed/tls/MutualRecurThd-TLS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<CLRTestPriority>1</CLRTestPriority>
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<NativeAotIncompatible>true</NativeAotIncompatible>
<CLRTestTargetUnsupported Condition="'$(TargetsWindows)' != 'true'">true</CLRTestTargetUnsupported>
<CopyDebugCRTDllsToOutputDirectory>true</CopyDebugCRTDllsToOutputDirectory>
<!-- Loading IJW assemblies into an unloadable context is not allowed -->
<UnloadabilityIncompatible>true</UnloadabilityIncompatible>
<!-- IJW assemblies contain native code that cannot be round-tripped through ilasm -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
</PropertyGroup>
<PropertyGroup>
<DebugType>PdbOnly</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="MutualRecurThd-TLS.cs" />
<CMakeProjectReference Include="CMakeLists.txt" />
<CMakeProjectReference Include="..\..\..\Interop\IJW\ijwhostmock\CMakeLists.txt" />
<ProjectReference Include="$(TestLibraryProjectPath)" />
</ItemGroup>
</Project>
Loading
Loading