Skip to content

Commit 4579d2a

Browse files
committed
update llvm release URLs
1 parent 04aded1 commit 4579d2a

File tree

3 files changed

+119
-25
lines changed

3 files changed

+119
-25
lines changed

.github/actions/install-llvm-binaries/action.yml

Lines changed: 111 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,144 @@
1010
# outputs includes: llvm_dir, which is the directory where the libraries are installed
1111

1212
name: "Install LLVM Binaries"
13-
description: "Installs pre-compiled LLVM libraries for a specific OS and architecture."
13+
description: "Installs pre-compiled LLVM libraries."
1414
author: "Intel Corporation"
1515

1616
inputs:
1717
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)"
1919
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)"
2322
required: true
24-
#TODO: options
23+
default: ""
2524
container_image:
2625
description: "Container image to use (optional)"
2726
required: false
2827
default: ""
2928
ver:
3029
description: "LLVM version to install (e.g., 18.1.2) (optional)"
3130
required: false
32-
default: "18.1.2"
31+
default: "18.1.8"
3332
#TODO: options
3433
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:
3638
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 }}
3840

3941
runs:
4042
using: "composite"
4143
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
4347
shell: bash
4448
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 }}"
4950
50-
- name: Create installation directory
51+
- name: Create installation directory(Ubuntu)
52+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
5153
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
5360

54-
- name: Download and install LLVM binaries
61+
- name: Download and install LLVM binaries(Ubuntu)
62+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
5563
shell: bash
5664
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+
}
6098
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
63144
shell: bash
64145
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

.github/workflows/compilation_on_windows.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,15 @@ jobs:
100100
id: install_llvm_libraries
101101
uses: ./.github/actions/install-llvm-binaries
102102
with:
103-
os: ${{ matrix.os }}
104-
arch: ${{ matrix.arch }}
103+
os: windows-latest
104+
triple: x86_64-pc-windows-msvc
105105

106106
- name: build wamrc from source code
107+
shell: bash
107108
run: |
108109
cmake -S . -B build \
109110
-DWAMR_BUILD_WITH_CUSTOM_LLVM=1 \
110-
-DLLVM_DIR=${{ steps.install_llvm_libraries.outputs.llvm_dir }}/lib/cmake/llvm \
111+
-DLLVM_DIR=${{ steps.install_llvm_libraries.outputs.llvm_dir_on_windows }}/lib/cmake/llvm \
111112
-DCMAKE_BUILD_TYPE=Release
112113
cmake --build build --config Release --parallel 4
113114
working-directory: wamr-compiler

wamr-compiler/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ cmake_minimum_required (VERSION 3.14)
55

66
include(CheckPIESupported)
77

8+
include(CMakePrintHelpers)
9+
810
if (NOT DEFINED WAMR_BUILD_PLATFORM)
911
if (CMAKE_SYSTEM_NAME)
1012
string(TOLOWER ${CMAKE_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
@@ -165,6 +167,8 @@ if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
165167
set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
166168
endif ()
167169

170+
cmake_print_variables(WAMR_BUILD_WITH_CUSTOM_LLVM LLVM_DIR)
171+
168172
find_package(LLVM REQUIRED CONFIG)
169173
include_directories(${LLVM_INCLUDE_DIRS})
170174
add_definitions(${LLVM_DEFINITIONS})

0 commit comments

Comments
 (0)