LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 33672 - [Win][MSVC2017] Failed to find MSBuild toolsets directory
Summary: [Win][MSVC2017] Failed to find MSBuild toolsets directory
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-01 17:57 PDT by Mikhail Strelnikov
Modified: 2018-12-07 20:55 PST (History)
11 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Strelnikov 2017-07-01 17:57:29 PDT
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".
Comment 1 Trass3r 2018-01-10 14:00:09 PST
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:
https://github.com/WubbaLubba/LlvmForVS2017/issues/2
Comment 2 Roelf-Jilling Wolthuis 2018-01-25 11:21:37 PST
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.
Comment 3 Trass3r 2018-01-25 13:38:49 PST
> 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.
Comment 5 Mikhail Matrosov 2018-03-18 07:56:12 PDT
(In reply to Trass3r from comment #3)
> 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 <Import> 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: https://github.com/WubbaLubba/LlvmForVS2017/issues/5
Comment 6 Roelf-Jilling Wolthuis 2018-03-26 10:57:22 PDT
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.
Comment 7 Mikhail Matrosov 2018-03-27 09:09:46 PDT
Hi, Roelf-Jilling Wolthuis,

Could you please clarify what _exactly_ I need to do to test your fix?
Comment 8 Roelf-Jilling Wolthuis 2018-03-27 11:16:36 PDT
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.)
Comment 9 Tiago Macarios 2018-11-13 17:49:06 PST
Hey Zach isn't this fixed with the new extension?
Comment 10 Mikhail Strelnikov 2018-12-07 20:55:29 PST
Since the file install.bat was removed, there is no reason to complain.