我尝试使用corert ilc 编译器和 microsoft 链接器构建一个针对 win-x86 的 .NET core 2.0 控制台应用程序。
到目前为止,我下载了最新版本的 corert 库,并使用提交 c7781a90f00645f6bd06ef57e5d3fd879fe3e9a0 时的发布目标成功构建了预览。
我添加了构建脚本 rd.xml、ilc.rsp 和 link.rsp,但我不断收到来自 ilc 的消息:
Error: Target architecture is not supported
Internal.CommandLine.CommandLineException: Target architecture is not supported
at ILCompiler.Program.Run(String[] args)
at ILCompiler.Program.Main(String[] args)
更新:我能够解决架构问题,但现在由于缺少文件引用而失败:
C:\testapp>call "..\corert\bin\Windows_NT.x64.Release\tools\ilc.exe" ".\ilc.rsp"
Error: [TEMPORARY EXCEPTION MESSAGE] FileLoadErrorGeneric: Microsoft.Extensions.Options
Internal.TypeSystem.TypeSystemException+FileNotFoundException: [TEMPORARY EXCEPTION MESSAGE] FileLoadErrorGeneric: Microsoft.Extensions.Options
at Internal.TypeSystem.ThrowHelper.ThrowFileNotFoundException(ExceptionStringID id, String fileName)
at ILCompiler.CompilerTypeSystemContext.GetModuleForSimpleName(String simpleName, Boolean throwIfNotFound)
at Internal.TypeSystem.CustomAttributeTypeNameParser.GetTypeByCustomAttributeTypeName(ModuleDesc module, String name, Boolean throwIfNotFound, Func`4 resolver)
at Internal.TypeSystem.CustomAttributeTypeNameParser.GetTypeByCustomAttributeTypeName(ModuleDesc module, String name, Boolean throwIfNotFound, Func`4 resolver)
at ILCompiler.RdXmlRootProvider.ProcessTypeDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, XElement typeElement)
at ILCompiler.RdXmlRootProvider.ProcessAssemblyDirective(IRootingServiceProvider rootProvider, XElement assemblyElement)
at ILCompiler.RdXmlRootProvider.AddCompilationRoots(IRootingServiceProvider rootProvider)
at ILCompiler.Compilation..ctor(DependencyAnalyzerBase`1 dependencyGraph, NodeFactory nodeFactory, IEnumerable`1 compilationRoots, DebugInformationProvider debugInformationProvider, Logger logger)
at ILCompiler.ILScannerBuilder.ToILScanner()
at ILCompiler.Program.Run(String[] args)
at ILCompiler.Program.Main(String[] args)
更新 2:我能够通过查找所有丢失文件的引用来解决问题,但最后我意识到我需要将架构目标切换到 x64,但是现在它在链接器上失败了:
C:\testapp>call link @".\link.rsp"
libcpmt.lib(nothrow.obj) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'