Skip to content

Commit 5dc264e

Browse files
committed
update llvm release URLs
1 parent 04aded1 commit 5dc264e

File tree

3 files changed

+126
-28
lines changed

3 files changed

+126
-28
lines changed

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

Lines changed: 118 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,151 @@
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 }}"
50+
51+
- name: Install dependencies(Windows)
52+
if: ${{ startsWith(inputs.os, 'windows') }}
53+
shell: powershell
54+
run: |
55+
choco install libxml2
4956
50-
- name: Create installation directory
57+
- name: Create installation directory(Ubuntu)
58+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
5159
shell: bash
52-
run: sudo mkdir -p /opt/llvm-${{ inputs.ver }}
60+
run: mkdir -p /opt/llvm-${{ inputs.ver }}
61+
62+
- name: Create installation directory(Windows)
63+
if: ${{ startsWith(inputs.os, 'windows') }}
64+
shell: powershell
65+
run: New-Item -ItemType Directory -Path .\core\deps\llvm\build -Force
5366

54-
- name: Download and install LLVM binaries
67+
- name: Download and install LLVM binaries(Ubuntu)
68+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
5569
shell: bash
5670
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 }}
71+
wget -O llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}.tar.xz
72+
tar xf llvm.tar.xz --strip-components=1 -C llvm-${{ inputs.ver }}
73+
working-directory: /opt
74+
75+
- name: Download and install LLVM binaries(Windows)
76+
if: ${{ startsWith(inputs.os, 'windows') }}
77+
shell: powershell
78+
run: |
79+
try {
80+
$ErrorActionPreference = "Stop"
81+
# Significantly reduce the time consumption of downloading.
82+
$ProgressPreference = 'SilentlyContinue'
83+
$url="https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ inputs.ver }}/clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}.tar.xz"
84+
Write-Host "Downloading LLVM from: $url"
85+
Invoke-WebRequest -Uri $url -OutFile llvm.tar.xz
86+
87+
if (-not (Test-Path llvm.tar.xz)) {
88+
throw "Download failed: llvm.tar.xz not found"
89+
}
90+
91+
Write-Host "Extracting LLVM package..."
92+
# Use 7z for better performance on Windows
93+
if (-not (Test-Path "C:\Program Files\7-Zip\7z.exe")) {
94+
throw "7-Zip is not installed. Please install 7-Zip to extract the LLVM package."
95+
}
96+
97+
# First extract the .tar file from .tar.xz
98+
Write-Host "Extracting .tar from .tar.xz..."
99+
& "C:\Program Files\7-Zip\7z.exe" e llvm.tar.xz
60100
61-
- name: Set output LLVM_DIR
62-
id: set_llvm_dir
101+
if ($LASTEXITCODE -ne 0) {
102+
throw "Extraction of .tar.xz failed with exit code: $LASTEXITCODE"
103+
}
104+
105+
# Then extract the contents from .tar
106+
Write-Host "Extracting contents from .tar..."
107+
& "C:\Program Files\7-Zip\7z.exe" x "llvm.tar"
108+
109+
if ($LASTEXITCODE -ne 0) {
110+
throw "Extraction of .tar failed with exit code: $LASTEXITCODE"
111+
}
112+
113+
# Verify the contents
114+
dir "."
115+
116+
$extractedDir = Join-Path -Path "." -ChildPath "clang+llvm-${{ inputs.ver }}-${{ inputs.triple}}"
117+
if (-not (Test-Path $extractedDir)) {
118+
throw "Extraction failed: $extractedDir not found"
119+
}
120+
121+
# Verify the contents
122+
dir "$extractedDir"
123+
124+
Write-Host "Moving contents from $extractedDir to llvm\build..."
125+
126+
# Move all contents from the extracted directory to the target directory
127+
Get-ChildItem -Path "$extractedDir" | Move-Item -Destination ".\llvm\build"
128+
129+
# Verify the contents
130+
dir ".\llvm\build"
131+
132+
# Search LLVMConfig.cmake and llvm-config.cmake, ignore case
133+
$llvmConfigFiles = Get-ChildItem -Path ".\llvm\build" -Recurse -Include "LLVMConfig.cmake", "llvm-config.cmake" -ErrorAction SilentlyContinue
134+
Write-Host "Found LLVMConfig.cmake and llvm-config.cmake files: $($llvmConfigFiles)"
135+
if ($llvmConfigFiles.Count -eq 0) {
136+
throw "No LLVMConfig.cmake or llvm-config.cmake files found in the extracted directory."
137+
}
138+
139+
Write-Host "LLVM installation completed successfully"
140+
}
141+
catch {
142+
Write-Error "Failed to install LLVM: $_"
143+
exit 1
144+
}
145+
working-directory: .\core\deps
146+
147+
148+
- name: Set output LLVM_DIR(Ubuntu)
149+
if: ${{ startsWith(inputs.os, 'ubuntu') }}
150+
id: set_llvm_dir_ubuntu
63151
shell: bash
64152
run: echo "llvm_dir=/opt/llvm-${{ inputs.ver }}" >> $GITHUB_OUTPUT
153+
154+
- name: Set output LLVM_DIR(Windows)
155+
if: ${{ startsWith(inputs.os, 'windows') }}
156+
id: set_llvm_dir_windows
157+
shell: powershell
158+
run: |
159+
$absolutePath = (Resolve-Path ".\core\deps\llvm\build").Path
160+
Write-Output "llvm_dir=$absolutePath" >> $env:GITHUB_OUTPUT

.github/workflows/compilation_on_windows.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,13 @@ 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: |
108-
cmake -S . -B build \
109-
-DWAMR_BUILD_WITH_CUSTOM_LLVM=1 \
110-
-DLLVM_DIR=${{ steps.install_llvm_libraries.outputs.llvm_dir }}/lib/cmake/llvm \
111-
-DCMAKE_BUILD_TYPE=Release
109+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
112110
cmake --build build --config Release --parallel 4
113111
working-directory: wamr-compiler
114112

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)