zufuliu / llvm-utils

LLVM/Clang toolsets for Visual Studio 2022, 2019, 2017, 2015, 2013, 2012 and 2010.
Other
209 stars 35 forks source link

The specified task executable location "bin\clang-cl.exe" is invalid. #7

Open 11philip22 opened 3 years ago

11philip22 commented 3 years ago

Hi, I have installed llvm-utils for visual studio 2019. And i have installed llvm in C:\llvm But when i compile a project with LLVM v 142 as toolchain. i get the error The specified task executable location "bin\clang-cl.exe" is invalid. I have a Directory.build.props in my project root with the following contents:

<Project>
  <PropertyGroup>
    <LLVMInstallDir>C:\llvm\</LLVMInstallDir>
    <LLVMToolsVersion>14.0.0</LLVMToolsVersion>
  </PropertyGroup>
</Project>
zufuliu commented 3 years ago

How about remove above property? LLVMInstallDir is detected from registry (which is set official installer from https://github.com/llvm/llvm-project/releases), see https://github.com/zufuliu/llvm-utils/blob/main/VS2017/LLVM/LLVM.Common.props#L3

<PropertyGroup>
  <LLVMInstallDir>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\LLVM\LLVM)</LLVMInstallDir>
  <LLVMInstallDir Condition="'$(LLVMInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM\LLVM)</LLVMInstallDir>

for your self built llvm, two workarounds:

  1. you set ClangClExecutable in your project: ClangClExecutable

  2. create registry and set default value for LLVM\LLVM item to the directory C:\llvm.

I will need time to figure out why override LLVMInstallDir not work, and expose it in LLVM property page for easy configuration.

zufuliu commented 3 years ago

Hi @11philip22, can you test latest code, check whether it works now?

In 319852e44ab5a6bf03873e565bff54444984f1a8, I changed LLVMInstallDir to only use official installation folder when bin\clang-cl.exe exists (in your case, since bin\clang-cl.exe is not found, it's an empty string). By default Visual Studio 2019/2022 sets LLVMInstallDir to $(VsInstallRoot)\VC\Tools\Llvm or $(VsInstallRoot)\VC\Tools\Llvm\x64, depends on the imported order of your Directory.build.props file, this change may still not fix the problem.

11philip22 commented 3 years ago

How about remove above property? LLVMInstallDir is detected from registry (which is set official installer from https://github.com/llvm/llvm-project/releases), see https://github.com/zufuliu/llvm-utils/blob/main/VS2017/LLVM/LLVM.Common.props#L3

<PropertyGroup>
  <LLVMInstallDir>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\LLVM\LLVM)</LLVMInstallDir>
  <LLVMInstallDir Condition="'$(LLVMInstallDir)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\LLVM\LLVM)</LLVMInstallDir>

for your self built llvm, two workarounds:

1. you set `ClangClExecutable` in your project:
   ![ClangClExecutable](https://user-images.githubusercontent.com/2289926/138464602-aba182c7-70b8-4e7d-8346-388b436ac1d6.png)

2. create registry and set default value for `LLVM\LLVM` item to the directory `C:\llvm`.

I will need time to figure out why override LLVMInstallDir not work, and expose it in LLVM property page for easy configuration.

hi @zufuliu Thanks for responding. I dont think LLVMInstallDir is set because i compiled from source.

Hi @11philip22, can you test latest code, check whether it works now?

In 319852e, I changed LLVMInstallDir to only use official installation folder when bin\clang-cl.exe exists (in your case, since bin\clang-cl.exe is not found, it's an empty string). By default Visual Studio 2019/2022 sets LLVMInstallDir to $(VsInstallRoot)\VC\Tools\Llvm or $(VsInstallRoot)\VC\Tools\Llvm\x64, depends on the imported order of your Directory.build.props file, this change may still not fix the problem.

I will try out your new release :)