Skip to content

Commit

Permalink
source-build: bundle NativeAOT libraries with the SDK. (#41198)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmds authored Jun 19, 2024
1 parent 18d85d9 commit f3ebfb5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Installer/redist-installer/redist-installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<ResolveAssemblyReferencesSilent>true</ResolveAssemblyReferencesSilent>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>none</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<BundleRuntimePacks Condition="'$(BundleRuntimePacks)' == '' and '$(DotNetBuildSourceOnly)' == 'true'">true</BundleRuntimePacks>
<BundleNativeAotCompiler Condition="'$(BundleNativeAotCompiler)' == '' and '$(DotNetBuildSourceOnly)' == 'true' and '$(SourceBuildUseMonoRuntime)' != 'true'">true</BundleNativeAotCompiler>
<!-- DotNetBuildOrchestrator is (currently) needed in order to obtain NuGet packages from the runtime build. -->
<BundleNativeAotCompiler Condition="'$(BundleNativeAotCompiler)' == '' and '$(DotNetBuildSourceOnly)' == 'true' and '$(SourceBuildUseMonoRuntime)' != 'true' and '$(DotNetBuildOrchestrator)' == 'true'">true</BundleNativeAotCompiler>
</PropertyGroup>

<ItemGroup>
Expand Down
16 changes: 16 additions & 0 deletions src/Installer/redist-installer/targets/GenerateLayout.targets
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@
<RelativeLayoutPath>packs/%(PackageName)/%(PackageVersion)</RelativeLayoutPath>
</BundledLayoutPackage>

<BundledLayoutPackage Include="MicrosoftDotNetILCompilerPackNupkg" Condition="'$(BundleNativeAotCompiler)' == 'true'">
<PackageName>runtime.$(SharedFrameworkRid).Microsoft.DotNet.ILCompiler</PackageName>
<PackageVersion>$(MicrosoftNETCoreAppRuntimePackageVersion)</PackageVersion>
<TargetFramework>$(TargetFramework)</TargetFramework>
<RelativeLayoutPath>packs/%(PackageName)/%(PackageVersion)</RelativeLayoutPath>
</BundledLayoutPackage>

<BundledLayoutLibraryPackage Include="$(SourceBuiltShippingPackagesDir)/../runtime/Microsoft.DotNet.ILCompiler.$(MicrosoftNETCoreAppRuntimePackageVersion).nupkg" Condition="'$(BundleNativeAotCompiler)' == 'true'" />

<BundledLayoutLibraryPackage Include="$(SourceBuiltShippingPackagesDir)/../runtime/Microsoft.NET.ILLink.Tasks.$(MicrosoftNETILLinkTasksPackageVersion).nupkg" Condition="'$(BundleNativeAotCompiler)' == 'true'" />

<BundledInstallerComponent Include="DownloadedRuntimeDepsInstallerFile"
Condition="('$(IsDebianBaseDistro)' == 'true' OR '$(IsRPMBasedDistro)' == 'true') And '$(SkipBuildingInstallers)' != 'true' And '$(InstallerExtension)' != '' And !$(Architecture.StartsWith('arm'))">
<BaseUrl>$(NetRuntimeRootUrl)</BaseUrl>
Expand Down Expand Up @@ -460,6 +471,11 @@
SkipUnchangedFiles="true"
/>

<Copy SourceFiles="@(BundledLayoutLibraryPackage)"
DestinationFolder="$(RedistLayoutPath)/library-packs"
SkipUnchangedFiles="true"
/>

<!-- From Version.targets in SDK redist -->
<PropertyGroup>
<ArtifactNameSdk>dotnet-toolset-internal</ArtifactNameSdk>
Expand Down
2 changes: 2 additions & 0 deletions src/SourceBuild/content/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ targets="/t:Build"
if [[ "$test" == true ]]; then
project="$scriptroot/test/tests.proj"
targets="$targets;VSTest"
# Workaround for vstest hangs (https://github.com/microsoft/vstest/issues/5091) [TODO]
export MSBUILDENSURESTDOUTFORTASKPROCESSES=1
fi

function Build {
Expand Down
2 changes: 2 additions & 0 deletions src/SourceBuild/content/eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ $targets = "/t:Build"
if ($test) {
$project = Join-Path (Join-Path $RepoRoot "test") "tests.proj"
$targets += ";VSTest"
# Workaround for vstest hangs (https://github.com/microsoft/vstest/issues/5091) [TODO]
$env:MSBUILDENSURESTDOUTFORTASKPROCESSES="1"
}

if ($buildRepoTests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void SourceBuiltSdkContainsNativeDebugSymbols()
StringBuilder issueDetails = new();
foreach (var fileName in fileNames)
{
if (!IsElfFile(fileName))
if (!IsElfFile(fileName) || SkipFile(fileName))
{
continue;
}
Expand Down Expand Up @@ -70,6 +70,14 @@ private bool IsElfFile(string fileName)
return Regex.IsMatch(fileStdOut, @"ELF 64-bit [LM]SB (?:pie )?(?:executable|shared object)");
}

private static bool SkipFile(string path)
{
string fileName = Path.GetFileName(path);

// 'ilc' is a NativeAOT-built application which doesn't meet the expectations set by the test.
return fileName == "ilc";
}

private ScanResult ScanFile(string fileName)
{
string readelfSStdOut = ExecuteHelper.ExecuteProcessValidateExitCode("eu-readelf", $"-S {fileName}", OutputHelper);
Expand Down
15 changes: 10 additions & 5 deletions src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -788,17 +788,22 @@ private ToolPackSupport AddToolPack(

var runtimePackName = packNamePattern.Replace("**RID**", hostRuntimeIdentifier);

if (EnableRuntimePackDownload)
var runtimePackItem = new TaskItem(runtimePackName);
runtimePackItem.SetMetadata(MetadataKeys.NuGetPackageId, runtimePackName);
runtimePackItem.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);

string runtimePackPath = GetPackPath(runtimePackName, packVersion);
if (runtimePackPath != null)
{
runtimePackItem.SetMetadata(MetadataKeys.PackageDirectory, runtimePackPath);
}
else if (EnableRuntimePackDownload)
{
// We need to download the runtime pack
runtimePackToDownload = new TaskItem(runtimePackName);
runtimePackToDownload.SetMetadata(MetadataKeys.Version, packVersion);
}

var runtimePackItem = new TaskItem(runtimePackName);
runtimePackItem.SetMetadata(MetadataKeys.NuGetPackageId, runtimePackName);
runtimePackItem.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);

switch (toolPackType)
{
case ToolPackType.Crossgen2:
Expand Down

0 comments on commit f3ebfb5

Please sign in to comment.