llvm/llvm-project

[Win][MSVC2017] Failed to find MSBuild toolsets directory

llvmbot opened this issue · 10 comments

Bugzilla Link 33672
Resolution FIXED
Resolved on Dec 07, 2018 20:55
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @arrowd,@ismail,@reupen,@mmatrosov,@tiagomacarios,@Trass3r,@yurybura

Extended Description

LLVM\tools\msbuild\install.bat does not support toolset v141.

Steps to reproduce:

  1. Install Windows
  2. Install Visual Studio 2017
  3. Install LLVM-5.0.0-r306282-win32.exe, "LLVM\tools\msbuild\install.bat" will fail with error "Failed to find MSBuild toolsets directory".

These scripts have never been updated. The toolset is also still named LLVM-vs2014.

Seems like the ms-compat options are not correct anymore either:
https://www.reddit.com/r/cpp/comments/6oepq4/making_windows_clang_401_play_nice_with_visual/

There is an attempt at solving this:
https://github.com/WubbaLubba/LlvmForVS2017
but still has issues:
Arik-Playground/LlvmForVS2017#2

I started working on a patch, since I wanted to use the C++17 additions to the STL.

For VS2017 Microsoft changed the directory structure, to allow independent installations of VS and so you can install VS where you want.
This requires a major overhaul of the install script.

That part I have mostly done now.
It does need some additional testing. Especially with older editions.

And there are some issues still.

To try the changes to the integration system, I created a stand-alone implementation for Clang v5.0.1.
https://github.com/Farwaykorse/VS_Clang

@​Trass3r Thanks for the link. I'll have to take a look at your PR on WubbaLubba's implementation.

Thanks for the link. I'll have to take a look at your PR on
WubbaLubba's implementation.

Has been merged in the meantime.
It's working nicely.

Has been merged in the meantime.
It's working nicely.

I am using Visual Studio Community 2017 15.6.2. I installed LLVM-6.0.0-win64.exe. LLVM-vs2014 toolset appeared in the list of toolset in Visual Studio. However, when I tried to set it to a project, I got this error:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Redirect.14.props(47,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.cpp.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Unfortunately, the fix proposed by Roelf-Jilling Wolthuis did not help. I created a corresponding issue: Arik-Playground/LlvmForVS2017#5

Excuse me, I've pushed the updated prop-files to point to the correct LLVM path for v6.0.0.
This should make a "LLVM-vs2017" platfom toolset available in VS2017.
Could you try again?

Note, that if you want to use the LLVM-vs2014 integration, you need to have v140 of the VC++ toolset (VS2015) installed. It is available in the VS2017 installer as "VC++ 2015.3 toolset for desktop (x86,x64)".
Than compilation should work without any additional fixes, but Clang will be limited to what VS2015 supports.

The install script at: https://github.com/Farwaykorse/VS_Clang
should work without this extra 3 GB install and adds support for C++17.

I have an outstanding fix for LLVM to fix the paths, D42595.
No update for the install method to support VS2017, because Zachary Turner is working on a new integration method for LLVM v7.0, using a VS-plugin.

Hi, Roelf-Jilling Wolthuis,

Could you please clarify what exactly I need to do to test your fix?

I've pushed a version of the script that pauses after running, so you can see the output without running it from the console.

  1. Use git, or download the zip-file, from the repository.
  2. You can run the script install.bat by double-clicking it, but if you don't have write-access to the install directory of Visual Studio, you'll have to run it as Administrator. (You would see some Access is denied. messages.)
    'Run as Administrator' is available under the (right-click) context-menu.
    It should show output something like: (Depending on what you have installed.)
Installing MSVC integration...
  LLVM-vs2012 (Win32)
  LLVM-vs2012_xp (Win32)
  LLVM-vs2013 (Win32)
  LLVM-vs2013_xp (Win32)
  LLVM-vs2014 (Win32)
  LLVM-vs2014_xp (Win32)
  LLVM-vs2014 (x64)
  LLVM-vs2014_xp (x64)
Found VS: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
  LLVM-vs2017 (Win32)
  LLVM-vs2017 (x64)
Found VS: D:\VisualStudio
  LLVM-vs2017 (Win32)
  LLVM-vs2017 (x64)
Installed integation for 12 toolsets.
Done!
Press any key to continue . . .

Note: If you downloaded the zip-file, Windows might show a Defender SmartScreen. You can click More info and Run Anyway.


Or, if you don't trust the script, you can copy the files manually.
When you run the script as a normal user, it still lists all VC++ toolsets it found. And the install directory for VS2017.

Installing MSVC integration...
  LLVM-vs2012 (Win32)
Access is denied.
...
Found VS: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
  LLVM-vs2017 (Win32)
Access is denied.
  LLVM-vs2017 (x64)
Access is denied.
...
WARNING: Copy operation failed for 8 installations.
         Verify write access. (Run as administrator.)
WARNING: Failed to install any toolset.

So in this example: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
I'm calling it: [VS2017_dir]

  1. Navigate to:
    [VS2017_dir]\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets
  2. Create a new folder: LLVM-vs2017
  3. Copy the downloaded files: toolset-vs2017.props and toolset-vs2017.targets from the downloaded folder Win32.
  4. And rename them to: toolset.props and toolset.targets

Repeat for 64-bit:

  1. Navigate to: [VS2017_dir]\Common7\IDE\VC\VCTargets\Platforms\x64\PlatformToolsets
  2. ...
  3. ... from the downloaded folder x64.
  4. ...

When you have "Windows XP support for C++" installed, you'll notice you have two folders in ...\PlatformToolsets (v141 and v141_xp)

  1. ...
  2. Create a new folder: LLVM-vs2017_xp
  3. Copy ... toolset-vs2017_xp.props and ...
  4. ...
    (Repeat for both 32 and 64-bit.)

Hey Zach isn't this fixed with the new extension?

Since the file install.bat was removed, there is no reason to complain.