Skip to content
Merged
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
5 changes: 5 additions & 0 deletions src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Comment thread
davidwrighton marked this conversation as resolved.
Console.WriteLine();

Console.WriteLine(String.Format(SR.SwitchWithDefaultHelp, "--type-validation", String.Join("', '", Enum.GetNames<TypeValidationRule>()), nameof(TypeValidationRule.Automatic)));
Console.WriteLine();

Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/tools/aot/crossgen2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ private void RunSingleCompilation(Dictionary<string, string> inFilePaths, Instru
string rtrHeaderSymbolName = Get(_command.ReadyToRunHeaderSymbolName);

ReadyToRunContainerFormat format = Get(_command.OutputFormat);
if (format == ReadyToRunContainerFormat.PE && typeSystemContext.Target.Architecture == TargetArchitecture.Wasm32)
{
format = ReadyToRunContainerFormat.Wasm;
Comment thread
davidwrighton marked this conversation as resolved.
}
if (!composite && format != ReadyToRunContainerFormat.PE && format != ReadyToRunContainerFormat.Wasm)
{
throw new Exception(string.Format(SR.ErrorContainerFormatRequiresComposite, format));
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/tools/r2rtest/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void CreateCommand(string name, string description, Option[] options, Func<Build
OutputDirectory,
Crossgen2Path,
TargetArch,
TargetOs,
VerifyTypeAndFieldLayout,
NoJit,
NoCrossgen2,
Expand Down Expand Up @@ -72,6 +73,7 @@ void CreateCommand(string name, string description, Option[] options, Func<Build
OutputDirectory,
Crossgen2Path,
TargetArch,
TargetOs,
VerifyTypeAndFieldLayout,
NoJit,
NoCrossgen2,
Expand Down Expand Up @@ -107,6 +109,7 @@ void CreateCommand(string name, string description, Option[] options, Func<Build
{
Crossgen2Path,
TargetArch,
TargetOs,
VerifyTypeAndFieldLayout,
NoCrossgen2,
NoCleanup,
Expand Down Expand Up @@ -280,6 +283,9 @@ void CreateCommand(string name, string description, Option[] options, Func<Build
public Option<string> TargetArch { get; } =
new("--target-arch") { Description = "Target architecture for crossgen2" };

public Option<string> TargetOs { get; } =
new("--target-os") { Description = "Target OS for crossgen2" };

//
// compile-nuget specific options
//
Expand All @@ -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);
Expand Down Expand Up @@ -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; }
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/tools/r2rtest/Crossgen2Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ protected override IEnumerable<string> BuildCommandLineArguments(IEnumerable<str
yield return $"--targetarch={_options.TargetArch}";
}

if (_options.TargetOs != null)
{
yield return $"--targetos={_options.TargetOs}";
}

if (_options.VerifyTypeAndFieldLayout)
{
yield return "--verify-type-and-field-layout";
Expand Down
21 changes: 19 additions & 2 deletions src/tests/Common/CLRTest.CrossGen.targets
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
if [ "$(CrossGen2OutputFormat)" == "macho" ]; then
__CompositeExt=".o"
__CompositeExtFinal=".dylib"
elif [ "$(CrossGen2OutputFormat)" == "wasm" ]; then
__CompositeExt=".wasm"
__CompositeExtFinal=".wasm"
fi
RunCrossgen2OnFiles "$PWD/composite-r2r${__CompositeExt}" "$PWD/composite-r2r${__CompositeExtFinal}" "$PWD/IL-CG2/*.dll"
else
Expand All @@ -182,6 +185,9 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
do
echo $dllFile
bareFileName="${dllFile##*/}"
if [ "$(CrossGen2OutputFormat)" == "wasm" ]; then
bareFileName="${bareFileName%.dll}.wasm"
fi
RunCrossgen2OnFiles "$PWD/$bareFileName" "$PWD/$bareFileName" "$dllFile"
if [ $__cg2ExitCode -ne 0 ]; then
break
Expand Down Expand Up @@ -255,7 +261,11 @@ if defined RunCrossGen2 (

if defined CompositeBuildMode (
set ExtraCrossGen2Args=!ExtraCrossGen2Args! --composite
set __OutputFile=!scriptPath!\composite-r2r.dll
if "$(CrossGen2OutputFormat)"=="wasm" (
set __OutputFile=!scriptPath!\composite-r2r.wasm
) else (
set __OutputFile=!scriptPath!\composite-r2r.dll
)
set __PdbFile=!scriptPath!\composite-r2r.ni.pdb
rem In composite mode, treat all dll's in the test folder as rooting inputs
set __InputFile=!scriptPath!IL-CG2\*.dll
Expand All @@ -264,7 +274,11 @@ if defined RunCrossGen2 (
) else (
set ExtraCrossGen2Args=!ExtraCrossGen2Args! -r:!scriptPath!IL-CG2\*.dll
for %%I in (!scriptPath!IL-CG2\*.dll) do (
set __OutputFile=!scriptPath!%%~nI.dll
if "$(CrossGen2OutputFormat)"=="wasm" (
set __OutputFile=!scriptPath!%%~nI.wasm
) else (
set __OutputFile=!scriptPath!%%~nI.dll
)
set __PdbFile=!scriptPath!%%~nI.ni.pdb
set __InputFile=%%I
call :CompileOneFileCrossgen2
Expand Down Expand Up @@ -302,6 +316,9 @@ if defined RunCrossGen2 (
echo --targetos:$(TargetOS)>>!__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!
Expand Down
26 changes: 25 additions & 1 deletion src/tests/Common/CLRTest.Execute.Bash.targets
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,20 @@ fi
<CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"$CORE_ROOT/corerun" $(CoreRunArgs) ${__DotEnvArg}</CLRTestRunFile>
<WatcherRunFile>"$CORE_ROOT/watchdog" $_WatcherTimeoutMins</WatcherRunFile>

<!-- Note that this overwrites CLRTestBashPreCommands rather than adding to it. -->
<!-- CoreCLR on browser defaults to running tests with Node.js -->
<BashDefaultRunWithNodeJS Condition="'$(RuntimeFlavor)' == 'coreclr' and '$(TargetOS)' == 'browser'"><![CDATA[
if [ -z "${RunWithNodeJS:-}" ] ; then
export RunWithNodeJS=1
fi
]]></BashDefaultRunWithNodeJS>

<CLRTestBashPreCommands Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(TargetArchitecture)' == 'wasm'"><![CDATA[
$(CLRTestBashPreCommands)
$(BashDefaultRunWithNodeJS)
if [ ! -z ${RunCrossGen2+x} ]%3B then
TakeLock
fi

if [ -z "${RunWithNodeJS:-}" ] ; then
# Build wasm app containing the test dll
__Command=""
Expand All @@ -286,6 +298,10 @@ if [ -z "${RunWithNodeJS:-}" ] ; then

$__Command msbuild $CORE_ROOT/wasm-test-runner/WasmTestRunner.proj /p:NetCoreAppCurrent=$(NetCoreAppCurrent) /p:TestAssemblyFileName=$(MsBuildProjectName).dll /p:TestBinDir=`pwd` $(CLRTestMSBuildArgs) || exit $?
fi

if [ ! -z ${RunCrossGen2+x} ]%3B then
ReleaseLock
fi
Comment thread
davidwrighton marked this conversation as resolved.
]]>
</CLRTestBashPreCommands>

Expand Down Expand Up @@ -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
Expand All @@ -389,6 +409,10 @@ else
run_with_timeout $__TestTimeout "${cmd[@]}"
fi
CLRTestExitCode=$?

if [ ! -z ${RunCrossGen2+x} ]%3B then
ReleaseLock
fi
]]>
</BashCLRTestLaunchCmds>
<BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' And '$(TargetOS)' == 'android'">
Expand Down
29 changes: 28 additions & 1 deletion src/tests/Common/CLRTest.Execute.Batch.targets
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,25 @@ Exit /b !ERRORLEVEL!
<CLRTestRunFile Condition="'$(CLRTestIsHosted)'=='true'">"%CORE_ROOT%\corerun.exe" $(CoreRunArgs) %__DotEnvArg%</CLRTestRunFile>
<WatcherRunFile>"%CORE_ROOT%\watchdog.exe" %_WatcherTimeoutMins%</WatcherRunFile>

<!-- CoreCLR on browser defaults to running tests with Node.js -->
<BatchDefaultRunWithNodeJS Condition="'$(RuntimeFlavor)' == 'coreclr' and '$(TargetOS)' == 'browser'"><![CDATA[
IF NOT DEFINED RunWithNodeJS (
set RunWithNodeJS=1
)
]]></BatchDefaultRunWithNodeJS>

<BatchCopyCoreShimLocalCmds Condition="'$(CLRTestScriptLocalCoreShim)' == 'true'"><![CDATA[
REM Local CoreShim requested - see MSBuild property 'CLRTestScriptLocalCoreShim'
ECHO Copying '%CORE_ROOT%\CoreShim.dll'...
COPY /y %CORE_ROOT%\CoreShim.dll .
]]></BatchCopyCoreShimLocalCmds>
<!-- Note that this overwrites CLRTestBatchPreCommands rather than adding to it. -->
<CLRTestBatchPreCommands Condition="'$(CLRTestKind)' == 'BuildAndRun' and '$(TargetArchitecture)' == 'wasm'"><![CDATA[
$(CLRTestBatchPreCommands)
$(BatchDefaultRunWithNodeJS)
if defined RunCrossGen2 (
call :TakeLock
)

IF NOT DEFINED RunWithNodeJS (
REM Build wasm app containing the test dll
IF DEFINED __TestDotNetCmd (
Expand All @@ -277,10 +289,17 @@ IF NOT DEFINED RunWithNodeJS (

!__Command! msbuild %CORE_ROOT%\wasm-test-runner\WasmTestRunner.proj /p:NetCoreAppCurrent=$(NetCoreAppCurrent) /p:TestAssemblyFileName=$(MsBuildProjectName).dll /p:TestBinDir=%%CD%% $(CLRTestMSBuildArgs)
IF NOT "!ERRORLEVEL!"=="0" (
if defined RunCrossGen2 (
call :ReleaseLock
)
popd
Exit /b !ERRORLEVEL!
)
)

if defined RunCrossGen2 (
call :ReleaseLock
)
]]></CLRTestBatchPreCommands>

<BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' And '$(TargetOS)' != 'android' And '$(TargetOS)' != 'browser'">
Expand Down Expand Up @@ -314,6 +333,10 @@ if defined RunCrossGen2 (
]]></BatchCLRTestLaunchCmds>
<BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' And '$(TargetOS)' == 'browser'">
<![CDATA[
if defined RunCrossGen2 (
call :TakeLock
)

IF NOT DEFINED RunWithNodeJS (
ECHO V8 execution is not supported on Windows. Set RunWithNodeJS to use Node.
set CLRTestExitCode=1
Expand Down Expand Up @@ -346,6 +369,10 @@ IF NOT DEFINED RunWithNodeJS (
call :RunWithTimeout !__TestTimeout!
set CLRTestExitCode=!ERRORLEVEL!
)

if defined RunCrossGen2 (
call :ReleaseLock
)
]]></BatchCLRTestLaunchCmds>
<BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun' And '$(TargetOS)' == 'android'">
<![CDATA[
Expand Down
19 changes: 19 additions & 0 deletions src/tests/Common/CoreRootArtifacts.targets
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,26 @@
</PropertyGroup>

<ItemGroup Condition="'$(_Crossgen2Dir)' != ''">
<!-- When crossgen2-published does not exist (e.g. wasm cross-targeting builds),
copy crossgen2 itself from the cross-architecture build output. -->
<_CoreRootArtifactSource
Include="$(_Crossgen2Dir)/crossgen2$(ExeSuffix)"
Condition="Exists('$(_Crossgen2Dir)/crossgen2$(ExeSuffix)') and !Exists('$(CoreCLRArtifactsPath)crossgen2-published/crossgen2$(ExeSuffix)')"
TargetDir="crossgen2/" />
<_CoreRootArtifactSource
Include="$(_Crossgen2Dir)/crossgen2.pdb"
Comment thread
kg marked this conversation as resolved.
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);
Expand Down
1 change: 1 addition & 0 deletions src/tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@

<PropertyGroup Condition="'$(TargetOS)' == 'browser'">
<CLRTestMSBuildArgs>/p:MSBuildEnableWorkloadResolver=false /p:Configuration=$(Configuration)</CLRTestMSBuildArgs>
<CrossGen2OutputFormat>wasm</CrossGen2OutputFormat>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestsCommonProject)' != 'true'">
Expand Down
8 changes: 4 additions & 4 deletions src/tests/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -361,8 +361,8 @@ echo.
echo Build target OS options:
echo os ^<value^>: 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.
Expand Down
12 changes: 12 additions & 0 deletions src/tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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//:/ })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<CLRTestTargetUnsupported Condition="'$(EnableNativeSanitizers)' != ''">true</CLRTestTargetUnsupported>
<!-- Disable on Mono which does not support runtime-async. -->
<CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' == 'mono'">true</CLRTestTargetUnsupported>
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' == 'wasm'">true</CLRTestTargetUnsupported>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="helper/helper.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- Needed for CLRTestTargetUnsupported, GCStressIncompatible, CrossGenTest -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported>
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' == 'wasm'">true</CLRTestTargetUnsupported>
<!-- We skip the ReadyToRun tests when sanitized due to build complexity -->
<DisableProjectBuild Condition="'$(EnableNativeSanitizers)' != ''">true</DisableProjectBuild>
<!-- Running Crossgen2 under GCStress takes too long -->
Expand Down
1 change: 1 addition & 0 deletions src/tests/readytorun/tests/mainv1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<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>
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' == 'wasm'">true</CLRTestTargetUnsupported>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="fieldgetter.ilproj" />
Expand Down
1 change: 1 addition & 0 deletions src/tests/readytorun/tests/mainv2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<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>
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' == 'wasm'">true</CLRTestTargetUnsupported>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="fieldgetter.ilproj" />
Expand Down
Loading