-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build script and github workflow
- Loading branch information
1 parent
09a6094
commit bd05dd1
Showing
6 changed files
with
181 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: "Build LLVM" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Git tag for the release.' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build_llvm: | ||
name: Build LLVM | ||
strategy: | ||
matrix: | ||
# os: [ubuntu-20.04, macos-11, windows-2019] | ||
os: [ubuntu-20.04] | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
contents: write # for creating releases | ||
container: | ||
# Intentionally old ubuntu version with old glibc. | ||
image: ubuntu:18.04 | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
# Install build dependencies. | ||
- run: "apt update && apt install -y clang git wget build-essential python3 ninja-build" | ||
# cmake from package manager is to old for the LLVM build. | ||
- run: "wget https://github.com/Kitware/CMake/releases/download/v3.30.0-rc2/cmake-3.30.0-rc2-linux-x86_64.sh" | ||
- run: "chmod +x cmake-*.sh" | ||
- run: "./cmake-*.sh --skip-license --prefix=/usr" | ||
# Build and package LLVM. | ||
- run: "./build-llvm-libs.sh" | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: llvm-static-libs | ||
path: llvm-static-libs.tar.gz | ||
- name: create release | ||
id: create-release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ inputs.tag }} | ||
release_name: ${{ inputs.tag }} | ||
draft: false | ||
prerelease: true | ||
- name: upload linux artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.create-release.outputs.upload_url }} | ||
asset_path: ./llvm-static-libs.tar.gz | ||
asset_name: llvm-static-linux-amd64.tar.gz | ||
asset_content_type: application/gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(llvm-static) | ||
|
||
if(POLICY CMP0114) | ||
cmake_policy(SET CMP0114 NEW) | ||
endif() | ||
|
||
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: | ||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") | ||
cmake_policy(SET CMP0135 NEW) | ||
endif() | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
# set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
set(CMAKE_BUILD_TYPE Release) | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add(${LLVM_PROJECT_TARGET} | ||
PREFIX ${LLVM_PROJECT_TARGET} | ||
GIT_REPOSITORY https://github.com/llvm/llvm-project.git | ||
GIT_TAG llvmorg-18.1.5 | ||
GIT_SHALLOW ON | ||
SOURCE_SUBDIR llvm | ||
CMAKE_ARGS | ||
-G${CMAKE_GENERATOR} | ||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} | ||
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} | ||
-DCMAKE_C_COMPILER_LAUNCHER:FILEPATH=${CMAKE_C_COMPILER_LAUNCHER} | ||
-DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=${CMAKE_CXX_COMPILER_LAUNCHER} | ||
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} | ||
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} | ||
-DLLVM_ENABLE_PROJECTS=clang | ||
-DLLVM_ENABLE_RTTI=ON | ||
-DLLVM_ENABLE_PIC=ON | ||
-DLLVM_TARGETS_TO_BUILD=X86 | ||
-DLLVM_BUILD_TOOLS=OFF | ||
-DLLVM_BUILD_TESTS=OFF | ||
-DLLVM_ENABLE_TERMINFO=OFF | ||
-DLLVM_ENABLE_ZLIB=OFF | ||
-DLLVM_ENABLE_ZSTD=OFF | ||
-DLLVM_ENABLE_LIBXML2=OFF | ||
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target clangTooling -j16 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# llvm-static | ||
# LLVM Tooling | ||
|
||
This repository contains scripts to build static LLVM libraries which can be used to develop libclangTooling based tools. See the release page for downloadable archives. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
BUILD_DIR="$SCRIPT_DIR/build" | ||
LLVM_BUILD_DIR="$BUILD_DIR/external.llvm-project" | ||
|
||
cd "$SCRIPT_DIR" | ||
mkdir -p build | ||
# cmake -B build -GNinja . | ||
# cmake --build build | ||
mkdir -p $LLVM_BUILD_DIR/include | ||
touch $LLVM_BUILD_DIR/include/clang.h | ||
|
||
# Pack everything we need into a tar archive. | ||
# We only need the header files, static libraries and add | ||
# a CMake file that makes it easy to link libclangTooling. | ||
cp $SCRIPT_DIR/cmake/CMakeLists.txt $LLVM_BUILD_DIR | ||
cd $LLVM_BUILD_DIR | ||
tar -czvf "$SCRIPT_DIR/llvm-static-libs.tar.gz" include/ lib/*.a CMakeLists.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Static libraries that are needed when using libclangTooling | ||
set(CLANG_TOOLING_DEPS | ||
clangFormat | ||
clangToolingInclusions | ||
clangFrontend | ||
clangDriver | ||
clangParse | ||
clangSerialization | ||
clangSema | ||
clangAPINotes | ||
clangEdit | ||
clangAnalysis | ||
clangASTMatchers | ||
clangAST | ||
clangSupport | ||
clangToolingCore | ||
clangRewrite | ||
clangLex | ||
clangBasic | ||
# Order as reported by llvm-config --libs --link-static | ||
LLVMWindowsDriver | ||
LLVMOption | ||
LLVMFrontendOpenMP | ||
LLVMFrontendOffloading | ||
LLVMScalarOpts | ||
LLVMTransformUtils | ||
LLVMAnalysis | ||
LLVMProfileData | ||
LLVMDebugInfoDWARF | ||
LLVMObject | ||
LLVMTextAPI | ||
LLVMMCParser | ||
LLVMIRReader | ||
LLVMAsmParser | ||
LLVMMC | ||
LLVMBitReader | ||
LLVMCore | ||
LLVMRemarks | ||
LLVMBitstreamReader | ||
LLVMBinaryFormat | ||
LLVMTargetParser | ||
LLVMSupport | ||
LLVMDemangle) | ||
|
||
foreach(lib ${CLANG_TOOLING_DEPS}) | ||
add_library(${lib} STATIC IMPORTED) | ||
set_property(TARGET ${lib} PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/lib${lib}.a") | ||
endforeach(lib) | ||
|
||
# Exported clangTooling target. | ||
add_library(clangTooling STATIC IMPORTED GLOBAL) | ||
set_property(TARGET clangTooling PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libclangTooling.a") | ||
target_include_directories(clangTooling INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
set_target_properties(clangTooling PROPERTIES INTERFACE_LINK_LIBRARIES "${CLANG_TOOLING_DEPS}") |