diff --git a/docs/workflow/building/coreclr/nativeaot.md b/docs/workflow/building/coreclr/nativeaot.md index 155ed05186e7b0..78182440736af7 100644 --- a/docs/workflow/building/coreclr/nativeaot.md +++ b/docs/workflow/building/coreclr/nativeaot.md @@ -18,6 +18,8 @@ The AOT compiler typically takes the app, core libraries, and framework librarie The executable looks like a native executable, in the sense that it can be debugged with native debuggers and have full-fidelity access to locals, and stepping information. +The compiler also has a mode where each managed assembly can be compiled into a separate object file. The object files are later linked into a single executable using the platform linker. This mode is mostly used in testing (it's faster to compile this way because we don't need to recompiling the same code from e.g. CoreLib). It's not a shipping configuration and has many problems (requires exactly matching compilation settings, forfeits many optimizations, and has trouble around cross-module generic virtual method implementations). + ## Building - [Install pre-requisites](../../README.md#build-requirements) @@ -65,15 +67,12 @@ To run all the tests that got built, run `src\tests\run.cmd runnativeaottests [D To run an individual test (after it was built), navigate to the `artifacts\tests\coreclr\[Windows|Linux|OSX[.x64.[Debug|Release]\$path_to_test` directory. `$path_to_test` matches the subtree of `src\tests`. You should see a `[.cmd|.sh]` file there. This file is a script that will compile and launch the individual test for you. Before invoking the script, set the following environment variables: -* CORE_ROOT=$repo_root\artifacts\tests\coreclr\[Windows|Linux|OSX[.x64.[Debug|Release]\Tests\Core_Root -* RunNativeAot=1 -* __TestDotNetCmd=$repo_root\dotnet[.cmd|.sh] +* CORE_ROOT=$repo_root\artifacts\tests\coreclr\[Windows|Linux|OSX].x64.[Debug|Release]\Tests\Core_Root +* CLRCustomTestLauncher=$repo_root\src\tests\Common\scripts\nativeaottest[.cmd|.sh] `$repo_root` is the root of your clone of the repo. -By default the test suite will delete the build artifacts (Native AOT images and response files) if the test compiled successfully. If you want to keep these files instead of deleting them after test run, set the following environment variables and make sure you'll have enough disk space (tens of MB per test): - -* CLRTestNoCleanup=1 +Sometimes it's handy to be able to rebuild the managed test manually or run the compilation under a debugger. A response file that was used to invoke the ahead of time compiler can be found in `$repo_root\artifacts\tests\coreclr\obj\[Windows|Linux|OSX].x64.[Debug|Release]\Managed`. For more advanced scenarios, look for at [Building Test Subsets](../../testing/coreclr/windows-test-instructions.md#building-test-subsets) and [Generating Core_Root](../../testing/coreclr/windows-test-instructions.md#generating-core_root) diff --git a/eng/pipelines/coreclr/nativeaot-post-build-steps.yml b/eng/pipelines/coreclr/nativeaot-post-build-steps.yml index 272433f32f3e25..a44c7223039580 100644 --- a/eng/pipelines/coreclr/nativeaot-post-build-steps.yml +++ b/eng/pipelines/coreclr/nativeaot-post-build-steps.yml @@ -16,7 +16,7 @@ steps: # Build coreclr native test output - ${{ if eq(parameters.osGroup, 'windows') }}: - - script: $(Build.SourcesDirectory)/src/tests/build.cmd nativeaot $(buildConfigUpper) ${{ parameters.archType }} ${{ parameters.testFilter }} /p:NativeAotMultimodule=true + - script: $(Build.SourcesDirectory)/src/tests/build.cmd nativeaot $(buildConfigUpper) ${{ parameters.archType }} ${{ parameters.testFilter }} /p:BuildNativeAotFrameworkObjects=true displayName: Build tests - ${{ if ne(parameters.osGroup, 'windows') }}: - script: $(Build.SourcesDirectory)/src/tests/build.sh nativeaot $(buildConfigUpper) ${{ parameters.archType }} '${{ parameters.testFilter }}' @@ -29,7 +29,3 @@ steps: - ${{ if ne(parameters.osGroup, 'windows') }}: - script: $(Build.SourcesDirectory)/src/tests/run.sh --runnativeaottests $(buildConfigUpper) ${{ parameters.archType }} displayName: Run tests in single file mode - - - ${{ if eq(parameters.osGroup, 'windows') }}: - - script: $(Build.SourcesDirectory)/src/tests/run.cmd runnativeaottests nativeaotmultimodule $(buildConfigUpper) ${{ parameters.archType }} - displayName: Run tests in multifile mode diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.props b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.props index 4e8bbecff72873..ab8a85f74668a2 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.props +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.props @@ -36,6 +36,9 @@ The .NET Foundation licenses this file to you under the MIT license. $(CrossCompileArch)-linux-gnu $(CrossCompileArch)-alpine-linux-musl + + $ORIGIN + @executable_path @@ -57,7 +60,7 @@ The .NET Foundation licenses this file to you under the MIT license. - $(IlcFrameworkPath)lib%(Identity).a + $(IlcFrameworkNativePath)lib%(Identity).a @@ -75,8 +78,7 @@ The .NET Foundation licenses this file to you under the MIT license. - - + diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 529de6be54f554..1b1b747d8738f6 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -23,6 +23,8 @@ The .NET Foundation licenses this file to you under the MIT license. $(IlcPath)\tools\ $(IlcPath)\sdk\ $(IlcPath)\framework\ + $(IlcPath)\framework\ + $(IlcFrameworkPath) $(IlcPath)\mibc\ windows OSX @@ -119,7 +121,7 @@ The .NET Foundation licenses this file to you under the MIT license. $(NativeIntermediateOutputPath)\%(Filename).ilc.rsp - $(NativeIntermediateOutputPath)\%(Filename).$(IlcOutputFileExt) + $(NativeIntermediateOutputPath)\%(Filename)$(IlcOutputFileExt) @@ -139,6 +141,7 @@ The .NET Foundation licenses this file to you under the MIT license. $(IlcHostPackagePath)\tools\ $(RuntimePackagePath)\sdk\ $(RuntimePackagePath)\framework\ + $(RuntimePackagePath)\framework\ $(RuntimePackagePath)\mibc\ diff --git a/src/tests/Common/CLRTest.Execute.Bash.targets b/src/tests/Common/CLRTest.Execute.Bash.targets index ac563dff7cfed7..88732593734707 100644 --- a/src/tests/Common/CLRTest.Execute.Bash.targets +++ b/src/tests/Common/CLRTest.Execute.Bash.targets @@ -321,10 +321,6 @@ then else LAUNCHER="$_DebuggerFullPath $_DebuggerArgsSeparator $(CLRTestRunFile)" fi -if [ ! -z "$RunNativeAot" ] -then - LAUNCHER="$_DebuggerFullPath" -fi $(BashIlrtTestLaunchCmds) @@ -340,13 +336,6 @@ CLRTestExitCode=$? if [ ! -z ${RunCrossGen+x} ]%3B then ReleaseLock fi -if [ ! -z "$RunNativeAot" ] -then - if [ -z "$CLRTestNoCleanup" ]; - then - rm -rf native - fi -fi $(BashLinkerTestCleanupCmds) ]]> diff --git a/src/tests/Common/CLRTest.Execute.Batch.targets b/src/tests/Common/CLRTest.Execute.Batch.targets index 584f4d30cfd9b0..387d3785482843 100644 --- a/src/tests/Common/CLRTest.Execute.Batch.targets +++ b/src/tests/Common/CLRTest.Execute.Batch.targets @@ -306,9 +306,6 @@ IF NOT "%CLRCustomTestLauncher%"=="" ( ) ELSE ( set LAUNCHER=%_DebuggerFullPath% $(CLRTestRunFile) ) -IF NOT "%RunNativeAot%"=="" ( - set LAUNCHER=%_DebuggerFullPath% -) $(BatchIlrtTestLaunchCmds) @@ -321,11 +318,6 @@ set CLRTestExitCode=!ERRORLEVEL! if defined RunCrossGen ( call :ReleaseLock ) -if defined RunNativeAot ( - if not defined CLRTestNoCleanup ( - IF EXIST native rmdir /s /q native - ) -) $(BatchLinkerTestCleanupCmds) ]]> diff --git a/src/tests/Common/CLRTest.Execute.targets b/src/tests/Common/CLRTest.Execute.targets index 142133bd6aabe6..3c9ec6b40ec4f3 100644 --- a/src/tests/Common/CLRTest.Execute.targets +++ b/src/tests/Common/CLRTest.Execute.targets @@ -78,7 +78,6 @@ This file contains the logic for providing Execution Script generation. - diff --git a/src/tests/Common/CLRTest.NativeAot.targets b/src/tests/Common/CLRTest.NativeAot.targets deleted file mode 100644 index ca515f126f5280..00000000000000 --- a/src/tests/Common/CLRTest.NativeAot.targets +++ /dev/null @@ -1,194 +0,0 @@ - - - - $(BashScriptSnippetGen);GetNativeAotBashScript - $(BatchScriptSnippetGen);GetNativeAotBatchScript - - - - - - - - - - - - /dev/null - else - cp *.so native/ 2>/dev/null - fi - - ExePath=native/$(MSBuildProjectName) -fi - ]]> - - - $(NativeAotCleanupBashScript);$(BashCLRTestPreCommands);$(NativeAotBashScript) - - - - - - - - - - - - - - - - - - $(NativeAotCleanupBatchScript);$(CLRTestBatchPreCommands);$(NativeAotBatchScript) - - - - - - <_RootEntryAssemblyLine Condition="$(CLRTestFullTrimming) == 'true'"><TrimmerDefaultAction>link</TrimmerDefaultAction> - - <_NativeAotBuildProjectFile> - - - - $(MSBuildProjectName) - $(TargetFramework) - Exe - %24(MSBuildProjectDirectory)\ - %24(MSBuildProjectDirectory)\ - $(TargetArchitecture) - $(Optimize) - true - true - false - false - false - $(OutputRid) - $(_RootEntryAssemblyLine) - - - $(NativeAotProjectLines) - - - - - - -@(RuntimeHostConfigurationOption->' ', '%0A') - - - - - - - - - - - ]]> - - - - - - - - diff --git a/src/tests/Common/Directory.Build.targets b/src/tests/Common/Directory.Build.targets index 35a714d99aa1ac..1e0b3a791d4eed 100644 --- a/src/tests/Common/Directory.Build.targets +++ b/src/tests/Common/Directory.Build.targets @@ -31,7 +31,7 @@ DependsOnTargets="ResolveAssemblyReferences;ResolveRuntimeFilesFromLocalBuild"> - + @@ -171,14 +171,6 @@ - - - - - - - - @@ -196,17 +188,6 @@ - - - - diff --git a/src/tests/Common/scripts/nativeaottest.cmd b/src/tests/Common/scripts/nativeaottest.cmd new file mode 100644 index 00000000000000..f189082edc6773 --- /dev/null +++ b/src/tests/Common/scripts/nativeaottest.cmd @@ -0,0 +1,15 @@ +@rem This script is a bridge that allows running NativeAOT compiled executables instead of using corerun. +@rem +@rem To use this script, set the CLRCustomTestLauncher environment variable to the full path of this script. +@rem +@rem The .cmd files of the individual tests will call this script to launch the test. +@rem This script gets the following arguments +@rem 1. Full path to the directory of the test binaries (the test .cmd file is in there) +@rem 2. Filename of the test executable +@rem 3. - n. Additional arguments that were passed to the test .cmd + +@rem File name of the test executable is the original assembly, so swap .dll for .exe +set __ExeFileName=%2 +set __ExeFileName=%__ExeFileName:~0,-4%.exe + +%_DebuggerFullPath% %1\native\%__ExeFileName% %3 %4 %5 %6 %7 %8 %9 diff --git a/src/tests/Common/scripts/nativeaottest.sh b/src/tests/Common/scripts/nativeaottest.sh new file mode 100755 index 00000000000000..c4c38fbd242b96 --- /dev/null +++ b/src/tests/Common/scripts/nativeaottest.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# This script is a bridge that allows running NativeAOT compiled executables instead of using corerun. +# +# To use this script, set the CLRCustomTestLauncher environment variable to the full path of this script. +# +# The .cmd files of the individual tests will call this script to launch the test. +# This script gets the following arguments +# 1. Full path to the directory of the test binaries (the test .sh file is in there) +# 2. Filename of the test executable +# 3. - n. Additional arguments that were passed to the test .sh + +exename=$(basename $2 .dll) +$_DebuggerFullPath $1/native/$exename "${@:3}" diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index 6eda7ef53f14d1..3bede4f5b7ed7e 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -448,4 +448,40 @@ + + + $ORIGIN/.. + @executable_path/.. + + + true + + $(CoreCLRILCompilerDir) + $(CoreCLRILCompilerDir)netstandard/ILCompiler.Build.Tasks.dll + $(CoreCLRAotSdkDir) + $(MicrosoftNetCoreAppRuntimePackRidLibTfmDir) + $(MicrosoftNetCoreAppRuntimePackNativeDir) + $(OutputRid) + + true + true + $(IlcSdkPath) + + + true + false + <_UsingDefaultForHasRuntimeOutput>false + + + + + + + + diff --git a/src/tests/build.proj b/src/tests/build.proj index 66bfd1755ac3ef..d36b022df6497b 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -442,7 +442,7 @@ DependsOnTargets="BuildManagedTestGroups" Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__GenerateLayoutOnly)' != '1' and '$(__SkipManaged)' != '1' and !$(MonoAot) and !$(MonoFullAot)" /> - + @@ -477,6 +477,9 @@ $(GroupBuildCmd) /nodeReuse:false $(GroupBuildCmd) /maxcpucount $(GroupBuildCmd) /bl:$(ArtifactsDir)/log/$(Configuration)/InnerManagedTestBuild.$(__TestGroupToBuild).binlog + $(GroupBuildCmd) "/p:DefaultBuildAllTarget=BuildNativeAot" + $(GroupBuildCmd) "/p:IlcMultiModule=true" + $(GroupBuildCmd) "/p:BuildNativeAotFrameworkObjects=true" @@ -557,14 +560,20 @@ AfterTargets="ManagedBuild" Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__GenerateLayoutOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and ($(MonoAot) or $(MonoFullAot))" /> - - - - <_OptimizeFlagValue Condition="'$(Configuration)' == 'Checked' or '$(Configuration)' == 'Release'">true - - + + + + + + + + + + + + Properties="@(CreateLibProperty)" /> - diff --git a/src/tests/nativeaot/Directory.Build.props b/src/tests/nativeaot/Directory.Build.props index fc766c7ca3ad4a..c80fd3b623f2f2 100644 --- a/src/tests/nativeaot/Directory.Build.props +++ b/src/tests/nativeaot/Directory.Build.props @@ -1,7 +1,7 @@ - true + link diff --git a/src/tests/nativeaot/SmokeTests/Dataflow/Dataflow.csproj b/src/tests/nativeaot/SmokeTests/Dataflow/Dataflow.csproj index a2f7c8a0639046..7f97c2260b4f9d 100644 --- a/src/tests/nativeaot/SmokeTests/Dataflow/Dataflow.csproj +++ b/src/tests/nativeaot/SmokeTests/Dataflow/Dataflow.csproj @@ -6,7 +6,7 @@ true - true + true diff --git a/src/tests/nativeaot/SmokeTests/DeadCodeElimination/DeadCodeElimination.csproj b/src/tests/nativeaot/SmokeTests/DeadCodeElimination/DeadCodeElimination.csproj index 52b5172db82453..9efd44e913184c 100644 --- a/src/tests/nativeaot/SmokeTests/DeadCodeElimination/DeadCodeElimination.csproj +++ b/src/tests/nativeaot/SmokeTests/DeadCodeElimination/DeadCodeElimination.csproj @@ -6,7 +6,7 @@ true - true + true diff --git a/src/tests/nativeaot/SmokeTests/DynamicGenerics/DynamicGenerics.csproj b/src/tests/nativeaot/SmokeTests/DynamicGenerics/DynamicGenerics.csproj index a1f95483ed6ef9..fb40cdf7cd10cb 100644 --- a/src/tests/nativeaot/SmokeTests/DynamicGenerics/DynamicGenerics.csproj +++ b/src/tests/nativeaot/SmokeTests/DynamicGenerics/DynamicGenerics.csproj @@ -4,22 +4,14 @@ BuildAndRun 0 true - true - portable - true + true - - - - ]]> - - @@ -29,9 +21,5 @@ - - - PreserveNewest - diff --git a/src/tests/nativeaot/SmokeTests/FrameworkStrings/UseSystemResourceKeys.csproj b/src/tests/nativeaot/SmokeTests/FrameworkStrings/UseSystemResourceKeys.csproj index 22911d34a257e8..15bfab87f5776d 100644 --- a/src/tests/nativeaot/SmokeTests/FrameworkStrings/UseSystemResourceKeys.csproj +++ b/src/tests/nativeaot/SmokeTests/FrameworkStrings/UseSystemResourceKeys.csproj @@ -6,18 +6,12 @@ $(DefineConstants);RESOURCE_KEYS - true + true - - - - ]]> - - diff --git a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/X64Baseline.csproj b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/X64Baseline.csproj index c08324ae84ec64..e49eb84629044d 100644 --- a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/X64Baseline.csproj +++ b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/X64Baseline.csproj @@ -5,7 +5,6 @@ 0 true true - true $(DefineConstants);BASELINE_INTRINSICS diff --git a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64NonVex.csproj b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64NonVex.csproj index 76a1896a961ec0..9c6dfc29a3b918 100644 --- a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64NonVex.csproj +++ b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64NonVex.csproj @@ -5,19 +5,12 @@ 0 true true - true $(DefineConstants);NON_VEX_INTRINSICS - - - - ]]> - - diff --git a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64Vex.csproj b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64Vex.csproj index b3a7e88134f8ed..8ef7fb3a0b7b2b 100644 --- a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64Vex.csproj +++ b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/x64Vex.csproj @@ -5,19 +5,12 @@ 0 true true - true $(DefineConstants);VEX_INTRINSICS - - - - ]]> - - + // It's important we only use one canonical method and that method is not used from the consumption EXE. + if (GenericClass.IsArrayOfT(null)) + return false; + if (!GenericClass.IsArrayOfT(new string[0])) + return false; + + // Force the existence of a generic dictionary for GenericClass> + // Here we test a canonical method that will be used from the consumption EXE too. + if (!GenericClass>.IsT(new GenericStruct())) + return false; + + return true; + } + + public class GenericClass + { + [MethodImpl(MethodImplOptions.NoInlining)] + public static bool IsT(object o) => o is T; + [MethodImpl(MethodImplOptions.NoInlining)] + public static bool IsArrayOfT(object o) => o is T[]; + [MethodImpl(MethodImplOptions.NoInlining)] + public static bool IsMdArrayOfT(object o) => o is T[,]; + } + + public struct GenericStruct + { + public T Value; + } + + public class GenericClassWithTLS + { + [ThreadStatic] + public static int ThreadStaticInt; + } + + public static bool MethodThatUsesGenericWithTLS() + { + GenericClassWithTLS.ThreadStaticInt += 1; + return GenericClassWithTLS.ThreadStaticInt == 1; + } + + public enum MyEnum + { + One, Two + } +} diff --git a/src/tests/nativeaot/SmokeTests/MultiModule/Library.csproj b/src/tests/nativeaot/SmokeTests/MultiModule/Library.csproj new file mode 100644 index 00000000000000..96480bc3e86593 --- /dev/null +++ b/src/tests/nativeaot/SmokeTests/MultiModule/Library.csproj @@ -0,0 +1,10 @@ + + + Library + SharedLibrary + true + + + + + diff --git a/src/tests/nativeaot/SmokeTests/MultiModule/MultiModule.cs b/src/tests/nativeaot/SmokeTests/MultiModule/MultiModule.cs new file mode 100644 index 00000000000000..22b37c36dd5979 --- /dev/null +++ b/src/tests/nativeaot/SmokeTests/MultiModule/MultiModule.cs @@ -0,0 +1,90 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Globalization; +using System.Reflection; +using System.Runtime.CompilerServices; + +public class ReflectionTest +{ + const int Pass = 100; + const int Fail = -1; + + public static int Main() + { + if (TestStaticBases() == Fail) + return Fail; + + if (TestSharedGenerics() == Fail) + return Fail; + + if (TestGenericTLS() == Fail) + return Fail; + + if (TestInjectedEnumMethods() == Fail) + return Fail; + + return Pass; + } + + public static int TestStaticBases() + { + Console.WriteLine("Testing static bases in library code are available.."); + MultiModuleLibrary.ReturnValue = 50; + MultiModuleLibrary.ThreadStaticInt = 50; + + MultiModuleLibrary.StaticString = MultiModuleLibrary.ReturnValue.ToString() + MultiModuleLibrary.ThreadStaticInt.ToString(); + if (MultiModuleLibrary.StaticString != "5050") + return Fail; + + if (MultiModuleLibrary.ReturnValue + MultiModuleLibrary.ThreadStaticInt != 100) + return Fail; + + return Pass; + } + + public static int TestSharedGenerics() + { + Console.WriteLine("Testing generic dictionaries can be folded properly.."); + + // Use a generic dictionary that also exists in the library + if (!MultiModuleLibrary.GenericClass.IsT("Hello")) + return Fail; + if (!MultiModuleLibrary.GenericClass.IsMdArrayOfT(new string[0, 0])) + return Fail; + + if (!MultiModuleLibrary.GenericClass>.IsArrayOfT(new MultiModuleLibrary.GenericStruct[0])) + return Fail; + if (!MultiModuleLibrary.GenericClass>.IsT(new MultiModuleLibrary.GenericStruct())) + return Fail; + + if (!MultiModuleLibrary.MethodThatUsesGenerics()) + return Fail; + + return Pass; + } + + public static int TestGenericTLS() + { + Console.WriteLine("Testing thread statics on generic types shared between modules are shared properly.."); + + if (!MultiModuleLibrary.MethodThatUsesGenericWithTLS()) + return Fail; + + MultiModuleLibrary.GenericClassWithTLS.ThreadStaticInt += 1; + if (MultiModuleLibrary.GenericClassWithTLS.ThreadStaticInt != 2) + return Fail; + + return Pass; + } + + public static int TestInjectedEnumMethods() + { + Console.WriteLine("Testing context-injected methods on enums.."); + if (!MultiModuleLibrary.MyEnum.One.Equals(MultiModuleLibrary.MyEnum.One)) + return Fail; + + return Pass; + } +} diff --git a/src/tests/nativeaot/SmokeTests/MultiModule/MultiModule.csproj b/src/tests/nativeaot/SmokeTests/MultiModule/MultiModule.csproj new file mode 100644 index 00000000000000..7ab77cd0c702ec --- /dev/null +++ b/src/tests/nativeaot/SmokeTests/MultiModule/MultiModule.csproj @@ -0,0 +1,33 @@ + + + Exe + BuildAndRun + 0 + true + + + true + true + + + + + + + + + + + + + + + <_ResolvedProjectReferencePaths Remove="@(ObjFiles)" /> + + + diff --git a/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.csproj b/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.csproj index 3d7e77f5e9b5ed..0179e0d922c0d9 100644 --- a/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.csproj +++ b/src/tests/nativeaot/SmokeTests/PInvoke/PInvoke.csproj @@ -4,7 +4,7 @@ true - true + true diff --git a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.csproj b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.csproj index df0f69f5374c15..f0f876b0bb4ad5 100644 --- a/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.csproj +++ b/src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.csproj @@ -4,18 +4,12 @@ BuildAndRun 0 true - true + true - - - - ]]> - - diff --git a/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj b/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj index 1523073f7f9d71..f4c607f5d4dbdc 100644 --- a/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj +++ b/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj @@ -7,7 +7,7 @@ $(DefineConstants);REFLECTION_FROM_USAGE - true + true diff --git a/src/tests/nativeaot/SmokeTests/Reflection/Reflection_ReflectedOnly.csproj b/src/tests/nativeaot/SmokeTests/Reflection/Reflection_ReflectedOnly.csproj index 82c15f11dda895..48c56315c08b84 100644 --- a/src/tests/nativeaot/SmokeTests/Reflection/Reflection_ReflectedOnly.csproj +++ b/src/tests/nativeaot/SmokeTests/Reflection/Reflection_ReflectedOnly.csproj @@ -6,19 +6,13 @@ true - true + true - - - - ]]> - - diff --git a/src/tests/nativeaot/SmokeTests/SharedLibrary/SharedLibrary.csproj b/src/tests/nativeaot/SmokeTests/SharedLibrary/SharedLibrary.csproj index 04616906f4f9f6..84d04824fe8a6b 100644 --- a/src/tests/nativeaot/SmokeTests/SharedLibrary/SharedLibrary.csproj +++ b/src/tests/nativeaot/SmokeTests/SharedLibrary/SharedLibrary.csproj @@ -4,18 +4,10 @@ BuildAndRun 0 true - - - - - - Library Shared - ]]> - + nul diff --git a/src/tests/run.cmd b/src/tests/run.cmd index 156ee282284dbc..05af04071ea42d 100644 --- a/src/tests/run.cmd +++ b/src/tests/run.cmd @@ -61,8 +61,6 @@ if /i "%1" == "ilasmroundtrip" (set __IlasmRoundTrip=1& if /i "%1" == "printlastresultsonly" (set __PrintLastResultsOnly=1&shift&goto Arg_Loop) if /i "%1" == "runcrossgen2tests" (set RunCrossGen2=true&shift&goto Arg_Loop) -if /i "%1" == "runnativeaottests" (set RunNativeAot=true&shift&goto Arg_Loop) -if /i "%1" == "nativeaotmultimodule" (set NativeAotMultimodule=true&shift&goto Arg_Loop) REM This test feature is currently intentionally undocumented if /i "%1" == "runlargeversionbubblecrossgen2tests" (set RunCrossGen2=true&set CrossgenLargeVersionBubble=true&shift&goto Arg_Loop) if /i "%1" == "link" (set DoLink=true&set ILLINK=%2&shift&shift&goto Arg_Loop) @@ -74,6 +72,7 @@ if /i "%1" == "gcstresslevel" (set COMPlus_GCStress=%2 if /i "%1" == "runincontext" (set RunInUnloadableContext=1&shift&goto Arg_Loop) if /i "%1" == "tieringtest" (set TieringTest=1&shift&goto Arg_Loop) +if /i "%1" == "runnativeaottests" (set RunNativeAot=1&shift&goto Arg_Loop) if /i not "%1" == "msbuildargs" goto SkipMsbuildArgs :: All the rest of the args will be collected and passed directly to msbuild. @@ -141,14 +140,6 @@ if defined CrossgenLargeVersionBubble ( set __RuntestPyArgs=%__RuntestPyArgs% --large_version_bubble ) -if defined RunNativeAot ( - set __RuntestPyArgs=%__RuntestPyArgs% --run_nativeaot_tests -) - -if defined NativeAotMultimodule ( - set __RuntestPyArgs=%__RuntestPyArgs% --nativeaot_multimodule -) - if defined __PrintLastResultsOnly ( set __RuntestPyArgs=%__RuntestPyArgs% --analyze_results_only ) @@ -161,6 +152,10 @@ if defined TieringTest ( set __RuntestPyArgs=%__RuntestPyArgs% --tiering_test ) +if defined RunNativeAot ( + set __RuntestPyArgs=%__RuntestPyArgs% --run_nativeaot_tests +) + REM Find python and set it to the variable PYTHON set _C=-c "import sys; sys.stdout.write(sys.executable)" (py -3 %_C% || py -2 %_C% || python3 %_C% || python2 %_C% || python %_C%) > %TEMP%\pythonlocation.txt 2> NUL diff --git a/src/tests/run.py b/src/tests/run.py index d0275baca9297f..aab137bafa08f7 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -92,8 +92,6 @@ parser.add_argument("--gcsimulator", dest="gcsimulator", action="store_true", default=False) parser.add_argument("--ilasmroundtrip", dest="ilasmroundtrip", action="store_true", default=False) parser.add_argument("--run_crossgen2_tests", dest="run_crossgen2_tests", action="store_true", default=False) -parser.add_argument("--run_nativeaot_tests", dest="run_nativeaot_tests", action="store_true", default=False) -parser.add_argument("--nativeaot_multimodule", dest="nativeaot_multimodule", action="store_true", default=False) parser.add_argument("--large_version_bubble", dest="large_version_bubble", action="store_true", default=False) parser.add_argument("--skip_test_run", dest="skip_test_run", action="store_true", default=False, help="Does not run tests.") parser.add_argument("--sequential", dest="sequential", action="store_true", default=False) @@ -103,6 +101,7 @@ parser.add_argument("--limited_core_dumps", dest="limited_core_dumps", action="store_true", default=False) parser.add_argument("--run_in_context", dest="run_in_context", action="store_true", default=False) parser.add_argument("--tiering_test", dest="tiering_test", action="store_true", default=False) +parser.add_argument("--run_nativeaot_tests", dest="run_nativeaot_tests", action="store_true", default=False) ################################################################################ # Globals @@ -871,16 +870,6 @@ def run_tests(args, print("Setting RunCrossGen2=true") os.environ["RunCrossGen2"] = "true" - if args.run_nativeaot_tests: - print("Running tests Native AOT") - print("Setting RunNativeAot=true") - os.environ["RunNativeAot"] = "true" - - if args.nativeaot_multimodule: - print("Native AOT will be compiled in multimodule mode") - print("Setting NativeAotMultimodule=true") - os.environ["NativeAotMultimodule"] = "true" - if args.large_version_bubble: print("Large Version Bubble enabled") os.environ["LargeVersionBubble"] = "true" @@ -902,6 +891,10 @@ def run_tests(args, print("Running test repeatedly to promote methods to tier1") os.environ["CLRCustomTestLauncher"] = args.tieringtest_script_path + if args.run_nativeaot_tests: + print("Running tests NativeAOT") + os.environ["CLRCustomTestLauncher"] = args.nativeaottest_script_path + # Set __TestTimeout environment variable, which is the per-test timeout in milliseconds. # This is read by the test wrapper invoker, in src\tests\Common\Coreclr.TestWrapper\CoreclrTestWrapperLib.cs. print("Setting __TestTimeout=%s" % str(per_test_timeout)) @@ -1003,16 +996,6 @@ def setup_args(args): lambda unused: True, "Error setting run_crossgen2_tests") - coreclr_setup_args.verify(args, - "run_nativeaot_tests", - lambda unused: True, - "Error setting run_nativeaot_tests") - - coreclr_setup_args.verify(args, - "nativeaot_multimodule", - lambda unused: True, - "Error setting nativeaot_multimodule") - coreclr_setup_args.verify(args, "skip_test_run", lambda arg: True, @@ -1043,6 +1026,12 @@ def setup_args(args): lambda arg: True, "Error setting tiering_test") + coreclr_setup_args.verify(args, + "run_nativeaot_tests", + lambda arg: True, + "Error setting run_nativeaot_tests") + + print("host_os : %s" % coreclr_setup_args.host_os) print("arch : %s" % coreclr_setup_args.arch) print("build_type : %s" % coreclr_setup_args.build_type) @@ -1056,6 +1045,7 @@ def setup_args(args): coreclr_setup_args.coreclr_tests_src_dir = os.path.join(coreclr_setup_args.runtime_repo_location, "src", "tests") coreclr_setup_args.runincontext_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "runincontext%s" % (".cmd" if coreclr_setup_args.host_os == "windows" else ".sh")) coreclr_setup_args.tieringtest_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "tieringtest%s" % (".cmd" if coreclr_setup_args.host_os == "windows" else ".sh")) + coreclr_setup_args.nativeaottest_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "nativeaottest%s" % (".cmd" if coreclr_setup_args.host_os == "windows" else ".sh")) coreclr_setup_args.logs_dir = os.path.join(coreclr_setup_args.artifacts_location, "log") return coreclr_setup_args diff --git a/src/tests/run.sh b/src/tests/run.sh index a920fc580b5cae..15663e66e5e50f 100755 --- a/src/tests/run.sh +++ b/src/tests/run.sh @@ -18,7 +18,6 @@ function print_usage { echo ' --disableEventLogging : Disable the events logged by both VM and Managed Code' echo ' --sequential : Run tests sequentially (default is to run in parallel).' echo ' --runcrossgen2tests : Runs the ReadyToRun tests compiled with Crossgen2' - echo ' --runnativeaottests : Runs the ready to run tests compiled with Native AOT' echo ' --jitstress= : Runs the tests with COMPlus_JitStress=n' echo ' --jitstressregs= : Runs the tests with COMPlus_JitStressRegs=n' echo ' --jitminopts : Runs the tests with COMPlus_JITMinOpts=1' @@ -36,6 +35,7 @@ function print_usage { echo ' --printLastResultsOnly : Print the results of the last run' echo ' --runincontext : Run each tests in an unloadable AssemblyLoadContext' echo ' --tieringtest : Run each test to encourage tier1 rejitting' + echo ' --runnativeaottests : Run NativeAOT compiled tests' echo ' --limitedDumpGeneration : ' } @@ -99,6 +99,7 @@ printLastResultsOnly= runSequential=0 runincontext=0 tieringtest=0 +nativeaottest=0 for i in "$@" do @@ -168,9 +169,6 @@ do --runcrossgen2tests) export RunCrossGen2=1 ;; - --runnativeaottests) - export RunNativeAot=1 - ;; --sequential) runSequential=1 ;; @@ -201,6 +199,9 @@ do --tieringtest) tieringtest=1 ;; + --runnativeaottests) + nativeaottest=1 + ;; *) echo "Unknown switch: $i" print_usage @@ -285,10 +286,6 @@ if [[ -n "$RunCrossGen2" ]]; then runtestPyArguments+=("--run_crossgen2_tests") fi -if [[ -n "$RunNativeAot" ]]; then - runtestPyArguments+=("--run_nativeaot_tests") -fi - if [[ "$limitedCoreDumps" == "ON" ]]; then runtestPyArguments+=("--limited_core_dumps") fi @@ -303,6 +300,11 @@ if [[ "$tieringtest" -ne 0 ]]; then runtestPyArguments+=("--tieringtest") fi +if [[ "$nativeaottest" -ne 0 ]]; then + echo "Running NativeAOT compiled tests" + runtestPyArguments+=("--run_nativeaot_tests") +fi + # Default to python3 if it is installed __Python=python if command -v python3 &>/dev/null; then