Skip to content
Closed
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
19 changes: 19 additions & 0 deletions eng/illink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,25 @@
<ILLinkArgs>$(ILLinkArgs) --disable-opt unusedinterfaces</ILLinkArgs>
<!-- keep DynamicDependencyAttribute unless a project explicitly disables it -->
<ILLinkArgs Condition="'$(ILLinkKeepDepAttributes)' != 'false'">$(ILLinkArgs) --keep-dep-attributes true</ILLinkArgs>
<!-- enable verbose output -->
<ILLinkArgs>$(ILLinkArgs) --verbose</ILLinkArgs>
<!-- suprress warnings with the following codes:
IL2006: The generic parameter 'T' from A with dynamically accessed member kinds B is passed into the generic parameter
'T' from 'System.Lazy<T>' which requires dynamically accessed member kinds 'PublicParameterlessConstructor'
IL2008: Could not find type A specified in resource B
IL2009: Could not find method A in type B specified in resource C
IL2012: Could not find field A in type B specified in resource C
IL2025: Duplicate preserve of" warnings from verbose output,
as we need both linker annotations and xml files
IL2026: Calling A which has B can break functionality when trimming application code. The target method might be removed.
IL2035: Unresolved assembly A in DynamicDependencyAttribute on B
IL2041: The DynamicallyAccessedMembersAttribute is only allowed on method parameters, return value or generic parameters.
IL2047: All overridden members must have the same DynamicallyAccessedMembersAttribute,
usage as we don't add suppression files for ref projects
IL2050: P/invoke method A declares a parameter with COM marshalling. Correctness of COM interop cannot be guaranteed after trimming.
Interfaces and interface members might be removed
-->
<ILLinkArgs>$(ILLinkArgs) --nowarn IL1001;IL2006;IL2008;IL2009;IL2012;IL2025;IL2026;IL2035;IL2041;IL2047;IL2050</ILLinkArgs>
</PropertyGroup>

<MakeDir Directories="$(ILLinkTrimInputPath)" />
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
</ItemGroup>

<PropertyGroup>
<_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">crossgen-corelib.cmd</_CoreClrBuildScript>
<_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">crossgen-corelib.sh</_CoreClrBuildScript>
<_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(TargetOs)' == 'Windows_NT'">crossgen-corelib.cmd</_CoreClrBuildScript>
<_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(TargetOs)' != 'Windows_NT'">crossgen-corelib.sh</_CoreClrBuildScript>
</PropertyGroup>

<!-- Use IgnoreStandardErrorWarningFormat because Arcade sets WarnAsError and there's an existing warning in the native build. -->
<Exec Command="&quot;$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)&quot; @(_CoreClrBuildArg->'%(Identity)',' ')" />
<Exec Condition="'$(_CoreClrBuildScript)' != ''" Command="&quot;$(MSBuildThisFileDirectory)$(_CoreClrBuildScript)&quot; @(_CoreClrBuildArg->'%(Identity)',' ')" />
</Target>

<Target Name="Restore" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageTargetWindows Condition="'$(OS)' == 'Windows_NT' and '$(TargetOs)' == 'Windows_NT'">true</PackageTargetWindows>
<PackageTargetWindows Condition="'$(OS)' == 'Windows_NT' and '$(TargetOs)' == ''">true</PackageTargetWindows>
</PropertyGroup>

<Import Condition="'$(PackageTargetWindows)' == 'true'" Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />

<PropertyGroup Condition="'$(PackageTargetRuntime)' == ''">
<IsLineupPackage Condition="'$(IsLineupPackage)' == ''">true</IsLineupPackage>
Expand All @@ -11,5 +16,8 @@
<NativeBinary Include="$(BinDir)ilasm$(ApplicationFileExtension)" />
</ItemGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
<Import Condition="'$(PackageTargetWindows)' == 'true'" Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />

<!-- Avoid "There is no target in the project" error. -->
<Target Condition="'$(PackageTargetWindows)' == 'false'" Name="Empty" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: What does ildasm packaging has to do with linker?

<PropertyGroup>
<PackageTargetWindows Condition="'$(OS)' == 'Windows_NT' and '$(TargetOs)' == 'Windows_NT'">true</PackageTargetWindows>
<PackageTargetWindows Condition="'$(OS)' == 'Windows_NT' and '$(TargetOs)' == ''">true</PackageTargetWindows>
</PropertyGroup>

<Import Condition="'$(PackageTargetWindows)' == 'true'" Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />

<PropertyGroup Condition="'$(PackageTargetRuntime)' == ''">
<IsLineupPackage Condition="'$(IsLineupPackage)' == ''">true</IsLineupPackage>
Expand All @@ -11,5 +16,8 @@
<NativeBinary Include="$(BinDir)ildasm$(ApplicationFileExtension)" />
</ItemGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
<Import Condition="'$(PackageTargetWindows)' == 'true'" Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />

<!-- Avoid "There is no target in the project" error. -->
<Target Condition="'$(PackageTargetWindows)' == ''" Name="Empty" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageTargetWindows Condition="'$(OS)' == 'Windows_NT' and '$(TargetOs)' == ''">true</PackageTargetWindows>
<PackageTargetWindows Condition="'$(OS)' == 'Windows_NT' and '$(TargetOs)' == 'Windows_NT'">true</PackageTargetWindows>
</PropertyGroup>

<Import Condition="'$(PackageTargetWindows)' == 'true'" Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />

<PropertyGroup Condition="'$(PackageTargetRuntime)' == ''">
<IsLineupPackage Condition="'$(IsLineupPackage)' == ''">true</IsLineupPackage>
Expand All @@ -11,5 +16,8 @@
<NativeBinary Include="$(BinDir)corerun$(ApplicationFileExtension)" />
</ItemGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
<Import Condition="'$(PackageTargetWindows)' == 'true'" Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />

<!-- Avoid "There is no target in the project" error. -->
<Target Condition="'$(PackageTargetWindows)' == ''" Name="Empty" />
</Project>
2 changes: 2 additions & 0 deletions src/coreclr/src/tools/aot/crossgen2/CommandLineOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if SHOULD_RUN_CROSSGEN

@jkotas jkotas Jul 29, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this change need to be touching crossgen2? I would expect that we will run the linker analysis for libraries only.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to avoid the warnings (samples shown below) I was seeing locally relating to crossgen/crossgen2 and other projects changed in this PR by enabling verbose output on only libraries (i.e not mono/corelib System.Private.CoreLib). These warnings motivated most of the changes in this PR.

CROSSGEN-CORELIB : error : CrossGen System.Private.CoreLib build failed. Refer to D:\repos\dotnet_runtime\src\coreclr\..\..\artifacts\log\CrossgenCoreLib_Windows_NT__x64__Release.log [D:\repos\dotnet_runtime\src\coreclr\crossgen-corelib.proj]
EXEC : error : file "D:\repos\dotnet_runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\IL\System.Private.CoreLib.dll" or one of its dependencies was not found [D:\repos\dotnet_runtime\src\coreclr\crossgen-corelib.proj]
EXEC : error : Error enumerating files under D:\repos\dotnet_runtime\src\coreclr\..\..\artifacts\bin\coreclr\Windows_NT.x64.Release\IL\. [D:\repos\dotnet_runtime\src\coreclr\crossgen-corelib.proj]
D:\repos\dotnet_runtime\src\coreclr\crossgen-corelib.proj(20,5): error MSB3073: The command ""D:\repos\dotnet_runtime\src\coreclr\crossgen-corelib.cmd" -x64 -release" exited with code 1.

D:\repos\dotnet_runtime\.dotnet\sdk\5.0.100-preview.8.20362.3\Microsoft.Common.CurrentVersion.targets(4651,5): error MSB3030: Could not copy the file "D:\repos\dotnet_runtime\artifacts\bin\coreclr\OSX.x64.Release\clrjit.dll" because it was not found. [D:\repos\dotnet_runtime\src\coreclr\src\tools\aot\crossgen2\crossgen2.csproj]
D:\repos\dotnet_runtime\.dotnet\sdk\5.0.100-preview.8.20362.3\Microsoft.Common.CurrentVersion.targets(4651,5): error MSB3030: Could not copy the file "D:\repos\dotnet_runtime\artifacts\bin\coreclr\OSX.x64.Release\jitinterface.dll" because it was not found. [D:\repos\dotnet_runtime\src\coreclr\src\tools\aot\crossgen2\crossgen2.csproj]

using System;
using System.CommandLine;
using System.IO;
Expand Down Expand Up @@ -206,3 +207,4 @@ public static Command RootCommand()
}
}
}
#endif
12 changes: 12 additions & 0 deletions src/coreclr/src/tools/aot/crossgen2/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#if SHOULD_RUN_CROSSGEN
using System;
using System.Collections.Generic;
using System.CommandLine;
Expand Down Expand Up @@ -664,3 +665,14 @@ private static int InnerMain(CommandLineOptions buildOptions)
}
}
}
#else
namespace ILCompiler
{
internal class Program
{
public static void Main(string[] args)
{
}
}
}
#endif
92 changes: 51 additions & 41 deletions src/coreclr/src/tools/aot/crossgen2/crossgen2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,6 @@
<Configurations>Debug;Release;Checked</Configurations>
</PropertyGroup>

<ItemGroup Label="Embedded Resources">
<EmbeddedResource Include="Properties\Resources.resx">
<GenerateSource>true</GenerateSource>
<ClassName>System.SR</ClassName>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ILCompiler.DependencyAnalysisFramework\ILCompiler.DependencyAnalysisFramework.csproj" />
<ProjectReference Include="..\ILCompiler.TypeSystem.ReadyToRun\ILCompiler.TypeSystem.ReadyToRun.csproj" />
<ProjectReference Include="..\ILCompiler.ReadyToRun\ILCompiler.ReadyToRun.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Common\CommandLine\CommandLineException.cs" />
<Compile Include="..\..\Common\CommandLine\CommandLineHelpers.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine">
<Version>$(SystemCommandLineVersion)</Version>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<CrossHostArch></CrossHostArch>
<CrossHostArch Condition="'$(TargetArchitecture)' == 'arm64' and '$(BuildArchitecture)' == 'x64'">x64</CrossHostArch>
Expand All @@ -55,23 +31,57 @@
<LibraryNameExtension Condition="$([MSBuild]::IsOsPlatform('OSX'))">.dylib</LibraryNameExtension>

<JitInterfaceLibraryName>$(LibraryNamePrefix)jitinterface$(LibraryNameExtension)</JitInterfaceLibraryName>
</PropertyGroup>

<ItemGroup>
<Content Include="$(BinDir)\$(JitInterfaceLibraryName)"
CopyToOutputDirectory="PreserveNewest"
CopyToPublishDirectory="PreserveNewest"
Link="%(FileName)%(Extension)"
/>

<Content Include="$(BinDir)\$(NativeArchFolder)$(LibraryNamePrefix)clrjit$(LibraryNameExtension)"
CopyToOutputDirectory="PreserveNewest"
CopyToPublishDirectory="PreserveNewest"
Link="$(LibraryNamePrefix)clrjit-$(TargetSpec)$(LibraryNameExtension)"
/>
</ItemGroup>
<ShouldRunCrossGen Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(TargetOs)' == 'Windows_NT'">true</ShouldRunCrossGen>
<ShouldRunCrossGen Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(TargetOs)' != 'Windows_NT'">true</ShouldRunCrossGen>
<DefineConstants Condition="'$(ShouldRunCrossGen)' == 'true'">$(DefineConstants);SHOULD_RUN_CROSSGEN</DefineConstants>
</PropertyGroup>

<Target Name="CreateCrossTargetingPackage" AfterTargets="Build" Condition="'$(CrossHostArch)' != ''">
<Choose>
<When Condition="'$(ShouldRunCrossGen)' == 'true'">

<ItemGroup Label="Embedded Resources">
<EmbeddedResource Include="Properties\Resources.resx">
<GenerateSource>true</GenerateSource>
<ClassName>System.SR</ClassName>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ILCompiler.DependencyAnalysisFramework\ILCompiler.DependencyAnalysisFramework.csproj" />
<ProjectReference Include="..\ILCompiler.TypeSystem.ReadyToRun\ILCompiler.TypeSystem.ReadyToRun.csproj" />
<ProjectReference Include="..\ILCompiler.ReadyToRun\ILCompiler.ReadyToRun.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Common\CommandLine\CommandLineException.cs" />
<Compile Include="..\..\Common\CommandLine\CommandLineHelpers.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine">
<Version>$(SystemCommandLineVersion)</Version>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Content Include="$(BinDir)\$(JitInterfaceLibraryName)"
CopyToOutputDirectory="PreserveNewest"
CopyToPublishDirectory="PreserveNewest"
Link="%(FileName)%(Extension)"
/>

<Content Include="$(BinDir)\$(NativeArchFolder)$(LibraryNamePrefix)clrjit$(LibraryNameExtension)"
CopyToOutputDirectory="PreserveNewest"
CopyToPublishDirectory="PreserveNewest"
Link="$(LibraryNamePrefix)clrjit-$(TargetSpec)$(LibraryNameExtension)"
/>
</ItemGroup>

</When>
</Choose>

<Target Name="CreateCrossTargetingPackage" AfterTargets="Build" Condition="'$(CrossHostArch)' != '' and '$(ShouldRunCrossGen)' == 'true'">

<PropertyGroup>
<CrossPackageFolder>$(BinDir)\$(CrossHostArch)\crossgen2</CrossPackageFolder>
Expand All @@ -98,9 +108,9 @@

</Target>

<Target Name="GenerateDepsJsonFile" Returns="$(ProjectDepsFilePath)" DependsOnTargets="GenerateBuildDependencyFile" />
<Target Name="GenerateDepsJsonFile" Returns="$(ProjectDepsFilePath)" DependsOnTargets="GenerateBuildDependencyFile" Condition="'$(ShouldRunCrossGen)' == 'true'" />

<Target Name="RemoveUnusedFilesFromDepsJson" AfterTargets="ResolveRuntimePackAssets" BeforeTargets="GenerateBuildDependencyFile">
<Target Name="RemoveUnusedFilesFromDepsJson" AfterTargets="ResolveRuntimePackAssets" BeforeTargets="GenerateBuildDependencyFile" Condition="'$(ShouldRunCrossGen)' == 'true'">
<PropertyGroup>
<StaticLibraryFileExtension>.a</StaticLibraryFileExtension>
<StaticLibraryFileExtension Condition="'$(TargetOS)' == 'Windows_NT'">.lib</StaticLibraryFileExtension>
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Native/build-native.proj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<Target Name="BuildNativeUnix"
BeforeTargets="Build"
Condition="'$(TargetOS)' != 'Windows_NT'">
Condition="'$(TargetOS)' != 'Windows_NT' and '$(OS)' != 'Windows_NT'">
<PropertyGroup>
<!--
MSBuildNodeCount should a good approximation for how many procs to use for native build, if we find that doesn't work
Expand Down
13 changes: 11 additions & 2 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<ScriptExt Condition="'$(OS)' != 'Windows_NT'">.sh</ScriptExt>
<CoreClrFileName Condition="'$(TargetsWindows)' == 'true'">coreclr.dll</CoreClrFileName>
<CoreClrFileName Condition="'$(TargetsOSX)' == 'true'">libcoreclr.dylib</CoreClrFileName>
<CoreClrFileName Condition="'$(CoreClrFileName)' == ''">libcoreclr.so</CoreClrFileName>
<CoreClrFileName Condition="'$(TargetsOSX)' == 'true' and '$(OS)' == 'Windows_NT'">coreclr.dll</CoreClrFileName>
<!-- <CoreClrFileName Condition="'$(CoreClrFileName)' == ''">libcoreclr.so</CoreClrFileName> -->
<MonoFileName Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">libmonosgen-2.0.dylib</MonoFileName>
<MonoFileName Condition="'$(TargetsAndroid)' == 'true'">libmonosgen-2.0.so</MonoFileName>
<MonoFileName Condition="'$(TargetsBrowser)' == 'true'">libmonosgen-2.0.a</MonoFileName>
Expand Down Expand Up @@ -943,6 +944,10 @@
<_MonoRuntimeFilePath Condition="'$(TargetstvOS)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.dylib</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsAndroid)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.so</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsBrowser)' == 'true'">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.a</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsBrowser)' == 'true'">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.a</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsLinux)' == 'true' and '$(OS)' == 'Windows_NT' and '$(Platform)' == 'x64'">$(MonoObjDir)x64\Bin\$(Configuration)\mono-2.0-sgen.dll</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsOSX)' == 'true' and '$(OS)' == 'Windows_NT' and '$(Platform)' == 'x64'">$(MonoObjDir)x64\Bin\$(Configuration)\mono-2.0-sgen.dll</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(TargetsLinux)' == 'true' and '$(OS)' == 'OSX'">$(MonoObjDir)out\lib\libmonosgen-2.0.dylib</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.so</_MonoRuntimeFilePath>
<_MonoRuntimeStaticFilePath Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.a</_MonoRuntimeStaticFilePath>
<_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'arm64'">$(MonoObjDir)cross\out\bin\aarch64-apple-darwin10-mono-sgen</_MonoAotCrossFilePath>
Expand Down Expand Up @@ -1001,7 +1006,11 @@
SkipUnchangedFiles="true"
Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsBrowser)' == 'true'"/>

<Exec Condition="'$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'" Command="install_name_tool -id @rpath/$(MonoFileName) $(BinDir)$(MonoFileName)" />
<PropertyGroup>
<TargetsAppleDevice Condition="'$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'">true</TargetsAppleDevice>
</PropertyGroup>

<Exec Condition="'$(TargetsAppleDevice)' == 'true' and '$(OS)' == 'OSX'" Command="install_name_tool -id @rpath/$(MonoFileName) $(BinDir)$(MonoFileName)" />
</Target>

</Project>