如何使用本机corert预览构建?

时间:2017-09-27 14:55:39

标签: c# c++ .net native corert

我尝试使用corert ilc编译器和microsoft链接器构建面向win-x86的.NET核心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'

1 个答案:

答案 0 :(得分:2)

问题是由使用Developer Command Prompt而不是x64 Native Tools命令提示符引起的。前者默认以x86为目标,但后者以x64为目标,并将链接到x64库。