diff --git a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs index 49127d3077831a..1540d9f143b10f 100644 --- a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs +++ b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs @@ -315,6 +315,11 @@ public static void PrintExtendedHelp(ParseResult _) Console.WriteLine(); Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--targetarch", String.Join("', '", ValidArchitectures), Helpers.GetTargetArchitecture(null).ToString().ToLowerInvariant())); Console.WriteLine(); + + string[] ValidObjFormats = ["pe", "macho", "wasm"]; + Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--obj-format", String.Join("', '", ValidObjFormats), "pe")); + Console.WriteLine(); + Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--type-validation", String.Join("', '", Enum.GetNames()), nameof(TypeValidationRule.Automatic))); Console.WriteLine(); diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs index 592e6bc4300669..88b093bde7daed 100644 --- a/src/coreclr/tools/aot/crossgen2/Program.cs +++ b/src/coreclr/tools/aot/crossgen2/Program.cs @@ -414,6 +414,10 @@ private void RunSingleCompilation(Dictionary inFilePaths, Instru string rtrHeaderSymbolName = Get(_command.ReadyToRunHeaderSymbolName); ReadyToRunContainerFormat format = Get(_command.OutputFormat); + if (format == ReadyToRunContainerFormat.PE && typeSystemContext.Target.Architecture == TargetArchitecture.Wasm32) + { + format = ReadyToRunContainerFormat.Wasm; + } if (!composite && format != ReadyToRunContainerFormat.PE && format != ReadyToRunContainerFormat.Wasm) { throw new Exception(string.Format(SR.ErrorContainerFormatRequiresComposite, format)); diff --git a/src/coreclr/tools/r2rtest/CommandLineOptions.cs b/src/coreclr/tools/r2rtest/CommandLineOptions.cs index 82404653add802..c0b818a5922cf5 100644 --- a/src/coreclr/tools/r2rtest/CommandLineOptions.cs +++ b/src/coreclr/tools/r2rtest/CommandLineOptions.cs @@ -34,6 +34,7 @@ void CreateCommand(string name, string description, Option[] options, Func TargetArch { get; } = new("--target-arch") { Description = "Target architecture for crossgen2" }; + public Option TargetOs { get; } = + new("--target-os") { Description = "Target OS for crossgen2" }; + // // compile-nuget specific options // @@ -306,6 +312,7 @@ public BuildOptions(R2RTestRootCommand cmd, ParseResult res) Crossgen2Path = res.GetValue(cmd.Crossgen2Path); VerifyTypeAndFieldLayout = res.GetValue(cmd.VerifyTypeAndFieldLayout); TargetArch = res.GetValue(cmd.TargetArch); + TargetOs = res.GetValue(cmd.TargetOs); Exe = res.GetValue(cmd.Exe); NoJit = res.GetValue(cmd.NoJit); NoCrossgen2 = res.GetValue(cmd.NoCrossgen2); @@ -345,6 +352,7 @@ public BuildOptions(R2RTestRootCommand cmd, ParseResult res) public FileInfo Crossgen2Path { get; } public bool VerifyTypeAndFieldLayout { get; } public string TargetArch { get; } + public string TargetOs { get; } public bool Exe { get; } public bool NoJit { get; set; } public bool NoCrossgen2 { get; } diff --git a/src/coreclr/tools/r2rtest/Crossgen2Runner.cs b/src/coreclr/tools/r2rtest/Crossgen2Runner.cs index e9024d58da3a03..43fee7b771d150 100644 --- a/src/coreclr/tools/r2rtest/Crossgen2Runner.cs +++ b/src/coreclr/tools/r2rtest/Crossgen2Runner.cs @@ -122,6 +122,11 @@ protected override IEnumerable BuildCommandLineArguments(IEnumerable>!__ResponseFile! echo --verify-type-and-field-layout>>!__ResponseFile! echo --method-layout:random>>!__ResponseFile! + if not "$(CrossGen2OutputFormat)"=="" ( + echo -f:$(CrossGen2OutputFormat)>>!__ResponseFile! + ) if defined CrossGen2SynthesizePgo ( echo --synthesize-random-mibc>>!__ResponseFile! echo --embed-pgo-data>>!__ResponseFile! diff --git a/src/tests/Common/CLRTest.Execute.Bash.targets b/src/tests/Common/CLRTest.Execute.Bash.targets index d54cb9451549f2..f6e69ad1ab0bb2 100644 --- a/src/tests/Common/CLRTest.Execute.Bash.targets +++ b/src/tests/Common/CLRTest.Execute.Bash.targets @@ -270,8 +270,20 @@ fi "$CORE_ROOT/corerun" $(CoreRunArgs) ${__DotEnvArg} "$CORE_ROOT/watchdog" $_WatcherTimeoutMins - + + + @@ -370,6 +386,10 @@ run_with_timeout() { fi } +if [ ! -z ${RunCrossGen2+x} ]%3B then + TakeLock +fi + if [ -z ${RunWithNodeJS+x} ] ; then cd WasmApp ./run-v8.sh @@ -389,6 +409,10 @@ else run_with_timeout $__TestTimeout "${cmd[@]}" fi CLRTestExitCode=$? + +if [ ! -z ${RunCrossGen2+x} ]%3B then + ReleaseLock +fi ]]> diff --git a/src/tests/Common/CLRTest.Execute.Batch.targets b/src/tests/Common/CLRTest.Execute.Batch.targets index ad55aa0ea53e91..f193266a921e2c 100644 --- a/src/tests/Common/CLRTest.Execute.Batch.targets +++ b/src/tests/Common/CLRTest.Execute.Batch.targets @@ -257,13 +257,25 @@ Exit /b !ERRORLEVEL! "%CORE_ROOT%\corerun.exe" $(CoreRunArgs) %__DotEnvArg% "%CORE_ROOT%\watchdog.exe" %_WatcherTimeoutMins% + + + - @@ -314,6 +333,10 @@ if defined RunCrossGen2 ( ]]> + <_CoreRootArtifactSource + Include="$(_Crossgen2Dir)/crossgen2$(ExeSuffix)" + Condition="Exists('$(_Crossgen2Dir)/crossgen2$(ExeSuffix)') and !Exists('$(CoreCLRArtifactsPath)crossgen2-published/crossgen2$(ExeSuffix)')" + TargetDir="crossgen2/" /> + <_CoreRootArtifactSource + Include="$(_Crossgen2Dir)/crossgen2.pdb" + Condition="Exists('$(_Crossgen2Dir)/crossgen2.pdb') and !Exists('$(CoreCLRArtifactsPath)crossgen2-published/crossgen2$(ExeSuffix)')" + TargetDir="crossgen2/" /> + + <_CoreRootArtifactSource + Condition="'$(TargetArchitecture)' == 'wasm'" + Include=" + $(_Crossgen2Dir)/$(HostLibPrefix)clrjit_*$(HostLibSuffix); + $(_Crossgen2Dir)/$(HostLibPrefix)jitinterface_*$(HostLibSuffix); + $(_Crossgen2Dir)/$(HostLibPrefix)Microsoft.DiaSymReader.Native.*$(HostLibSuffix)" + TargetDir="crossgen2/" /> + <_CoreRootArtifactSource + Condition="'$(TargetArchitecture)' != 'wasm'" Include=" $(_Crossgen2Dir)/$(LibPrefix)clrjit_*$(LibSuffix); $(_Crossgen2Dir)/$(LibPrefix)jitinterface_*$(LibSuffix); diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index b6dce9ef455492..db8747e62a7edf 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -202,6 +202,7 @@ /p:MSBuildEnableWorkloadResolver=false /p:Configuration=$(Configuration) + wasm diff --git a/src/tests/build.cmd b/src/tests/build.cmd index 1f90861cde5a17..cb5305566bdf7b 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -70,8 +70,8 @@ if /i "%1" == "arm64" (set __BuildArch=arm64&set processedArg if /i "%1" == "wasm" (set __BuildArch=wasm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "os" (set __TargetOS=%2&set processedArgs=!processedArgs! %1&shift&shift&goto Arg_Loop) -if /i "%1" == "browser" (set __TargetOS=browser&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "wasi" (set __TargetOS=wasi&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "browser" (set __TargetOS=browser&set __BuildArch=wasm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "wasi" (set __TargetOS=wasi&set __BuildArch=wasm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "debug" (set __BuildType=Debug&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "release" (set __BuildType=Release&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -361,8 +361,8 @@ echo. echo Build target OS options: echo os ^: Set the target OS. Common values: windows ^(default^), linux, osx, android, echo ios, iossimulator, tvos, tvossimulator, maccatalyst, browser, wasi. -echo browser: Shorthand for "os browser" ^(typically combine with "wasm", for example "wasm browser"^). -echo wasi: Shorthand for "os wasi" ^(typically combine with "wasm", for example "wasm wasi"^). +echo browser: Shorthand for "os browser" ^(also sets architecture to wasm^). +echo wasi: Shorthand for "os wasi" ^(also sets architecture to wasm^). echo. echo -Rebuild: Clean up all test artifacts prior to building tests. echo -SkipRestorePackages: Skip package restore. diff --git a/src/tests/build.sh b/src/tests/build.sh index f18f28ee740369..04c4857862ccb7 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -141,6 +141,8 @@ usage_list+=(" target OS. Common values: linux (default on Linux), osx (defau usage_list+=(" ios, iossimulator, tvos, tvossimulator, maccatalyst, browser, wasi.") usage_list+=(" For mobile/device targets (android, ios, iossimulator, tvos, tvossimulator), this script") usage_list+=(" automatically skips building native test components.") +usage_list+=("-browser - Shorthand for '-os browser' (also sets architecture to wasm).") +usage_list+=("-wasi - Shorthand for '-os wasi' (also sets architecture to wasm).") usage_list+=("") usage_list+=("-rebuild - Clean up all test artifacts prior to building tests.") usage_list+=("-skiprestorepackages - Skip package restore.") @@ -300,6 +302,16 @@ handle_arguments_local() { __MonoFullAot=0 ;; + browser|-browser) + __TargetOS=browser + __TargetArch=wasm + ;; + + wasi|-wasi) + __TargetOS=wasi + __TargetArch=wasm + ;; + log*|-log*) local arg="$1" local parts=(${arg//:/ }) diff --git a/src/tests/readytorun/async-inline-thunks/async-inline-thunks.csproj b/src/tests/readytorun/async-inline-thunks/async-inline-thunks.csproj index 52eb3c331b841c..1536761f3f5f8a 100644 --- a/src/tests/readytorun/async-inline-thunks/async-inline-thunks.csproj +++ b/src/tests/readytorun/async-inline-thunks/async-inline-thunks.csproj @@ -9,6 +9,7 @@ true true + true diff --git a/src/tests/readytorun/determinism/crossgen2determinism.csproj b/src/tests/readytorun/determinism/crossgen2determinism.csproj index 84532f28885476..44c07855703f35 100644 --- a/src/tests/readytorun/determinism/crossgen2determinism.csproj +++ b/src/tests/readytorun/determinism/crossgen2determinism.csproj @@ -3,6 +3,7 @@ true true + true true diff --git a/src/tests/readytorun/tests/mainv1.csproj b/src/tests/readytorun/tests/mainv1.csproj index f94ba98d503ebc..2aa1311fc76e24 100644 --- a/src/tests/readytorun/tests/mainv1.csproj +++ b/src/tests/readytorun/tests/mainv1.csproj @@ -7,6 +7,7 @@ true true + true diff --git a/src/tests/readytorun/tests/mainv2.csproj b/src/tests/readytorun/tests/mainv2.csproj index 5a98d10e98612f..cbff9e03efb8c9 100644 --- a/src/tests/readytorun/tests/mainv2.csproj +++ b/src/tests/readytorun/tests/mainv2.csproj @@ -7,6 +7,7 @@ true true + true