@@ -7,22 +7,21 @@ function Resolve-LLVMLayout {
77 # 1. Direct LLVM_ROOT or LLVM_DIR environment variables
88 if ($env: LLVM_ROOT -and (Test-Path $env: LLVM_ROOT )) { $candidateRoots.Add ($env: LLVM_ROOT ) }
99 if ($env: LLVM_DIR -and (Test-Path $env: LLVM_DIR )) {
10- # If LLVM_DIR points to cmake dir, root is likely 2 or 3 levels up
1110 $dir = $env: LLVM_DIR
12- $candidateRoots.Add ((Split-Path (Split-Path (Split-Path $dir )))) # lib/cmake/llvm -> lib/cmake -> lib -> root
11+ $candidateRoots.Add ((Split-Path (Split-Path (Split-Path $dir )))) # lib/cmake/llvm -> root
1312 $candidateRoots.Add ((Split-Path (Split-Path $dir ))) # cmake -> root
1413 }
1514
1615 # 2. Check if llvm-config is in PATH
1716 $llvmConfig = Get-Command llvm- config - ErrorAction SilentlyContinue
1817 if ($llvmConfig ) {
19- $binPath = $llvmConfig.Source
20- $binDir = Split-Path $binPath
18+ $binDir = Split-Path $llvmConfig.Source
2119 $root = Split-Path $binDir
2220 $candidateRoots.Add ($root )
2321 }
2422
2523 # 3. Known installation paths
24+ $candidateRoots.Add (" C:\LLVM" )
2625 $candidateRoots.Add (" C:\Program Files\LLVM" )
2726 $candidateRoots.Add (" C:\Program Files (x86)\LLVM" )
2827 $candidateRoots.Add (" C:\ProgramData\chocolatey\lib\llvm\tools\llvm" )
@@ -50,34 +49,27 @@ function Resolve-LLVMLayout {
5049 foreach ($suffix in $cmakeSuffixes ) {
5150 $cmakeDir = Join-Path $root $suffix
5251 if (Test-Path (Join-Path $cmakeDir " LLVMConfig.cmake" )) {
53- return @ {
54- Root = $root
55- CMakeDir = $cmakeDir
56- BinDir = Join-Path $root " bin"
57- }
52+ return @ { Root = $root ; CMakeDir = $cmakeDir ; BinDir = Join-Path $root " bin" }
5853 }
5954 }
6055 }
6156
62- # 4. Fallback: Recursive search in common areas
63- Write-Host " Performing exhaustive search for LLVMConfig.cmake..."
64- $searchRoots = @ (" C:\Program Files" , " C:\Program Files (x86)" , " C:\ProgramData\chocolatey" , " C:\tools" )
57+ # 4. Fallback: Recursive search in common areas with INCREASED DEPTH
58+ Write-Host " Performing exhaustive search for LLVMConfig.cmake (Depth 8) ..."
59+ $searchRoots = @ (" C:\LLVM " , " C:\ Program Files" , " C:\Program Files (x86)" , " C:\ProgramData\chocolatey" , " C:\tools" )
6560 foreach ($sr in $searchRoots ) {
6661 if (-not (Test-Path $sr )) { continue }
67- $configFile = Get-ChildItem - Path $sr - Filter " LLVMConfig.cmake" - Recurse - Depth 4 - ErrorAction SilentlyContinue | Select-Object - First 1
62+ # Depth 8 ensures we find it even in deep Chocolatey paths
63+ $configFile = Get-ChildItem - Path $sr - Filter " LLVMConfig.cmake" - Recurse - Depth 8 - ErrorAction SilentlyContinue | Select-Object - First 1
6864 if ($configFile ) {
6965 $cmakeDir = $configFile.DirectoryName
7066 Write-Host " Found LLVMConfig.cmake at: $cmakeDir "
7167
7268 # Try to find the root by looking for 'bin' nearby
7369 $root = $cmakeDir
74- for ($i = 0 ; $i -lt 4 ; $i ++ ) {
70+ for ($i = 0 ; $i -lt 5 ; $i ++ ) {
7571 if (Test-Path (Join-Path $root " bin" )) {
76- return @ {
77- Root = $root
78- CMakeDir = $cmakeDir
79- BinDir = Join-Path $root " bin"
80- }
72+ return @ { Root = $root ; CMakeDir = $cmakeDir ; BinDir = Join-Path $root " bin" }
8173 }
8274 $parent = Split-Path - Parent $root
8375 if ($parent -eq $root ) { break }
@@ -94,8 +86,8 @@ $layout = Resolve-LLVMLayout
9486# 2. Install if not found
9587if (-not $layout ) {
9688 Write-Host " LLVM not initially found. Installing via Chocolatey..."
97- # Using -- params to add LLVM to PATH
98- choco install llvm - y -- version 17.0 .6 -- allow- downgrade -- no- progress -- limit-output -- package- parameters= " \ " / InstallDir:C:\LLVM\ " "
89+ # Attempt install with BOTH package params and install arguments for maximum compatibility
90+ choco install llvm - y -- version 17.0 .6 -- allow- downgrade -- no- progress -- limit-output -- package- parameters= " ' /InstallDir:C:\LLVM' " -- install-arguments = ' /D=C:\LLVM '
9991
10092 # Refresh PATH for the current session
10193 Write-Host " Refreshing PATH..."
@@ -119,7 +111,7 @@ if ($layout) {
119111 $cmakeDir = $layout.CMakeDir -replace " \\" , " /"
120112 $binDir = $layout.BinDir
121113
122- Write-Host " Resolved LLVM root: $llvmRoot "
114+ Write-Host " `n Resolved LLVM root: $llvmRoot "
123115 Write-Host " Resolved LLVM_DIR: $cmakeDir "
124116 Write-Host " Resolved BinDir: $binDir "
125117
@@ -134,16 +126,17 @@ if ($layout) {
134126 }
135127} else {
136128 Write-Host " `n --- DEBUG INFO: SEARCH FAILED ---"
137- Write-Host " Listing top-level directories for clues :"
138- $debugPaths = @ (" C:\Program Files " , " C:\Program Files (x86) " , " C:\ProgramData\chocolatey\lib" , " C:\LLVM " , " C:\tools " )
129+ Write-Host " Listing candidate root contents for diagnostics :"
130+ $debugPaths = @ (" C:\LLVM " , " C:\Program Files\LLVM " , " C:\ProgramData\chocolatey\lib\llvm " )
139131 foreach ($dp in $debugPaths ) {
140132 if (Test-Path $dp ) {
141133 Write-Host " `n Contents of $dp `:"
142- Get-ChildItem $dp - ErrorAction SilentlyContinue | Select-Object Name | Format-Table - HideTableHeaders
134+ Get-ChildItem $dp - Recurse - Depth 2 - ErrorAction SilentlyContinue | Select-Object FullName | Format-Table - HideTableHeaders
143135 }
144136 }
145137
146- Write-Error " Failed to detect LLVM after installation. Check logs above for directory contents. "
138+ Write-Error " Failed to detect LLVM after installation."
147139 exit 1
148140}
149141
142+
0 commit comments