Skip to content

Commit b7db8f4

Browse files
authored
[clr-interp] Include clrinterpreter library in the iOS app bundle (#117277)
* Install clrinterpreter into the sharedFramework to include it in the iOS bundle * Use static clrinterpreter on iOS * Fix build errors * Add functional test * Fix build errors * Build smoke tests * Update executable name placeholder in runtime-coreclr.m * Set environment variables to interp method * Set AdditionalXHarnessArguments * Set xharness env variables in helix * Add support for interpreter methods in AppleAppBuilder * Add InterpreterMethods property to AppleBuild.targets * Update build configuration to Debug and fix condition * Add environment variables DOTNET_InterpMode and DOTNET_ReadyToRun * Refactor AppleAppBuilder to support environment variables * Fix condition * Update PlatformManifestFileEntry conditions to use RuntimeConfiguration * Test build without PlatformManifestFileEntry * Add PlatformManifestFileEntry for clrinterpreter * Update FEATURE_INTERPRETER logic to use uppercase build type for Debug and Checked configurations * Update PlatformManifestFileEntry for clrinterpreter * Support optional installation of clr components * Move functional test to extra-platforms * Remove condition and clean up CMakeLists * Remove condition from iossimulator job * Remove redundant JIT static variable from coreclr cmake configuration * Fix build
1 parent 15a290a commit b7db8f4

File tree

14 files changed

+165
-24
lines changed

14 files changed

+165
-24
lines changed

eng/native/functions.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,11 @@ function(install_static_library targetName destination component)
548548
endif()
549549
endfunction()
550550

551-
# install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName])
551+
# install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName] [OPTIONAL])
552552
function(install_clr)
553553
set(multiValueArgs TARGETS DESTINATIONS)
554554
set(singleValueArgs COMPONENT)
555-
set(options "")
555+
set(options OPTIONAL)
556556
cmake_parse_arguments(INSTALL_CLR "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGV})
557557

558558
if ("${INSTALL_CLR_TARGETS}" STREQUAL "")
@@ -587,12 +587,18 @@ function(install_clr)
587587
get_symbol_file_name(${targetName} symbolFile)
588588
endif()
589589

590+
if (${INSTALL_CLR_OPTIONAL})
591+
set(INSTALL_CLR_OPTIONAL "OPTIONAL")
592+
else()
593+
set(INSTALL_CLR_OPTIONAL "")
594+
endif()
595+
590596
foreach(destination ${destinations})
591597
# We don't need to install the export libraries for our DLLs
592598
# since they won't be directly linked against.
593-
install(PROGRAMS $<TARGET_FILE:${targetName}> DESTINATION ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
599+
install(PROGRAMS $<TARGET_FILE:${targetName}> DESTINATION ${destination} COMPONENT ${INSTALL_CLR_COMPONENT} ${INSTALL_CLR_OPTIONAL})
594600
if (NOT "${symbolFile}" STREQUAL "")
595-
install_symbol_file(${symbolFile} ${destination} COMPONENT ${INSTALL_CLR_COMPONENT})
601+
install_symbol_file(${symbolFile} ${destination} COMPONENT ${INSTALL_CLR_COMPONENT} ${INSTALL_CLR_OPTIONAL})
596602
endif()
597603

598604
if(CLR_CMAKE_PGO_INSTRUMENT)

eng/pipelines/extra-platforms/runtime-extra-platforms-ioslikesimulator.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,37 @@ jobs:
133133
testBuildArgs: tree nativeaot/SmokeTests /p:BuildNativeAOTRuntimePack=true
134134
testRunNamePrefixSuffix: NativeAOT_$(_BuildConfig)
135135
buildAllTestsAsStandalone: true
136+
137+
#
138+
# iOS simulator
139+
# Build the whole product using CoreCLR and run functional tests
140+
#
141+
- template: /eng/pipelines/common/platform-matrix.yml
142+
parameters:
143+
jobTemplate: /eng/pipelines/common/global-build-job.yml
144+
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
145+
buildConfig: checked
146+
runtimeFlavor: coreclr
147+
isExtraPlatformsBuild: ${{ parameters.isExtraPlatformsBuild }}
148+
isiOSLikeSimulatorOnlyBuild: ${{ parameters.isiOSLikeSimulatorOnlyBuild }}
149+
platforms:
150+
- iossimulator_arm64
151+
variables:
152+
# map dependencies variables to local variables
153+
- name: librariesContainsChange
154+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
155+
- name: coreclrContainsChange
156+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_coreclr.containsChange'] ]
157+
- name: illinkContainsChange
158+
value: $[ stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_tools_illink.containsChange'] ]
159+
jobParameters:
160+
testGroup: innerloop
161+
nameSuffix: AllSubsets_CoreCLR
162+
buildArgs: -s clr+clr.runtime+libs+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=false /p:UseMonoRuntime=false /p:MonoForceInterpreter=false /p:RunSmokeTestsOnly=true
163+
timeoutInMinutes: 120
164+
# extra steps, run tests
165+
postBuildSteps:
166+
- template: /eng/pipelines/libraries/helix.yml
167+
parameters:
168+
creator: dotnet-bot
169+
testRunNamePrefixSuffix: CoreCLR_$(_BuildConfig)

src/coreclr/clrfeatures.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
22
set(FEATURE_JIT 1)
33
endif()
44

5+
if (CLR_CMAKE_TARGET_ARCH_WASM OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
6+
set(FEATURE_STATICALLY_LINKED 1)
7+
endif()
8+
59
if(CLR_CMAKE_TARGET_TIZEN_LINUX)
610
set(FEATURE_GDBJIT_LANGID_CS 1)
711
endif()

src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ if(FEATURE_PERFTRACING)
173173
endif(CLR_CMAKE_TARGET_LINUX)
174174
endif(FEATURE_PERFTRACING)
175175

176-
if(FEATURE_STATICALLY_LINKED)
177-
set(CLRJIT_STATIC clrjit_static)
176+
if (FEATURE_STATICALLY_LINKED)
177+
if (FEATURE_JIT)
178+
set(CLRJIT_STATIC clrjit_static gcinfo)
179+
endif(FEATURE_JIT)
180+
if (FEATURE_INTERPRETER)
181+
set(CLRINTERPRETER_STATIC clrinterpreter)
182+
endif(FEATURE_INTERPRETER)
178183
endif(FEATURE_STATICALLY_LINKED)
179184

180185
if(FEATURE_JIT)
@@ -192,7 +197,7 @@ if (CLR_CMAKE_TARGET_OSX)
192197
endif()
193198

194199
if(NOT CLR_CMAKE_HOST_ARCH_WASM)
195-
target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} cee_wks_core cee_wks ${FOUNDATION})
200+
target_link_libraries(coreclr PUBLIC ${CORECLR_LIBRARIES} ${CLRJIT_STATIC} ${CLRINTERPRETER_STATIC} cee_wks_core cee_wks ${FOUNDATION})
196201
endif(NOT CLR_CMAKE_HOST_ARCH_WASM)
197202

198203
target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} cee_wks_core ${CORECLR_STATIC_CLRJIT_STATIC} ${CEE_WKS_STATIC} ${FOUNDATION})

src/coreclr/interpreter/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ else()
4141
add_custom_target(interpreter_exports DEPENDS ${EXPORTS_FILE})
4242
endif()
4343

44-
if(CLR_CMAKE_TARGET_BROWSER)
44+
if(FEATURE_STATICALLY_LINKED AND NOT FEATURE_JIT)
4545
set(LIBRARY_TYPE STATIC)
4646
else()
4747
set(LIBRARY_TYPE SHARED)
4848
endif()
4949

5050
add_library_clr(clrinterpreter ${LIBRARY_TYPE} ${INTERPRETER_SOURCES})
5151

52+
set_target_properties(clrinterpreter PROPERTIES EXCLUDE_FROM_ALL $<NOT:${FEATURE_INTERPRETER}>)
53+
5254
add_dependencies(clrinterpreter interpreter_exports)
5355

5456
if(NOT CLR_CMAKE_HOST_WIN32)
@@ -63,4 +65,4 @@ target_link_libraries(clrinterpreter
6365

6466
set_property(TARGET clrinterpreter APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
6567

66-
install_clr(TARGETS clrinterpreter DESTINATIONS . COMPONENT runtime)
68+
install_clr(TARGETS clrinterpreter DESTINATIONS . sharedFramework COMPONENT runtime OPTIONAL)

src/coreclr/vm/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ endif(FEATURE_PERFTRACING)
4747
add_compile_definitions($<${FEATURE_CORECLR_CACHED_INTERFACE_DISPATCH}:FEATURE_CACHED_INTERFACE_DISPATCH>)
4848
add_compile_definitions($<${FEATURE_CORECLR_VIRTUAL_STUB_DISPATCH}:FEATURE_VIRTUAL_STUB_DISPATCH>)
4949

50-
if(CLR_CMAKE_TARGET_ARCH_WASM)
51-
add_compile_definitions(FEATURE_STATICALLY_LINKED)
52-
endif()
53-
5450
set(VM_SOURCES_DAC_AND_WKS_COMMON
5551
appdomain.cpp
5652
array.cpp

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
<PlatformManifestFileEntry Condition="'$(PgoInstrument)' != ''" Include="clrjit.pgd" IsNative="true" />
115115
<PlatformManifestFileEntry Include="libclrjit.so" IsNative="true" />
116116
<PlatformManifestFileEntry Include="libclrjit.dylib" IsNative="true" />
117+
<PlatformManifestFileEntry Condition="('$(RuntimeConfiguration)' == 'Debug' or '$(RuntimeConfiguration)' == 'Checked') and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64')" Include="libclrinterpreter.so" IsNative="true" />
118+
<PlatformManifestFileEntry Condition="('$(RuntimeConfiguration)' == 'Debug' or '$(RuntimeConfiguration)' == 'Checked') and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64')" Include="libclrinterpreter.dylib" IsNative="true" />
117119
<PlatformManifestFileEntry Include="mscordaccore.dll" IsNative="true" />
118120
<PlatformManifestFileEntry Include="libmscordaccore.so" IsNative="true" />
119121
<PlatformManifestFileEntry Include="libmscordaccore.dylib" IsNative="true" />

src/libraries/tests.proj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@
340340
<ProjectExclusions Include="$(RepoRoot)/src/tests/FunctionalTests/iOS/Device/LibraryMode/iOS.Device.LibraryMode.Test.csproj" />
341341
</ItemGroup>
342342

343+
<ItemGroup Condition="('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvossimulator') and '$(RuntimeFlavor)' == 'Mono' and '$(RunDisablediOSTests)' != 'true'">
344+
<ProjectExclusions Include="$(RepoRoot)\src\tests\FunctionalTests\iOS\Simulator\CoreCLR.Interpreter\*.Test.csproj" />
345+
</ItemGroup>
346+
343347
<ItemGroup Condition="'$(TargetOS)' == 'browser' and '$(RunDisabledWasmTests)' != 'true' and '$(RunAOTCompilation)' != 'true'">
344348
</ItemGroup>
345349

@@ -607,6 +611,11 @@
607611
<SmokeTestProject Include="$(RepoRoot)\src\tests\FunctionalTests\Android\Device_Emulator\JIT\*.Test.csproj"/>
608612
</ItemGroup>
609613

614+
<ItemGroup Condition="('$(TargetOS)' == 'iossimulator' or '$(TargetOS)' == 'tvossimulator') and '$(RuntimeFlavor)' == 'CoreCLR'">
615+
<SmokeTestProject Remove="@(SmokeTestProject)" />
616+
<SmokeTestProject Include="$(RepoRoot)\src\tests\FunctionalTests\iOS\Simulator\CoreCLR.Interpreter\*.Test.csproj"/>
617+
</ItemGroup>
618+
610619
<!--
611620
There is a decent number of hidden tests that fail with TestReadyToRun, and
612621
it's proven to be a neverending task to flush all of them at once. So, we will
@@ -689,7 +698,7 @@
689698
<ProjectReference Include="$(MSBuildThisFileDirectory)System.IO.Hashing\tests\System.IO.Hashing.Tests.csproj" />
690699
</ItemGroup>
691700

692-
<ItemGroup Condition="'$(ArchiveTests)' == 'true' and '$(RunSmokeTestsOnly)' != 'true' and '$(RunGrpcTestsOnly)' != 'true' and '$(TargetOS)' == 'iossimulator'">
701+
<ItemGroup Condition="'$(ArchiveTests)' == 'true' and '$(RunSmokeTestsOnly)' != 'true' and '$(RunGrpcTestsOnly)' != 'true' and '$(TargetOS)' == 'iossimulator' and '$(RuntimeFlavor)' == 'Mono'">
693702
<ProjectReference Include="$(RepoRoot)\src\tests\FunctionalTests\iOS\Simulator\**\*.Test.csproj"
694703
Exclude="@(ProjectExclusions)"
695704
BuildInParallel="false" />

src/mono/msbuild/apple/build/AppleBuild.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
EnableAppSandbox="$(EnableAppSandbox)"
323323
ExcludeFromAppDir="@(_ExcludeFromAppDir)"
324324
ExtraLinkerArguments="@(ExtraAppLinkerArgs)"
325+
EnvironmentVariables="@(EnvironmentVariables)"
325326
ForceAOT="$(RunAOTCompilation)"
326327
ForceInterpreter="$(MonoForceInterpreter)"
327328
GenerateCMakeProject="$(GenerateCMakeProject)"

src/tasks/AppleAppBuilder/AppleAppBuilder.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public string TargetOS
6363
[Required]
6464
public ITaskItem[] Assemblies { get; set; } = Array.Empty<ITaskItem>();
6565

66+
/// <summary>
67+
/// The set of environment variables
68+
/// </summary>
69+
public ITaskItem[] EnvironmentVariables { get; set; } = Array.Empty<ITaskItem>();
70+
6671
/// <summary>
6772
/// Additional linker arguments that apply to the app being built
6873
/// </summary>
@@ -315,6 +320,12 @@ public override bool Execute()
315320
assemblerFilesToLink.Add(nativeDependency);
316321
}
317322

323+
List<string> environmentVariables = new List<string>();
324+
foreach (ITaskItem item in EnvironmentVariables)
325+
{
326+
environmentVariables.Add(item.ItemSpec);
327+
}
328+
318329
List<string> extraLinkerArgs = new List<string>();
319330
foreach (ITaskItem item in ExtraLinkerArguments)
320331
{
@@ -339,7 +350,7 @@ public override bool Execute()
339350
if (GenerateXcodeProject)
340351
{
341352
XcodeProjectPath = generator.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, extraLinkerArgs, excludes,
342-
AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, targetRuntime, IsLibraryMode);
353+
AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, environmentVariables, NativeMainSource, targetRuntime, IsLibraryMode);
343354

344355
if (BuildAppBundle)
345356
{
@@ -365,7 +376,7 @@ public override bool Execute()
365376
else if (GenerateCMakeProject)
366377
{
367378
generator.GenerateCMake(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, extraLinkerArgs, excludes,
368-
AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, targetRuntime, IsLibraryMode);
379+
AppDir, binDir, MonoRuntimeHeaders, !shouldStaticLink, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, HybridGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, environmentVariables, NativeMainSource, targetRuntime, IsLibraryMode);
369380
}
370381

371382
return true;

0 commit comments

Comments
 (0)