zoukankan      html  css  js  c++  java
  • coreRT 和 Native 编译netcore AOT程序

    AOT是预编译成本地程序,避免JIT动态编译存在的性能问题。

    netcore一个吸引人的项目,就是基于coreRt 运行时的本地编译技术,下面我来替大家尝试一下它究竟表现如何。

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <RestoreSources>https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreSources>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp2.0</TargetFramework>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="microsoft.dotnet.ilcompiler" Version="1.0.0-alpha-*" />
    
      </ItemGroup>
    
    </Project>


    首先要在项目文件添加相关的包源,也就是:

    <RestoreSources>https://dotnet.myget.org/F/dotnet-core/api/v3/index.json</RestoreSources>

    然后引用包:

    <PackageReference Include="microsoft.dotnet.ilcompiler" Version="1.0.0-alpha-*" />

    因为还没有正式版,所以要把版本号写清楚,否则会提示找不到该包。

    用命令发布:

    dotnet publish -r win-x64 -c release

    会提示错误:error : Platform linker not found. To fix this problem, download and install Visual Studio 2017 from http://visualstudio.com. Make sure to install the Desktop Development for C++ workload.

    微软就是喜欢这里一块那里一块,就不能好好提供一站式服务吗?没办法,下载安装c++ 环境。这个要4GB,不知道有什么越过的方法。

    经测试,在win7 sp1 x64 虚拟机环境下可以正常执行。

    image

    hello world程序不到4m大小。感觉还可以。

    其他

    只支持64位生成,而且不能交叉编译,也就是不能在windows编译linux程序。在win7下面测试成功,winxp提示不是有效32位(不知道在xp 64版会怎样)。不知道能否支持win vista。

    ps。当这个native包更新后,他会替换默认的编译器,不知道怎么换回来。。

  • 相关阅读:
    CSP模拟11
    P3870 [TJOI2009]开关
    P2357 守墓人(分块)
    那一天她离我而去 (最短路)
    礼物(概率dp)
    收集邮票(概率dp)
    齿轮
    water
    【纪中受难记】——C3D4:万里无云
    zz maven eclipse svn 上传下载
  • 原文地址:https://www.cnblogs.com/Nobel/p/9524833.html
Copyright © 2011-2022 走看看