From ee99e9c9a4e865db7a1ee70eae9d4f64c15088c4 Mon Sep 17 00:00:00 2001 From: imhameed Date: Mon, 13 Jul 2020 21:05:44 -0700 Subject: [PATCH] Run CoreCLR runtime tests using Mono with LLVM AOT. (#38547) - coreclr/build-test.sh now has a new subcommand: 'mono_aot', which builds a new target, named 'MonoAotCompileTests', added to coreclr/tests/src/runtest.proj. This target compiles the runtime tests using Mono LLVM AOT in a simple configuration where the host platform is identical to the target platform. Parallel compilation happens via a hack: actual compilation happens in mono/msbuild/aot-compile.proj, a single-target msbuild file, and runtest.proj invokes this single-purpose project and target using batching to create multiple parallelizable instances of this project. Future work: use the MonoAOTCompiler custom task currently used to build the iOS sample program. - Avoid using the runtimeVariant string when defining coreClrProductArtifactName in mono/templates/xplat-pipeline-job.yml. There are no "runtime variants" of CoreCLR configured with this parameter; instead, depend on a shared non-runtime-variant build of CoreCLR. - Mark function DISubprograms as local definitions--this is an LLVM 9 compatibility fix. - Use --tag=CXX when linking libmonosgen-2.0.so via libtool when LLVM is linked into Mono. This makes libtool use the C++ compiler driver when linking Mono--which uses whatever platform-specific flags are necessary to link against the C++ stdlib. Previously, libtool would use the C compiler driver, which didn't do this and would produce shared objects with no explicit dependency on libstdc++. This problem is normally masked because of the very lax dynamic linking semantics on ELF, but Mono on our CI setup is built in a CentOS 7 image (which does not contain a C++11 libstdc++) that has a GCC 7 compatibility package installed, along with a clang 9 installation that detects headers from the GCC 7 compatibility package. This compatibility package includes a libstdc++ linker script that links C++11 libstdc++ components statically into the target while dynamically linking against components present in pre-C++11 libstdc++. The end result of all of this is that Mono built with this configuration will dynamically depend on C++11 libstdc++ symbols that should have been statically linked into the library, and will outright fail to run on machines without a newer version of libstdc++ available. - Add tests that fail after LLVM AOT compilation to issues.targets. --- .../templates/runtimes/run-test-job.yml | 4 + .../mono/templates/xplat-pipeline-job.yml | 2 +- eng/pipelines/runtime.yml | 48 +++++++++- src/coreclr/build-test.sh | 24 ++++- src/coreclr/tests/issues.targets | 89 +++++++++++++++++++ src/coreclr/tests/src/runtest.proj | 36 ++++++++ src/mono/configure.ac | 2 + src/mono/mono/mini/Makefile.am.in | 1 + src/mono/mono/mini/mini-llvm-cpp.cpp | 4 +- src/mono/msbuild/aot-compile.proj | 6 ++ 10 files changed, 210 insertions(+), 6 deletions(-) create mode 100644 src/mono/msbuild/aot-compile.proj diff --git a/eng/pipelines/common/templates/runtimes/run-test-job.yml b/eng/pipelines/common/templates/runtimes/run-test-job.yml index 4a89ea975bd..39616a833b0 100644 --- a/eng/pipelines/common/templates/runtimes/run-test-job.yml +++ b/eng/pipelines/common/templates/runtimes/run-test-job.yml @@ -268,6 +268,10 @@ jobs: /p:TargetArchitecture=$(archType) displayName: "Patch dotnet with mono" + - ${{ if and(eq(parameters.runtimeFlavor, 'mono'), eq(parameters.runtimeVariant, 'llvmaot')) }}: + - script: $(coreClrRepoRootDir)build-test$(scriptExt) mono_aot $(buildConfig) + displayName: "LLVM AOT compile CoreCLR tests" + # Send tests to Helix - template: /eng/pipelines/common/templates/runtimes/send-to-helix-step.yml parameters: diff --git a/eng/pipelines/mono/templates/xplat-pipeline-job.yml b/eng/pipelines/mono/templates/xplat-pipeline-job.yml index 364616643e8..89917a58e0b 100644 --- a/eng/pipelines/mono/templates/xplat-pipeline-job.yml +++ b/eng/pipelines/mono/templates/xplat-pipeline-job.yml @@ -48,7 +48,7 @@ jobs: variables: - name: coreClrProductArtifactName - value: 'CoreCLRProduct_${{ parameters.runtimeVariant }}_$(osGroup)$(osSubgroup)_$(archType)_${{ parameters.liveRuntimeBuildConfig }}' + value: 'CoreCLRProduct__$(osGroup)$(osSubgroup)_$(archType)_${{ parameters.liveRuntimeBuildConfig }}' - name: coreClrProductRootFolderPath value: '$(Build.SourcesDirectory)/artifacts/bin/coreclr/$(osGroup).$(archType).$(liveRuntimeBuildConfigUpper)' diff --git a/eng/pipelines/runtime.yml b/eng/pipelines/runtime.yml index 32d7dc0e686..10f5a74afc3 100644 --- a/eng/pipelines/runtime.yml +++ b/eng/pipelines/runtime.yml @@ -159,7 +159,7 @@ jobs: # # Build CoreCLR checked using GCC toolchain # Only when CoreCLR is changed -# +# - template: /eng/pipelines/common/platform-matrix.yml parameters: jobTemplate: /eng/pipelines/coreclr/templates/build-job.yml @@ -250,7 +250,7 @@ jobs: or( eq(dependencies.checkout.outputs['SetPathVars_coreclr.containsChange'], true), eq(variables['isFullMatrix'], true)) - + # Build the whole product using Mono runtime # Only when libraries, mono or installer are changed # @@ -479,6 +479,25 @@ jobs: eq(dependencies.checkout.outputs['SetPathVars_mono.containsChange'], true), eq(variables['isFullMatrix'], true)) +# +# Build Mono release with LLVM AOT +# Only when mono, or the runtime tests changed +# +- template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/mono/templates/build-job.yml + runtimeFlavor: mono + buildConfig: release + platforms: + - Linux_x64 + jobParameters: + runtimeVariant: llvmaot + condition: >- + or( + eq(dependencies.checkout.outputs['SetPathVars_runtimetests.containsChange'], true), + eq(dependencies.checkout.outputs['SetPathVars_mono.containsChange'], true), + eq(variables['isFullMatrix'], true)) + # # Build libraries using live CoreLib # These set of libraries are built always no matter what changed @@ -613,7 +632,7 @@ jobs: isOfficialBuild: false liveRuntimeBuildConfig: release testScope: innerloop - condition: >- + condition: >- or( eq(dependencies.checkout.outputs['SetPathVars_libraries.containsChange'], true), eq(dependencies.checkout.outputs['SetPathVars_coreclr.containsChange'], true), @@ -745,6 +764,29 @@ jobs: eq(dependencies.checkout.outputs['SetPathVars_mono.containsChange'], true), eq(dependencies.checkout.outputs['SetPathVars_runtimetests.containsChange'], true), eq(variables['isFullMatrix'], true)) +# +# Mono CoreCLR runtime Test executions using live libraries and LLVM AOT +# Only when Mono is changed +# +- template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/templates/runtimes/run-test-job.yml + buildConfig: release + runtimeFlavor: mono + platforms: + - Linux_x64 + helixQueueGroup: pr + helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml + jobParameters: + testGroup: innerloop + liveLibrariesBuildConfig: ${{ variables.debugOnPrReleaseOnRolling }} + liveRuntimeBuildConfig: release + runtimeVariant: llvmaot + condition: >- + or( + eq(dependencies.checkout.outputs['SetPathVars_mono.containsChange'], true), + eq(dependencies.checkout.outputs['SetPathVars_runtimetests.containsChange'], true), + eq(variables['isFullMatrix'], true)) # # Libraries Release Test Execution against a release mono runtime. diff --git a/src/coreclr/build-test.sh b/src/coreclr/build-test.sh index 2de59c68c06..f1a26c565e3 100755 --- a/src/coreclr/build-test.sh +++ b/src/coreclr/build-test.sh @@ -47,6 +47,18 @@ build_test_wrappers() fi } +build_mono_aot() +{ + __RuntimeFlavor="mono" + __MonoBinDir="$__RootBinDir/bin/mono/$__TargetOS.$__BuildArch.$__BuildType" + __Exclude="${__ProjectDir}/tests/issues.targets" + __TestBinDir="$__TestWorkingDir" + CORE_ROOT="$__TestBinDir"/Tests/Core_Root + export __Exclude + export CORE_ROOT + build_MSBuild_projects "Tests_MonoAot" "$__ProjectDir/tests/src/runtest.proj" "Mono AOT compile tests" "/t:MonoAotCompileTests" "/p:RuntimeFlavor=$__RuntimeFlavor" "/p:MonoLlvmPath=$__MonoBinDir" +} + generate_layout() { echo "${__MsgPrefix}Creating test overlay..." @@ -608,6 +620,12 @@ handle_arguments_local() { excludemonofailures|-excludemonofailures) __Mono=1 ;; + + mono_aot|-mono_aot) + __Mono=1 + __MonoAot=1 + ;; + *) __UnprocessedBuildArgs+=("$1") ;; @@ -661,6 +679,8 @@ __UseNinja=0 __VerboseBuild=0 __CMakeArgs="" __priority1= +__Mono=0 +__MonoAot=0 CORE_ROOT= source "$__ProjectRoot"/_build-commons.sh @@ -703,10 +723,12 @@ if [[ -z "$HOME" ]]; then echo "HOME not defined; setting it to $HOME" fi -if [[ (-z "$__GenerateLayoutOnly") && (-z "$__BuildTestWrappersOnly") ]]; then +if [[ (-z "$__GenerateLayoutOnly") && (-z "$__BuildTestWrappersOnly") && ("$__MonoAot" -eq 0) ]]; then build_Tests elif [[ ! -z "$__BuildTestWrappersOnly" ]]; then build_test_wrappers +elif [[ "$__MonoAot" -eq 1 ]]; then + build_mono_aot else generate_layout fi diff --git a/src/coreclr/tests/issues.targets b/src/coreclr/tests/issues.targets index e42c969e4a1..eb1f6be60e8 100644 --- a/src/coreclr/tests/issues.targets +++ b/src/coreclr/tests/issues.targets @@ -984,6 +984,95 @@ + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + Crashes during LLVM AOT compilation. + + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + + Doesn't pass after LLVM AOT compilation. + + PlatformDetection.IsPreciseGcSupported false on mono diff --git a/src/coreclr/tests/src/runtest.proj b/src/coreclr/tests/src/runtest.proj index adc7433ebd9..f4d3e4b8857 100644 --- a/src/coreclr/tests/src/runtest.proj +++ b/src/coreclr/tests/src/runtest.proj @@ -348,6 +348,37 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). + + + + + + + + + + $(CORE_ROOT)\corerun + $(CORE_ROOT)\corerun.exe + + + + + + @(AotEnvVar) + + + + _CorerunExecutable=$(CorerunExecutable);_TestDll=%(TestDlls.Identity);AotEnvVars=@(AotEnvVar) + + + + + @@ -374,6 +405,11 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). + + createFile (file, dir); type = builder->createSubroutineType (builder->getOrCreateTypeArray (ArrayRef ())); #if LLVM_API_VERSION >= 900 - di_func = builder->createFunction (di_file, name, mangled_name, di_file, line, type, 0); + di_func = builder->createFunction ( + di_file, name, mangled_name, di_file, line, type, 0, + DINode::FlagZero, DISubprogram::SPFlagDefinition | DISubprogram::SPFlagLocalToUnit); #else di_func = builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0); #endif diff --git a/src/mono/msbuild/aot-compile.proj b/src/mono/msbuild/aot-compile.proj new file mode 100644 index 00000000000..2bceabf0c57 --- /dev/null +++ b/src/mono/msbuild/aot-compile.proj @@ -0,0 +1,6 @@ + + + + + + -- 2.34.1