Integrate LLVM Clang 4.x.x / 5.x.x / 6.x.x into Visual Studio 2017

前端 未结 7 924
南笙
南笙 2020-12-23 18:40

The official LLVM 4.0 build for Windows integrates with Visual Studio up to Visual Studio 2015. Unfortunately it still doesn\'t support Visual Studio 2017.

When you

7条回答
  •  不知归路
    2020-12-23 18:52

    Check out January 09, 2018 http://planet.clang.org/

    Look at the "Try it out!" section:

    If you're already using clang-cl and lld-link on Windows today, you can try this out. There are two flags needed to enable this, one for the compiler and one for the linker: To enable the emission of a .debug$H section by the compiler, you will need to pass the undocumented -mllvm -emit-codeview-ghash-section flag to clang-cl (this flag should go away in the future, once this is considered stable and good enough to be turned on by default). To tell lld-link to use this information, you will need to pass the /DEBUG:GHASH to lld.

    You just need to pass the -mllvm -emit-codeview-ghash-section flags in either your c++ projects "Command Line:Additional Options" area, or place them directly in the "toolset.props" file that you created in C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\LLVM-vs2017 or C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets\LLVM-vs2017.

    The key is that in adding those cli options you're telling clang to emit debug information that the lld (aka lld-link) will understand and use to produce fully populated PDB files. Not the limited ones it made prior to the Jan 09, 2018 drops of LLVM 7.0.

    toolset.targets: (any version)

    
      
    
    

    toolset.props: (Win32 version)

      
      
      
    
      
        $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\LLVM\LLVM)
        $(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM\LLVM)
        $(LLVMInstallDir)\msbuild-bin;$(ExecutablePath)
        $(LLVMInstallDir)\lib\clang\7.0\lib\windows;$(LibraryPath)
      
    
      
        
          
          
          
          -m32 -fmsc-version=1913 %(AdditionalOptions)
        
      
    
    

    For x64, change -m32 to -m64

    p.p.s., I have also enabled Microsofts ARM and ARM64 compilers for building native Windows-10-ARM apps (not UWP modern-com-junk). But, as yet, I have not done enough digging through the clang sources to properly configure something similar for ARM to what -m32 and -m64 do for Intel code-gen.

    See these articles:

    • http://pete.akeo.ie/2017/05/compiling-desktop-arm-applications-with.html

    • https://www.theverge.com/2017/12/5/16737288/microsoft-windows-10-qualcomm-arm-laptops-launch

    • https://wiki.winehq.org/ARM

提交回复
热议问题