Skip to content

Commit

Permalink
Use custom ilc
Browse files Browse the repository at this point in the history
  • Loading branch information
nifanfa committed Feb 1, 2023
1 parent c779f28 commit 745ebbf
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ publish/
PublishScripts/

# NuGet Packages
*.nupkg
# *.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# **/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
Expand Down
1 change: 1 addition & 0 deletions ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Content Include="Properties\launchSettings.json" />
</ItemGroup>

<!--Warning: This package is modified(/packages). Using official one may cause it fail to compile!-->
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="7.0.0-alpha.1.22074.1" />
</ItemGroup>
Expand Down
8 changes: 2 additions & 6 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="local" value="packages\" />
</packageSources>
</configuration>
</configuration>
130 changes: 130 additions & 0 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Warning
The package "microsoft.dotnet.ilcompiler.7.0.0-alpha.1.22074.1.nupkg" is modified. Using official one may cause it fail to compile!

build\Microsoft.NETCore.Native.Windows.props
```diff
<!--
***********************************************************************************************
Microsoft.NETCore.Native.Windows.props

WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.

This file defines Windows-specific steps in the build process for native AOT compilation.

Licensed to the .NET Foundation under one or more agreements.
The .NET Foundation licenses this file to you under the MIT license.
***********************************************************************************************
​-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CppCompiler>cl</CppCompiler>
<CppLinker>link</CppLinker>
<CppLibCreator>lib</CppLibCreator>
<LibrarySuffix>.lib</LibrarySuffix>
<LibrarySuffix Condition="'$(ControlFlowGuard)' == 'Guard'">.GuardCF.lib</LibrarySuffix>
<FullRuntimeName>Runtime.WorkstationGC</FullRuntimeName>
<FullRuntimeName Condition="'$(ServerGarbageCollection)' == 'true' or '$(ControlFlowGuard)' == 'Guard'">Runtime.ServerGC</FullRuntimeName>
<BootstrapperName>bootstrapper</BootstrapperName>
<BootstrapperName Condition="$(NativeLib) != ''">bootstrapperdll</BootstrapperName>
<EntryPointSymbol Condition="'$(EntryPointSymbol)' == ''">wmainCRTStartup</EntryPointSymbol>
<LinkerSubsystem Condition="'$(OutputType)' == 'WinExe' and '$(LinkerSubsystem)' == ''">WINDOWS</LinkerSubsystem>
<LinkerSubsystem Condition="'$(OutputType)' == 'Exe' and '$(LinkerSubsystem)' == ''">CONSOLE</LinkerSubsystem>
</PropertyGroup>

<!-- Ensure that runtime-specific paths have already been set -->
<Target Name="SetupOSSpecificProps" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">

+ <!--
<ItemGroup>
<NativeLibrary Include="$(IlcSdkPath)$(BootstrapperName)$(LibrarySuffix)" />
<NativeLibrary Include="$(IlcSdkPath)$(FullRuntimeName)$(LibrarySuffix)" />
<NativeLibrary Condition="'$(IlcMultiModule)' == 'true'" Include="$(SharedLibrary)" />
</ItemGroup>
+ -->

+ <!--
<ItemGroup>
<NetCoreAppNativeLibrary Include="System.IO.Compression.Native" />
</ItemGroup>
+ -->

<ItemGroup>
<DirectPInvoke Include="@(NetCoreAppNativeLibrary->'%(Identity)')" />
<NetCoreAppNativeLibrary Include="@(NetCoreAppNativeLibrary->'%(Identity)')">
<EscapedPath>$(IlcSdkPath)%(Identity).Aot$(LibrarySuffix)</EscapedPath>
</NetCoreAppNativeLibrary>
<NativeLibrary Include="@(NetCoreAppNativeLibrary->'%(EscapedPath)')" />
</ItemGroup>

+ <!--
<ItemGroup>
<NativeLibrary Include="advapi32.lib" />
<NativeLibrary Include="bcrypt.lib" />
<NativeLibrary Include="crypt32.lib" />
<NativeLibrary Include="iphlpapi.lib" />
<NativeLibrary Include="kernel32.lib" />
<NativeLibrary Include="mswsock.lib" />
<NativeLibrary Include="ncrypt.lib" />
<NativeLibrary Include="normaliz.lib" />
<NativeLibrary Include="ntdll.lib" />
<NativeLibrary Include="ole32.lib" />
<NativeLibrary Include="oleaut32.lib" />
<NativeLibrary Include="secur32.lib" />
<NativeLibrary Include="user32.lib" />
<NativeLibrary Include="version.lib" />
<NativeLibrary Include="ws2_32.lib" />
</ItemGroup>
+ -->

<ItemGroup>
<DirectPInvokeList Include="$(MSBuildThisFileDirectory)WindowsAPIs.txt" />
</ItemGroup>

<ItemGroup>
<LinkerArg Condition="$(NativeLib) == 'Shared'" Include="/DLL" />
<LinkerArg Include="@(NativeLibrary->'&quot;%(Identity)&quot;')" />
<LinkerArg Include="/NOLOGO /MANIFEST:NO" />
<LinkerArg Condition="$(NativeDebugSymbols) == 'true'" Include="/DEBUG" />
<!-- The runtime is not compatible with jump stubs inserted by incremental linking. -->
<LinkerArg Include="/INCREMENTAL:NO" />
<LinkerArg Condition="'$(LinkerSubsystem)' != ''" Include="/SUBSYSTEM:$(LinkerSubsystem)" />
<LinkerArg Condition="'$(OutputType)' == 'WinExe' or '$(OutputType)' == 'Exe'" Include="/ENTRY:$(EntryPointSymbol)" />
<LinkerArg Condition="$(NativeLib) == 'Shared'" Include="/INCLUDE:CoreRT_StaticInitialization" />
<LinkerArg Include="/NATVIS:&quot;$(MSBuildThisFileDirectory)CoreRTNatVis.natvis&quot;" />
<LinkerArg Condition="'$(ControlFlowGuard)' == 'Guard'" Include="/guard:cf" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' != 'Debug'">
<LinkerArg Include="/OPT:REF" />
<LinkerArg Include="/OPT:ICF" />
</ItemGroup>

<Exec Command="where /Q $(CppCompiler) &amp;&amp; where /Q $(CppLinker)" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="_WhereCppTools" />
</Exec>

<Message Condition="'$(_WhereCppTools)' != '0'" Text="Tools '$(CppCompiler)' and '$(CppLinker)' not found on PATH. Attempting to autodetect." />

<Exec Condition="'$(_WhereCppTools)' != '0'" Command="&quot;$(MSBuildThisFileDirectory)findvcvarsall.bat&quot; $(TargetArchitecture)"
IgnoreExitCode="true" ConsoleToMSBuild="true" StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="_FindVCVarsallOutput" />
<Output TaskParameter="ExitCode" PropertyName="_VCVarsAllFound" />
</Exec>

<ItemGroup Condition="'$(_VCVarsAllFound)' == '0'">
<AdditionalNativeLibraryDirectories Include="$(_FindVCVarsallOutput.Split(`#`)[1].Split(';'))" />
</ItemGroup>

<PropertyGroup Condition="'$(_VCVarsAllFound)' == '0'">
<_CppToolsDirectory>$(_FindVCVarsallOutput.Split(`#`)[0])</_CppToolsDirectory>
<CppCompiler>"$(_CppToolsDirectory)cl.exe"</CppCompiler>
<CppLinker>"$(_CppToolsDirectory)link.exe"</CppLinker>
<CppLibCreator>"$(_CppToolsDirectory)lib.exe"</CppLibCreator>
</PropertyGroup>

<Error Condition="'$(_WhereCppTools)' != '0' AND '$(_VCVarsAllFound)' == '1'" Text="Platform linker not found. To fix this problem, download and install Visual Studio 2019 or Visual Studio 2022 from http://visualstudio.com. Make sure to install the Desktop Development for C++ workload. For ARM64 development also install C++ ARM64 build tools." />
</Target>
</Project>
```
Binary file not shown.
Binary file not shown.

0 comments on commit 745ebbf

Please sign in to comment.