|
10 | 10 | # outputs includes: llvm_dir, which is the directory where the libraries are installed |
11 | 11 |
|
12 | 12 | name: "Install LLVM Binaries" |
13 | | -description: "Installs pre-compiled LLVM libraries for a specific OS and architecture." |
| 13 | +description: "Installs pre-compiled LLVM libraries." |
14 | 14 | author: "Intel Corporation" |
15 | 15 |
|
16 | 16 | inputs: |
17 | 17 | os: |
18 | | - description: "Operating system to install on (e.g., ubuntu-22.04, macos-14)" |
| 18 | + description: "Operating system to install LLVM on (e.g., ubuntu-22.04, windows-latest)" |
19 | 19 | required: true |
20 | | - #TODO: options |
21 | | - arch: |
22 | | - description: "Architecture to install for (e.g., x86_64, aarch64)" |
| 20 | + triple: |
| 21 | + description: "LLVM triple to install (e.g., x86_64-linux-gnu-ubuntu-18.04, x86_64-pc-windows-msvc, arm64-apple-macos11)" |
23 | 22 | required: true |
24 | | - #TODO: options |
| 23 | + default: "" |
25 | 24 | container_image: |
26 | 25 | description: "Container image to use (optional)" |
27 | 26 | required: false |
28 | 27 | default: "" |
29 | 28 | ver: |
30 | 29 | description: "LLVM version to install (e.g., 18.1.2) (optional)" |
31 | 30 | required: false |
32 | | - default: "18.1.2" |
| 31 | + default: "18.1.8" |
33 | 32 | #TODO: options |
34 | 33 | outputs: |
35 | | - llvm_dir: |
| 34 | + llvm_dir_on_windows: |
| 35 | + description: "The directory where LLVM libraries are installed" |
| 36 | + value: ${{ steps.set_llvm_dir_windows.outputs.llvm_dir }} |
| 37 | + llvm_dir_on_ubuntu: |
36 | 38 | description: "The directory where LLVM libraries are installed" |
37 | | - value: ${{ steps.set_llvm_dir.outputs.llvm_dir }} |
| 39 | + value: ${{ steps.set_llvm_dir_ubuntu.outputs.llvm_dir }} |
38 | 40 |
|
39 | 41 | runs: |
40 | 42 | using: "composite" |
41 | 43 | steps: |
42 | | - - name: Check Runner OS |
| 44 | + #TODO: tell the user there is no pre-compiled LLVM binaries for macos with x86_64 architecture |
| 45 | + |
| 46 | + - name: LOG Runner OS |
43 | 47 | shell: bash |
44 | 48 | run: | |
45 | | - if [[ "${{ inputs.os }}" != "ubuntu-22.04" && "${{ inputs.os }}" != "macos-14" ]]; then |
46 | | - echo "::error title=⛔ error hint::Only support ubuntu-22.04 and macos-14 for now" |
47 | | - exit 1 |
48 | | - fi |
| 49 | + echo "::debug::installing LLVM binaries on ${{ inputs.os }}" |
49 | 50 |
|
50 | | - - name: Create installation directory |
| 51 | + - name: Create installation directory(Ubuntu) |
| 52 | + if: ${{ startsWith(inputs.os, 'ubuntu') }} |
51 | 53 | shell: bash |
52 | | - run: sudo mkdir -p /opt/llvm-${{ inputs.ver }} |
| 54 | + run: mkdir -p /opt/llvm-${{ inputs.ver }} |
| 55 | + |
| 56 | + - name: Create installation directory(Windows) |
| 57 | + if: ${{ startsWith(inputs.os, 'windows') }} |
| 58 | + shell: powershell |
| 59 | + run: New-Item -ItemType Directory -Path .\core\deps\llvm-${{ inputs.ver }} -Force |
53 | 60 |
|
54 | | - - name: Download and install LLVM binaries |
| 61 | + - name: Download and install LLVM binaries(Ubuntu) |
| 62 | + if: ${{ startsWith(inputs.os, 'ubuntu') }} |
55 | 63 | shell: bash |
56 | 64 | run: | |
57 | | - sudo wget -O llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.arch }}-${{ inputs.os }}.tar.xz |
58 | | - sudo tar xf llvm.tar.xz --strip-components=1 -C /opt/llvm-${{ inputs.ver }} |
59 | | - working-directory: /opt/llvm-${{ inputs.ver }} |
| 65 | + wget -O llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}.tar.xz |
| 66 | + tar xf llvm.tar.xz --strip-components=1 -C llvm-${{ inputs.ver }} |
| 67 | + working-directory: /opt |
| 68 | + |
| 69 | + - name: Download and install LLVM binaries(Windows) |
| 70 | + if: ${{ startsWith(inputs.os, 'windows') }} |
| 71 | + shell: powershell |
| 72 | + run: | |
| 73 | + try { |
| 74 | + $ErrorActionPreference = "Stop" |
| 75 | + # Significantly reduce the time consumption of downloading. |
| 76 | + $ProgressPreference = 'SilentlyContinue' |
| 77 | + $url="https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}.tar.xz" |
| 78 | + Write-Host "Downloading LLVM from: $url" |
| 79 | + Invoke-WebRequest -Uri $url -OutFile llvm.tar.xz |
| 80 | +
|
| 81 | + if (-not (Test-Path llvm.tar.xz)) { |
| 82 | + throw "Download failed: llvm.tar.xz not found" |
| 83 | + } |
| 84 | +
|
| 85 | + Write-Host "Extracting LLVM package..." |
| 86 | + # Use 7z for better performance on Windows |
| 87 | + if (-not (Test-Path "C:\Program Files\7-Zip\7z.exe")) { |
| 88 | + throw "7-Zip is not installed. Please install 7-Zip to extract the LLVM package." |
| 89 | + } |
| 90 | +
|
| 91 | + # First extract the .tar file from .tar.xz |
| 92 | + Write-Host "Extracting .tar from .tar.xz..." |
| 93 | + & "C:\Program Files\7-Zip\7z.exe" e llvm.tar.xz |
| 94 | +
|
| 95 | + if ($LASTEXITCODE -ne 0) { |
| 96 | + throw "Extraction of .tar.xz failed with exit code: $LASTEXITCODE" |
| 97 | + } |
60 | 98 |
|
61 | | - - name: Set output LLVM_DIR |
62 | | - id: set_llvm_dir |
| 99 | + # Then extract the contents from .tar |
| 100 | + Write-Host "Extracting contents from .tar..." |
| 101 | + & "C:\Program Files\7-Zip\7z.exe" x "llvm.tar" |
| 102 | +
|
| 103 | + if ($LASTEXITCODE -ne 0) { |
| 104 | + throw "Extraction of .tar failed with exit code: $LASTEXITCODE" |
| 105 | + } |
| 106 | +
|
| 107 | + # Verify the contents |
| 108 | + dir "." |
| 109 | +
|
| 110 | + $extractedDir = Join-Path -Path "." -ChildPath "clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}" |
| 111 | + if (-not (Test-Path $extractedDir)) { |
| 112 | + throw "Extraction failed: $extractedDir not found" |
| 113 | + } |
| 114 | +
|
| 115 | + # Verify the contents |
| 116 | + dir "$extractedDir" |
| 117 | +
|
| 118 | + Write-Host "Moving contents from $extractedDir to llvm-${{ inputs.ver }}..." |
| 119 | +
|
| 120 | + # Move all contents from the extracted directory to the target directory |
| 121 | + Get-ChildItem -Path "$extractedDir" | Move-Item -Destination ".\llvm-${{ inputs.ver }}" |
| 122 | +
|
| 123 | + # Verify the contents |
| 124 | + dir ".\llvm-${{ inputs.ver }}" |
| 125 | +
|
| 126 | + # Search LLVMConfig.cmake and llvm-config.cmake, ignore case |
| 127 | + $llvmConfigFiles = Get-ChildItem -Path ".\llvm-${{ inputs.ver }}" -Recurse -Include "LLVMConfig.cmake", "llvm-config.cmake" -ErrorAction SilentlyContinue |
| 128 | + Write-Host "Found LLVMConfig.cmake and llvm-config.cmake files: $($llvmConfigFiles)" |
| 129 | + if ($llvmConfigFiles.Count -eq 0) { |
| 130 | + throw "No LLVMConfig.cmake or llvm-config.cmake files found in the extracted directory." |
| 131 | + } |
| 132 | +
|
| 133 | + Write-Host "LLVM installation completed successfully" |
| 134 | + } |
| 135 | + catch { |
| 136 | + Write-Error "Failed to install LLVM: $_" |
| 137 | + exit 1 |
| 138 | + } |
| 139 | + working-directory: .\core\deps |
| 140 | + |
| 141 | + - name: Set output LLVM_DIR(Ubuntu) |
| 142 | + if: ${{ startsWith(inputs.os, 'ubuntu') }} |
| 143 | + id: set_llvm_dir_ubuntu |
63 | 144 | shell: bash |
64 | 145 | run: echo "llvm_dir=/opt/llvm-${{ inputs.ver }}" >> $GITHUB_OUTPUT |
| 146 | + |
| 147 | + - name: Set output LLVM_DIR(Windows) |
| 148 | + if: ${{ startsWith(inputs.os, 'windows') }} |
| 149 | + id: set_llvm_dir_windows |
| 150 | + shell: powershell |
| 151 | + run: | |
| 152 | + $absolutePath = (Resolve-Path ".\core\deps\llvm-${{ inputs.ver }}").Path |
| 153 | + Write-Output "llvm_dir=$absolutePath" >> $env:GITHUB_OUTPUT |
0 commit comments